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

Code snippet interferes with latex expressions #340

Closed
franciszekjuras opened this issue Jan 27, 2022 · 8 comments
Closed

Code snippet interferes with latex expressions #340

franciszekjuras opened this issue Jan 27, 2022 · 8 comments
Labels

Comments

@franciszekjuras
Copy link

To reproduce bug, create docstring:

"""
$n \\leq 0$. 
`l` is interfering.
"""

Result:
image
It appears that processing l somehow eats escape characters in \\leq as one possible workaround is to write \\\\leq
If l is changed to something different, equation is rendered properly:

'''
$n \\leq 0$. 
`k` is not interfering.
'''

image
Similarly:

"""
$n \\geq 0$. 
`g` is interfering.
"""

image

@mhils

This comment has been minimized.

@mhils mhils closed this as completed Jan 27, 2022
@mhils

This comment has been minimized.

@mhils mhils reopened this Jan 27, 2022
@mhils
Copy link
Member

mhils commented Jan 27, 2022

Looks like this is a bug in markdown2, the markdown parser we use:

>>> import markdown2
>>> markdown2.markdown('$n \\leq 0$.\n`l` is interfering.')
'<p>$n leq 0$.\n<code>l</code> is interfering.</p>\n'
>>> markdown2.markdown('$n \\leq 0$.\n`xl` is interfering.')
'<p>$n \\leq 0$.\n<code>xl</code> is interfering.</p>\n'

@franciszekjuras
Copy link
Author

franciszekjuras commented Jan 27, 2022

Thanks. I'll open an issue upstream.
Edit: I wanted to execute your snippet on my pc, but it turns out markdown2 is not installed with pdoc. Is this package somehow embedded in pdoc?

@mhils
Copy link
Member

mhils commented Jan 27, 2022

pdoc includes a vendored copy at pdoc.markdown2, but this also affects the latest markdown2 release.

@mhils mhils added the upstream label Jan 27, 2022
@mhils
Copy link
Member

mhils commented Jan 27, 2022

This is tracked at trentm/python-markdown2#412. The arguably annoying workaround is to not have code tags that are just a single character and maybe use $l$ again.

@mhils
Copy link
Member

mhils commented Mar 23, 2022

Thanks for fixing this, @Crozzers! 🍰

@mhils mhils closed this as completed in ed7f3e0 Mar 23, 2022
@Crozzers
Copy link
Contributor

No problem! Just happy that the fixes for #344 made it in as well.

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

No branches or pull requests

3 participants