Files
hermes-webui/tests/test_issue_code_syntax_highlight.py
T
2026-06-22 06:55:38 +00:00

28 lines
1.1 KiB
Python

"""Regression tests for fenced code block syntax highlighting."""
from pathlib import Path
UI_JS = Path(__file__).resolve().parent.parent / "static" / "ui.js"
def _read_ui_js() -> str:
return UI_JS.read_text()
def test_fenced_code_blocks_add_prism_language_class():
js = _read_ui_js()
assert 'class="language-${esc(lang)}"' in js, (
"Fenced code blocks should add Prism language-* classes so syntax highlighting works"
)
def test_fenced_code_blocks_keep_existing_pre_header_layout():
js = _read_ui_js()
# The fenced code rendering was moved into the stash callback (#1154 fix).
# The template string now uses `lang` instead of `normalizedLang`, and
# markdown-source fences may add a dedicated md-source-block class.
assert '${h}<pre${preClass}><code${langAttr}>${esc(code.replace(/\\n$/,' in js, (
"The syntax-highlight fix should preserve the shared fenced code block layout"
)
assert '<div class="code-block">' not in js, (
"This fix should not introduce a new wrapper around fenced code blocks"
)