sphinx-math-dollar 1.2__py3-none-any.whl → 1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
+ from . import _version
2
+ __version__ = _version.get_versions()['version']
3
+
4
+
1
5
  from .math_dollar import split_dollars
2
6
  from .extension import setup, NODE_BLACKLIST
3
7
 
4
8
  __all__ = ['split_dollars', 'setup', 'NODE_BLACKLIST']
5
9
 
6
- from ._version import get_versions
7
- __version__ = get_versions()['version']
8
- del get_versions
@@ -1,5 +1,5 @@
1
1
 
2
- # This file was generated by 'versioneer.py' (0.18) from
2
+ # This file was generated by 'versioneer.py' (0.21) from
3
3
  # revision-control system data, or from the parent directory name of an
4
4
  # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
5
  # of this file.
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2020-09-17T13:01:12-0600",
11
+ "date": "2026-02-05T11:06:39-0700",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "4bae503c3da72ab25cb1edb4dc62d48be41d3b48",
15
- "version": "1.2"
14
+ "full-revisionid": "3c9592e9d1bb9ec9e3bfe9e07ed8f6468012014a",
15
+ "version": "1.3"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -1,29 +1,52 @@
1
- from __future__ import print_function
1
+ import logging
2
2
  import os
3
3
  import sys
4
4
 
5
- from .math_dollar import split_dollars
6
-
7
- from docutils.nodes import GenericNodeVisitor, Text, math, math_block, FixedTextElement, literal
5
+ from docutils.nodes import (
6
+ FixedTextElement,
7
+ GenericNodeVisitor,
8
+ SkipNode,
9
+ Text,
10
+ literal,
11
+ math,
12
+ math_block,
13
+ )
8
14
  from docutils.transforms import Transform
9
15
 
16
+ from . import __version__
17
+ from .math_dollar import split_dollars
18
+
10
19
  NODE_BLACKLIST = node_blacklist = (FixedTextElement, literal, math)
11
20
 
12
21
  DEBUG = bool(os.environ.get("MATH_DOLLAR_DEBUG", False))
13
22
 
23
+
14
24
  class MathDollarReplacer(GenericNodeVisitor):
15
25
  def default_visit(self, node):
16
26
  return node
17
27
 
28
+ def unknown_visit(self, node):
29
+ logging.warning("sphinx-math-dollar: Skipping unknown node type %s", type(node))
30
+ raise SkipNode
31
+
18
32
  def visit_Text(self, node):
19
33
  parent = node.parent
20
34
  while parent:
21
35
  if isinstance(parent, node_blacklist):
22
- if DEBUG and any(i == 'math' for i, _ in split_dollars(node.rawsource)):
23
- print("sphinx-math-dollar: Skipping", node, "(node_blacklist = %s)" % (node_blacklist,), file=sys.stderr)
36
+ if DEBUG and any(
37
+ i == "math"
38
+ for i, _ in split_dollars(str(node).replace("\x00", "\\"))
39
+ ):
40
+ print(
41
+ "sphinx-math-dollar: Skipping",
42
+ node,
43
+ "(node_blacklist = %s)" % (node_blacklist,),
44
+ file=sys.stderr,
45
+ )
24
46
  return
25
47
  parent = parent.parent
26
- data = split_dollars(node.rawsource)
48
+ # See https://github.com/sympy/sphinx-math-dollar/issues/22
49
+ data = split_dollars(str(node).replace("\x00", "\\"))
27
50
  nodes = []
28
51
  has_math = False
29
52
  for typ, text in data:
@@ -35,14 +58,15 @@ class MathDollarReplacer(GenericNodeVisitor):
35
58
  elif typ == "display math":
36
59
  has_math = True
37
60
  new_node = math_block(text, Text(text))
38
- new_node.attributes.setdefault('nowrap', False)
39
- new_node.attributes.setdefault('number', None)
61
+ new_node.attributes.setdefault("nowrap", False)
62
+ new_node.attributes.setdefault("number", None)
40
63
  nodes.append(new_node)
41
64
  else:
42
65
  raise ValueError("Unrecognized type from split_dollars %r" % typ)
43
66
  if has_math:
44
67
  node.parent.replace(node, nodes)
