File: math_misc.py

package info (click to toggle)
python-pdoc 15.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,192 kB
  • sloc: python: 8,013; javascript: 1,156; makefile: 18; sh: 3
file content (86 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
Markdown should ignore tokens within inline `$...$` and displaymath `$$...$$`.
https://github.com/mitmproxy/pdoc/issues/639
"""


def test_stars():
    r"""
    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\*}
    f(x) &= x^2\\
         &= x \cdot x
    \end{align\*}
    $$

    Workaround (escaping `\\`):

    $$
    \begin{align\*}
    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}
    $$
    """