sphinx-math-dollar
sphinx-math-dollar copied to clipboard
Dollar sign destroys escaping
Tested sphinx-math-dollar versions: 1.2 and https://github.com/sympy/sphinx-math-dollar/commit/c60310d5038c9864ba85640ac76b7ecf9f8724d5
Exemplary reST code:
Test
----
#. **t**\ est
#. **t**\ est :math:`x`
#. **t**\ est $x$
If you didn't know, **t**\ est
sets the first character in bold. In reST you can't just write **t**est
like in Markdown.
Rendered output:
If I had to guess, there is some issue with this nasty regular expression https://github.com/sympy/sphinx-math-dollar/blob/c60310d5038c9864ba85640ac76b7ecf9f8724d5/sphinx_math_dollar/math_dollar.py#L52
Hm, doesn't seem to be the case because if I add the following line to the tests, it works just fine:
assert split_dollars(r"#. **t**\ est $X$") == [("text", r"#. **t**\ est "), ("math", "X")]
The problem is in extension.py. If I replace
data = split_dollars(str(node).replace('\x00', '\\'))
with
data = split_dollars(str(node))
then the bug vanishes - however then some math stuff is also rendered weirdly.
I think the problem is that for some reason the \
from the reST is turned into a \0
when we receive the reST in the extension and when we then replace all \0
with a \
, we turn the \
into a literal \
and not an escaping sequence.
This has to do with the change from https://github.com/sympy/sphinx-math-dollar/issues/22 (https://github.com/sympy/sphinx-math-dollar/pull/24).