45
68
 
69
+
46
70
  class TransformMath(Transform):
47
71
  # See http://docutils.sourceforge.net/docs/ref/transforms.html. We want it
48
72
  # to apply before things that change rawsource, since we have to use that
@@ -50,19 +74,29 @@ class TransformMath(Transform):
50
74
  # transforms are relevant here, other than SmartQuotes, so this may need
51
75
  # to be adjusted.
52
76
  default_priority = 500
77
+
53
78
  def apply(self, **kwargs):
54
79
  self.document.walk(MathDollarReplacer(self.document))
55
80
 
81
+
56
82
  def config_inited(app, config):
57
83
  global node_blacklist, DEBUG
58
84
  node_blacklist = config.math_dollar_node_blacklist
59
85
  DEBUG = config.math_dollar_debug
60
86
 
87
+
61
88
  def setup(app):
62
89
  app.add_transform(TransformMath)
63
90
  # We can't force a rebuild here because it will always appear different
64
91
  # since the tuple contains classes
65
- app.add_config_value('math_dollar_node_blacklist', NODE_BLACKLIST, '')
66
- app.add_config_value('math_dollar_debug', DEBUG, '')
92
+ app.add_config_value("math_dollar_node_blacklist", NODE_BLACKLIST, "")
93
+ app.add_config_value("math_dollar_debug", DEBUG, "")
94
+ app.add_config_value("parallel_read_safe", True, "")
95
+
96
+ app.connect("config-inited", config_inited)
67
97
 
68
- app.connect('config-inited', config_inited)
98
+ return {
99
+ "version": __version__,
100
+ "parallel_read_safe": True,
101
+ "parallel_write_safe": True,
102
+ }
@@ -1,24 +1,37 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: sphinx-math-dollar
3
- Version: 1.2
3
+ Version: 1.3
4
4
  Summary: Sphinx extension to let you write LaTeX math using $$
5
5
  Home-page: https://github.com/sympy/sphinx-math-dollar/
6
6
  Author: SymPy Development Team
7
7
  Author-email: sympy@googlegroups.com
8
8
  License: MIT
9
- Platform: UNKNOWN
10
- Classifier: Programming Language :: Python :: 2
11
9
  Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
12
14
  Classifier: License :: OSI Approved :: MIT License
13
15
  Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.11
14
17
  License-File: LICENSE
15
18
  Requires-Dist: sphinx
19
+ Dynamic: author
20
+ Dynamic: author-email
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: home-page
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
16
29
 
17
30
  ====================
18
31
  sphinx-math-dollar
19
32
  ====================
20
33
 
21
- sphinx-math-dollar is a Sphinx extension to let you write LaTeX math using $$.
34
+ sphinx-math-dollar is a Sphinx extension to let you write LaTeX math in RST using $$.
22
35
 
23
36
  To enable install it
24
37
 
@@ -45,6 +58,13 @@ Then in your ``conf.py``, add ``'sphinx_math_dollar'`` to your extensions list:
45
58
  },
46
59
  }
47
60
 
61
+ mathjax3_config = {
62
+ "tex": {
63
+ "inlineMath": [['\\(', '\\)']],
64
+ "displayMath": [["\\[", "\\]"]],
65
+ }
66
+ }
67
+
48
68
 
49
69
  The ``mathjax_config`` is needed to prevent MathJax from parsing dollar signs
50
70
  which are ignored by the extension because they should not be parsed as math.
@@ -99,9 +119,34 @@ To debug which nodes are skipped, set the environment variable
99
119
  If you feel a node should always be part of the default blacklist, please make
100
120
  a `pull request <https://github.com/sympy/sphinx-math-dollar>`_.
101
121
 
122
+ Known Issues
123
+ ============
124
+
125
+ See `the issue tracker <https://github.com/sympy/sphinx-math-dollar/issues>`__
126
+ for a full list of known issues.
127
+
128
+ - Absolute values can produce errors like ``Inline substitution_reference
129
+ start-string without end-string.``. See `issue #16
130
+ <https://github.com/sympy/sphinx-math-dollar/issues/16>`__.
131
+
132
+ This is because Sphinx parses the vertical bars ``|x|`` as inline
133
+ substitutions. To work around this, add spaces around the absolute value
134
+ bars, like ``1 + | x | + y``. If an absolute value bar is at the beginning
135
+ or end of the math expression, use curly braces (to avoid false positives,
136
+ sphinx-math-dollar will not parse dollar signs as math if there is a space
137
+ after the first ``$`` or before the last ``$``). For example, replace ``$|y|
138
+ \geq |x^e|$`` with ``${ | y | \geq | x^e | }$``, which produces ${ | y |
139
+ \geq | x^e | }$.
140
+
141
+ Markdown
142
+ ========
143
+
144
+ sphinx-math-dollar is designed to work with RST, which does not natively
145
+ support dollar signs for LaTeX math. If you prefer Markdown, we recommend
146
+ using [MyST](https://myst-parser.readthedocs.io/en/latest/), which natively
147
+ supports dollar math (this extension is not required).
148
+
102
149
  License
103
150
  =======
104
151
 
105
152
  MIT.
106
-
107
-
@@ -0,0 +1,9 @@
1
+ sphinx_math_dollar/__init__.py,sha256=bcmHii2PByvYXutrk_eIiiS8qMcyGmTVX4GZ2jXSPUI,215
2
+ sphinx_math_dollar/_version.py,sha256=jXLvGiXyKsKE_dAK7b4rd_IR0bn5NOZ3U0rEgNd2tTI,495
3
+ sphinx_math_dollar/extension.py,sha256=XUMt7auTPcJTf4ZbLt0Yik2yUpjUVidzzUwSRQbmxwE,3299
4
+ sphinx_math_dollar/math_dollar.py,sha256=nEThpznw83f1GfCYvOyVaPUMOhA1bZBn_KR8W5cgEGY,2609
5
+ sphinx_math_dollar-1.3.dist-info/licenses/LICENSE,sha256=vzfYNl5zzbBlGs990eAErxdU5hhaq5AjfVy5bkW58_c,1071
6
+ sphinx_math_dollar-1.3.dist-info/METADATA,sha256=d9kUC_5EsezivSkU6mpBOEG9lxDvi4oMLfOynUcuP0c,4939
7
+ sphinx_math_dollar-1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
8
+ sphinx_math_dollar-1.3.dist-info/top_level.txt,sha256=P68HuyABkdfqVE9nYxjqUxClEj1MMo-9KMv5Iwl5wVw,19
9
+ sphinx_math_dollar-1.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes
@@ -1,28 +0,0 @@
1
- import os
2
-
3
- from sphinx_testing import with_app
4
-
5
- @with_app(buildername='html', srcdir=os.path.join(os.path.dirname(__file__), 'test-build'),
6
- copy_srcdir_to_tmpdir=True)
7
- def _test_sphinx_build(app, status, warning):
8
- app.build()
9
- html = (app.outdir/'index.html').read_text()
10
-
11
- assert r"\(math\)" in html
12
- assert r"\[displaymath\]" in html
13
- assert "$nomath$" in html
14
-
15
- assert "$math$" not in html
16
- assert "$$displaymath$$" not in html
17
-
18
- assert r"\(nomath\)" not in html
19
- assert r"\(displaymath\)" not in html
20
-
21
- assert r"\[math\]" not in html
22
- assert r"\[nomath\]" not in html
23
-
24
- assert not status.read()
25
- assert not warning.read()
26
-
27
- def test_sphinx_build():
28
- _test_sphinx_build()
@@ -1,57 +0,0 @@
1
- from ..math_dollar import split_dollars
2
-
3
- def test_split_dollars():
4
- assert split_dollars("Text") == [("text", "Text")]
5
- assert split_dollars(r"$\sin(x)$") == [("math", r"\sin(x)")]
6
- assert split_dollars(r"$\sin(x)") == [("text", r"$\sin(x)")]
7
-
8
- assert split_dollars(r"$\sin(x)$ and $\cos(x)$") == \
9
- [
10
- ("math", r"\sin(x)"),
11
- ("text", " and "),
12
- ("math", r"\cos(x)"),
13
- ]
14
- assert split_dollars(r"The functions $\sin(x)$ and $\cos(x)$.") == \
15
- [
16
- ("text", "The functions "),
17
- ("math", r"\sin(x)"),
18
- ("text", " and "),
19
- ("math", r"\cos(x)"),
20
- ("text", "."),
21
- ]
22
-
23
- assert split_dollars(r"$\sin(x)$ and $\cos(x)$") == \
24
- [
25
- ("math", r"\sin(x)"),
26
- ("text", " and "),
27
- ("math", r"\cos(x)"),
28
- ]
29
-
30
- assert split_dollars("Math that is split across lines $\\sin(x) +\n\\cos(x)$.") == \
31
- [
32
- ("text", "Math that is split across lines "),
33
- ("math", "\\sin(x) +\n\\cos(x)"),
34
- ("text", "."),
35
- ]
36
-
37
- assert split_dollars('$f(n) = 0 \text{ if $n$ is prime}$ $f(n) = 0 \text{ if $n$ is prime}$ \text{ if $n$ is prime}')
38
-
39
- assert split_dollars(r"$ ls") == [("text", "$ ls")]
40
- assert split_dollars("$ cd ..\n$ ls") == [("text", "$ cd ..\n$ ls")]
41
-
42
- assert split_dollars(r"\$13 + \$14") == [("text", "$13 + $14")]
43
- assert split_dollars(r"$\$13 + \$14$") == [("math", "$13 + $14")]
44
- assert split_dollars(r"$\$13$.") == [("math", "$13"), ("text", ".")]
45
- assert split_dollars(r" $\sin(x)$") == [("text", " "), ("math", r"\sin(x)")]
46
-
47
- assert split_dollars(r"$$\sin(x)$$") == [("display math", r"\sin(x)")]
48
- assert split_dollars(r"$$\sin(x)$") == [("text", r"$$\sin(x)$")]
49
- assert split_dollars(r"$$\sin(x)") == [("text", r"$$\sin(x)")]
50
- assert split_dollars(r"\$$\sin(x)$$") == [("text", r"$$\sin(x)$$")]
51
- assert split_dollars(r"\$\$\sin(x)\$\$") == [("text", r"$$\sin(x)$$")]
52
- assert split_dollars(r"$\sin(x)$ and $$\cos(x)$$") == \
53
- [
54
- ("math", r"\sin(x)"),
55
- ("text", " and "),
56
- ("display math", r"\cos(x)"),
57
- ]
@@ -1,12 +0,0 @@
1
- sphinx_math_dollar/__init__.py,sha256=B7vcU5K4KIYSODDwl12G06VSz5HBBBTOaBrKa5t5_Wo,233
2
- sphinx_math_dollar/_version.py,sha256=VBI4Ekkzeg6O4FL5xZ-ny7WyxElT94e8Qygtqgkp4W0,495
3
- sphinx_math_dollar/extension.py,sha256=31aT5D3fggQCSraVksg7IAkwAxguNu1ZQ8G9L6lishE,2639
4
- sphinx_math_dollar/math_dollar.py,sha256=nEThpznw83f1GfCYvOyVaPUMOhA1bZBn_KR8W5cgEGY,2609
5
- sphinx_math_dollar/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- sphinx_math_dollar/tests/test_extension.py,sha256=cpSXgyDQe48giG4qalO5jh63I4t-5NvwW1Y6Aojr9Gg,727
7
- sphinx_math_dollar/tests/test_math_dollar.py,sha256=FiM8IPYehBMxe2zLee6DNNu441UYa7lW7yAGL5RFoGA,2206
8
- sphinx_math_dollar-1.2.dist-info/LICENSE,sha256=vzfYNl5zzbBlGs990eAErxdU5hhaq5AjfVy5bkW58_c,1071
9
- sphinx_math_dollar-1.2.dist-info/METADATA,sha256=DY8s0x7rl145tUuIPFW1gUaIGM4wOh2grbg80rj8JMo,3265
10
- sphinx_math_dollar-1.2.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
11
- sphinx_math_dollar-1.2.dist-info/top_level.txt,sha256=P68HuyABkdfqVE9nYxjqUxClEj1MMo-9KMv5Iwl5wVw,19
12
- sphinx_math_dollar-1.2.dist-info/RECORD,,