Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dollar sign destroys escaping #25

Open
schra opened this issue Sep 23, 2021 · 3 comments
Open

Dollar sign destroys escaping #25

schra opened this issue Sep 23, 2021 · 3 comments

Comments

@schra
Copy link

schra commented Sep 23, 2021

Tested sphinx-math-dollar versions: 1.2 and c60310d

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:
Screenshot from 2021-09-23 19-42-19

@asmeurer
Copy link
Member

If I had to guess, there is some issue with this nasty regular expression

dollars = re.compile(r"(?<!\$)(?<!\\)\$(\$)?([^\$ ](?:(?<=\\)\$|[^\$])*?)(?<!\\)\$(?(1)\$|)")

@schra
Copy link
Author

schra commented Sep 24, 2021

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.

@asmeurer
Copy link
Member

asmeurer commented Sep 24, 2021

This has to do with the change from #22 (#24).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants