"""Preserve report TeX for markdown.js's existing deferred KaTeX renderer.""" import re from html.parser import HTMLParser from xml.etree import ElementTree from markdown.blockprocessors import BlockProcessor from markdown.extensions import Extension from markdown.inlinepatterns import InlineProcessor from markdown.util import AtomicString # Keep delimiter and currency rules aligned with mathBlocks in markdown.js. _ESCAPED_MATH = r"\\\[([\s\S]*?)\\\]|\\\(([^\n]*?)\\\)" _DOLLAR_MATH = ( r"\$\$([\s\S]*?)\$\$|" r"(?