Skip to content

Commit 2a01f4e

Browse files
committed
Allow line breaks in inine math
Both dollars/math_inline and brackets/math_inline regexes have been changed, to allow (single) line breaks
1 parent bc799d4 commit 2a01f4e

File tree

5 files changed

+44
-21
lines changed

5 files changed

+44
-21
lines changed

markdown_it/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .main import MarkdownIt # noqa: F401
22

33

4-
__version__ = "0.4.4"
4+
__version__ = "0.4.5"

markdown_it/extensions/texmath/index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def render(tex, displayMode, macros):
146146
"inline": [
147147
{
148148
"name": "math_inline",
149-
"rex": re.compile(r"^\\\((.+?)\\\)"),
149+
"rex": re.compile(r"^\\\((.+?)\\\)", re.DOTALL),
150150
"tmpl": "<eq>{0}</eq>",
151151
"tag": "\\(",
152152
}
@@ -266,7 +266,7 @@ def render(tex, displayMode, macros):
266266
"inline": [
267267
{
268268
"name": "math_inline",
269-
"rex": re.compile(r"^\$(\S[^$\r\n]*?[^\s\\]{1}?)\$"),
269+
"rex": re.compile(r"^\$(\S[^$]*?[^\s\\]{1}?)\$"),
270270
"tmpl": "<eq>{0}</eq>",
271271
"tag": "$",
272272
"pre": dollar_pre,

markdown_it/extensions/texmath/port.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
commit: 78c548829ce2ef85c73dc71e680d01e5ae41ffbf
33
date: Oct 4, 2019
44
version: 0.6
5+
changes: |
6+
both dollars/math_inline and brackets/math_inline regexes have been changed,
7+
to allow (single) line breaks

tests/test_math/fixtures_bracket.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ conjugate complex (valid=True)
8282
<p><eq>a^\*b</eq> with <eq>a^\*</eq></p>
8383
.
8484

85+
Inline multi-line (valid=True)
86+
.
87+
a \(a
88+
\not=1\) b
89+
.
90+
<p>a <eq>a
91+
\not=1</eq> b</p>
92+
.
93+
94+
Inline multi-line with newline (valid=False)
95+
.
96+
a \(a
97+
98+
\not=1\) b
99+
.
100+
<p>a (a</p>
101+
<p>\not=1) b</p>
102+
.
103+
85104
single block equation, greek index (valid=True)
86105
.
87106
\[e_\\alpha\]
@@ -366,12 +385,3 @@ display equation in blockquote. (valid=True)
366385
<p>in blockquote.</p>
367386
</blockquote>
368387
.
369-
370-
line break in inline equation is not allowed. (valid=False)
371-
.
372-
\(1+1=
373-
2\)
374-
.
375-
<p>(1+1=
376-
2)</p>
377-
.

tests/test_math/fixtures_dollar.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ $a^\*b$ with $a^\*$
8282
<p><eq>a^\*b</eq> with <eq>a^\*</eq></p>
8383
.
8484

85+
Inline multi-line (valid=True)
86+
.
87+
a $a
88+
\not=1$ b
89+
.
90+
<p>a <eq>a
91+
\not=1</eq> b</p>
92+
.
93+
94+
Inline multi-line with newline (valid=False)
95+
.
96+
a $a
97+
98+
\not=1$ b
99+
.
100+
<p>a $a</p>
101+
<p>\not=1$ b</p>
102+
.
103+
85104
single block equation, greek index (valid=True)
86105
.
87106
$$e_\\alpha$$
@@ -417,12 +436,3 @@ $x $
417436
$ x$
418437
$x $</p>
419438
.
420-
421-
line break in inline equation is not allowed. (valid=False)
422-
.
423-
$1+1=
424-
2$
425-
.
426-
<p>$1+1=
427-
2$</p>
428-
.

0 commit comments

Comments
 (0)