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

Math plugin does not escape text hor html #400

Open
buehlefs opened this issue Nov 21, 2024 · 0 comments
Open

Math plugin does not escape text hor html #400

buehlefs opened this issue Nov 21, 2024 · 0 comments

Comments

@buehlefs
Copy link

The math plugin does not escape text for html (even if the renderer is configured to escape html).
This can be a problem when the math code contains html characters, e.g., \eft<1\right>.

Possible Fix:

# plugins/math.py
from ..util import escape

def render_block_math(renderer, text):
    if getattr(renderer, "_escape", False):
        text = escape(text)
    return '<div class="math">$$\n' + text + '\n$$</div>\n'


def render_inline_math(renderer, text):
    if getattr(renderer, "_escape", False):
        text = escape(text)
    return r'<span class="math">\(' + text + r'\)</span>'

But considering the output is always html, it could be a good idea to always escape the output.

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

1 participant