all2md.utils.html_utils

HTML-related utility helpers.

all2md.utils.html_utils.escape_html(text: str, *, enabled: bool = True) str

Escape HTML special characters when enabled.

all2md.utils.html_utils.render_math_html(content: str, notation: Literal['latex', 'mathml', 'html'], *, inline: bool, escape_enabled: bool = True) str

Render math content as HTML wrapper with notation metadata.

Parameters:
  • content (str) – Math content to render

  • notation (MathNotation) – Format of the math content (“latex”, “mathml”, or “html”)

  • inline (bool) – If True, render as inline math (span), otherwise block math (div)

  • escape_enabled (bool, default True) – If True, escape HTML special characters in content to prevent XSS. When notation=”html”, this should generally be True unless you are certain the content comes from a trusted source.

Returns:

HTML string with math content wrapped in appropriate tags

Return type:

str

Warning

When using notation=”html” with escape_enabled=False, you must ensure that the content comes from a trusted source to prevent XSS attacks.