diff --git a/test/testdata/math_misc.html b/test/testdata/math_misc.html index 4c62be77..44f05e85 100644 --- a/test/testdata/math_misc.html +++ b/test/testdata/math_misc.html @@ -48,6 +48,15 @@

API Documentation

  • test_stars
  • +
  • + test_math_newline +
  • +
  • + test_markdown_newline +
  • +
  • + test_macros +
  • @@ -64,34 +73,96 @@

    API Documentation

    math_misc

    - +

    Markdown should ignore tokens within inline $...$ and displaymath $$...$$. +https://github.com/mitmproxy/pdoc/issues/639

    +
    + -
     1def test_stars():
    - 2    r"""
    - 3    Markdown emphasis tokens (*) should be rendered correctly.
    - 4    https://github.com/mitmproxy/pdoc/issues/639
    +                        
     1"""
    + 2Markdown should ignore tokens within inline `$...$` and displaymath `$$...$$`.
    + 3https://github.com/mitmproxy/pdoc/issues/639
    + 4"""
      5
    - 6    Currently broken:
    - 7
    - 8    $$
    - 9    \begin{align*}
    -10    f(x) &= x^2\\
    -11         &= x \cdot x
    -12    \end{align*}
    -13    $$
    -14
    -15    Workaround:
    -16
    -17    $$
    -18    \begin{align\*}
    -19    f(x) &= x^2\\
    -20         &= x \cdot x
    -21    \end{align\*}
    -22    $$
    -23    """
    + 6def test_stars():
    + 7    r"""
    + 8    Markdown emphasis tokens (`*`) should not be captured in math mode.
    + 9
    +10    Currently broken: $*xyz*$
    +11
    +12    Workaround (escaping `*`): $\*xyz\*$
    +13
    +14    Workaround (extra whitespace): $* xyz *$
    +15
    +16    """
    +17
    +18def test_math_newline():
    +19    r"""
    +20    Markdown should not consume double backslashes (math newlines) in math mode.
    +21
    +22    Currently broken:
    +23
    +24    $$
    +25    \begin{align\*}
    +26    f(x) &= x^2\\
    +27         &= x \cdot x
    +28    \end{align\*}
    +29    $$
    +30
    +31    Workaround (escaping `\\`):
    +32
    +33    $$
    +34    \begin{align\*}
    +35    f(x) &= x^2\\\\
    +36         &= x \cdot x
    +37    \end{align\*}
    +38    $$
    +39    """
    +40
    +41def test_markdown_newline():
    +42    r"""
    +43    Markdown newlines (`\n\n`) should not emit a paragraph break in math mode.
    +44    
    +45    Currently broken:
    +46
    +47    $$
    +48    x + y
    +49
    +50    = z
    +51    $$
    +52
    +53    Workaround (no empty lines in math mode):
    +54
    +55    $$
    +56    x + y
    +57    % comment
    +58    = z
    +59    $$
    +60    """
    +61
    +62def test_macros():
    +63    r"""
    +64    Markdown should not capture headings (`#`) in math mode.
    +65    Currently broken:
    +66
    +67    $$
    +68    \newcommand{\define}[2]
    +69    {
    +70    #1 \quad \text{#2}
    +71    }
    +72    \define{e^{i\pi}+1=0}{Euler's identity}
    +73    $$
    +74
    +75
    +76    Workaround (no lines with leading `#`):
    +77
    +78    $$
    +79    \newcommand{\define}[2]{#1 \quad \text{#2}}
    +80    \define{e^{i\pi}+1=0}{Euler's identity}
    +81    $$
    +82    """
     
    @@ -107,55 +178,202 @@

    -
     2def test_stars():
    - 3    r"""
    - 4    Markdown emphasis tokens (*) should be rendered correctly.
    - 5    https://github.com/mitmproxy/pdoc/issues/639
    - 6
    - 7    Currently broken:
    - 8
    - 9    $$
    -10    \begin{align*}
    -11    f(x) &= x^2\\
    -12         &= x \cdot x
    -13    \end{align*}
    -14    $$
    -15
    -16    Workaround:
    -17
    -18    $$
    -19    \begin{align\*}
    -20    f(x) &= x^2\\
    -21         &= x \cdot x
    -22    \end{align\*}
    -23    $$
    -24    """
    +            
     7def test_stars():
    + 8    r"""
    + 9    Markdown emphasis tokens (`*`) should not be captured in math mode.
    +10
    +11    Currently broken: $*xyz*$
    +12
    +13    Workaround (escaping `*`): $\*xyz\*$
    +14
    +15    Workaround (extra whitespace): $* xyz *$
    +16
    +17    """
     
    -

    Markdown emphasis tokens (*) should be rendered correctly. -https://github.com/mitmproxy/pdoc/issues/639

    +

    Markdown emphasis tokens (*) should not be captured in math mode.

    + +

    Currently broken: $xyz$

    + +

    Workaround (escaping *): $*xyz*$

    + +

    Workaround (extra whitespace): $* xyz *$

    +
    + + + +
    + +
    + + def + test_math_newline(): + + + +
    + +
    19def test_math_newline():
    +20    r"""
    +21    Markdown should not consume double backslashes (math newlines) in math mode.
    +22
    +23    Currently broken:
    +24
    +25    $$
    +26    \begin{align\*}
    +27    f(x) &= x^2\\
    +28         &= x \cdot x
    +29    \end{align\*}
    +30    $$
    +31
    +32    Workaround (escaping `\\`):
    +33
    +34    $$
    +35    \begin{align\*}
    +36    f(x) &= x^2\\\\
    +37         &= x \cdot x
    +38    \end{align\*}
    +39    $$
    +40    """
    +
    + + +

    Markdown should not consume double backslashes (math newlines) in math mode.

    Currently broken:

    $$ -\begin{align} +\begin{align*} f(x) &= x^2\ &= x \cdot x -\end{align} +\end{align*} $$

    -

    Workaround:

    +

    Workaround (escaping \\):

    $$ \begin{align*} -f(x) &= x^2\ +f(x) &= x^2\\ &= x \cdot x \end{align*} $$

    +
    +
    + +
    + + def + test_markdown_newline(): + + + +
    + +
    42def test_markdown_newline():
    +43    r"""
    +44    Markdown newlines (`\n\n`) should not emit a paragraph break in math mode.
    +45    
    +46    Currently broken:
    +47
    +48    $$
    +49    x + y
    +50
    +51    = z
    +52    $$
    +53
    +54    Workaround (no empty lines in math mode):
    +55
    +56    $$
    +57    x + y
    +58    % comment
    +59    = z
    +60    $$
    +61    """
    +
    + + +

    Markdown newlines (\n\n) should not emit a paragraph break in math mode.

    + +

    Currently broken:

    + +

    $$ +x + y

    + +

    = z +$$

    + +

    Workaround (no empty lines in math mode):

    + +

    $$ +x + y +% comment += z +$$

    +
    + + +
    +
    + +
    + + def + test_macros(): + + + +
    + +
    63def test_macros():
    +64    r"""
    +65    Markdown should not capture headings (`#`) in math mode.
    +66    Currently broken:
    +67
    +68    $$
    +69    \newcommand{\define}[2]
    +70    {
    +71    #1 \quad \text{#2}
    +72    }
    +73    \define{e^{i\pi}+1=0}{Euler's identity}
    +74    $$
    +75
    +76
    +77    Workaround (no lines with leading `#`):
    +78
    +79    $$
    +80    \newcommand{\define}[2]{#1 \quad \text{#2}}
    +81    \define{e^{i\pi}+1=0}{Euler's identity}
    +82    $$
    +83    """
    +
    + + +

    Markdown should not capture headings (#) in math mode. +Currently broken:

    + +

    $$ +\newcommand{\define}[2] +{

    + +

    1 \quad \text{#2}

    + +

    } +\define{e^{i\pi}+1=0}{Euler's identity} +$$

    + +

    Workaround (no lines with leading #):

    + +

    $$ +\newcommand{\define}[2]{#1 \quad \text{#2}} +\define{e^{i\pi}+1=0}{Euler's identity} +$$

    +
    + +
    diff --git a/test/testdata/math_misc.py b/test/testdata/math_misc.py index 642e1874..55f7dc5a 100644 --- a/test/testdata/math_misc.py +++ b/test/testdata/math_misc.py @@ -1,24 +1,82 @@ +""" +Markdown should ignore tokens within inline `$...$` and displaymath `$$...$$`. +https://github.com/mitmproxy/pdoc/issues/639 +""" + def test_stars(): r""" - Markdown emphasis tokens (*) should be rendered correctly. - https://github.com/mitmproxy/pdoc/issues/639 + Markdown emphasis tokens (`*`) should not be captured in math mode. + + Currently broken: $*xyz*$ + + Workaround (escaping `*`): $\*xyz\*$ + + Workaround (extra whitespace): $* xyz *$ + + """ + +def test_math_newline(): + r""" + Markdown should not consume double backslashes (math newlines) in math mode. Currently broken: $$ - \begin{align*} + \begin{align\*} f(x) &= x^2\\ &= x \cdot x - \end{align*} + \end{align\*} $$ - Workaround: + Workaround (escaping `\\`): $$ \begin{align\*} - f(x) &= x^2\\ + f(x) &= x^2\\\\ &= x \cdot x \end{align\*} $$ """ +def test_markdown_newline(): + r""" + Markdown newlines (`\n\n`) should not emit a paragraph break in math mode. + + Currently broken: + + $$ + x + y + + = z + $$ + + Workaround (no empty lines in math mode): + + $$ + x + y + % comment + = z + $$ + """ + +def test_macros(): + r""" + Markdown should not capture headings (`#`) in math mode. + Currently broken: + + $$ + \newcommand{\define}[2] + { + #1 \quad \text{#2} + } + \define{e^{i\pi}+1=0}{Euler's identity} + $$ + + + Workaround (no lines with leading `#`): + + $$ + \newcommand{\define}[2]{#1 \quad \text{#2}} + \define{e^{i\pi}+1=0}{Euler's identity} + $$ + """ diff --git a/test/testdata/math_misc.txt b/test/testdata/math_misc.txt index 8d3305d0..eecce8d7 100644 --- a/test/testdata/math_misc.txt +++ b/test/testdata/math_misc.txt @@ -1,3 +1,6 @@ - + + + > \ No newline at end of file