Show More
@@ -23,7 +23,7 from IPython.utils.decorators import undoc | |||||
23 |
|
23 | |||
24 | @undoc |
|
24 | @undoc | |
25 | class MathBlockGrammar(mistune.BlockGrammar): |
|
25 | class MathBlockGrammar(mistune.BlockGrammar): | |
26 |
block_math = re.compile("^\$\$( |
|
26 | block_math = re.compile(r"^\$\$(.*?)\$\$", re.DOTALL) | |
27 | latex_environment = re.compile(r"^\\begin\{([a-z]*\*?)\}(.*?)\\end\{\1\}", |
|
27 | latex_environment = re.compile(r"^\\begin\{([a-z]*\*?)\}(.*?)\\end\{\1\}", | |
28 | re.DOTALL) |
|
28 | re.DOTALL) | |
29 |
|
29 | |||
@@ -52,12 +52,13 class MathBlockLexer(mistune.BlockLexer): | |||||
52 |
|
52 | |||
53 | @undoc |
|
53 | @undoc | |
54 | class MathInlineGrammar(mistune.InlineGrammar): |
|
54 | class MathInlineGrammar(mistune.InlineGrammar): | |
55 |
math = re.compile("^\$( |
|
55 | math = re.compile(r"^\$(.+?)\$") | |
|
56 | block_math = re.compile(r"^\$\$(.+?)\$\$", re.DOTALL) | |||
56 | text = re.compile(r'^[\s\S]+?(?=[\\<!\[_*`~$]|https?://| {2,}\n|$)') |
|
57 | text = re.compile(r'^[\s\S]+?(?=[\\<!\[_*`~$]|https?://| {2,}\n|$)') | |
57 |
|
58 | |||
58 | @undoc |
|
59 | @undoc | |
59 | class MathInlineLexer(mistune.InlineLexer): |
|
60 | class MathInlineLexer(mistune.InlineLexer): | |
60 | default_rules = ['math'] + mistune.InlineLexer.default_rules |
|
61 | default_rules = ['math', 'block_math'] + mistune.InlineLexer.default_rules | |
61 |
|
62 | |||
62 | def __init__(self, renderer, rules=None, **kwargs): |
|
63 | def __init__(self, renderer, rules=None, **kwargs): | |
63 | if rules is None: |
|
64 | if rules is None: | |
@@ -67,6 +68,9 class MathInlineLexer(mistune.InlineLexer): | |||||
67 | def output_math(self, m): |
|
68 | def output_math(self, m): | |
68 | return self.renderer.inline_math(m.group(1)) |
|
69 | return self.renderer.inline_math(m.group(1)) | |
69 |
|
70 | |||
|
71 | def output_block_math(self, m): | |||
|
72 | return self.renderer.block_math(m.group(1)) | |||
|
73 | ||||
70 | @undoc |
|
74 | @undoc | |
71 | class MarkdownWithMath(mistune.Markdown): |
|
75 | class MarkdownWithMath(mistune.Markdown): | |
72 | def __init__(self, renderer, **kwargs): |
|
76 | def __init__(self, renderer, **kwargs): |
General Comments 0
You need to be logged in to leave comments.
Login now