1919HLJS_THEME_INIT_JS = REPO_ROOT / "static" / "js" / "hljs-theme-init.js"
2020# HLJS_THEME_SHEETS was extracted to shared/theme.js (Day 4 module split).
2121# app.js re-exports it, but the canonical source is theme.js.
22- APP_JS = REPO_ROOT / "static" / "js" / "shared" / "theme.js"
22+ THEME_JS = REPO_ROOT / "static" / "js" / "shared" / "theme.js"
2323
2424
2525def _link_attr (html : str , link_id : str , attr : str ) -> str :
@@ -38,7 +38,7 @@ def _link_attr(html: str, link_id: str, attr: str) -> str:
3838def _js_theme_entry (js : str , theme : str ) -> dict :
3939 """Return {'href': ..., 'integrity': ...} from HLJS_THEME_SHEETS.<theme>."""
4040 block = re .search (re .escape (theme ) + r"\s*:\s*\{([^}]*)\}" , js , re .DOTALL )
41- assert block , f"HLJS_THEME_SHEETS.{ theme } entry not found in app .js"
41+ assert block , f"HLJS_THEME_SHEETS.{ theme } entry not found in theme .js"
4242 body = block .group (1 )
4343 out = {}
4444 for key in ("href" , "integrity" ):
@@ -63,27 +63,27 @@ def _js_string_assignments(js: str, keys: tuple[str, ...]) -> dict[str, str]:
6363
6464def test_dark_theme_url_and_hash_match_between_html_and_js ():
6565 html = INDEX_HTML .read_text (encoding = "utf-8" )
66- js = APP_JS .read_text (encoding = "utf-8" )
66+ js = THEME_JS .read_text (encoding = "utf-8" )
6767
6868 html_href = _link_attr (html , "hljs-theme" , "href" )
6969 html_integrity = _link_attr (html , "hljs-theme" , "integrity" )
7070 js_dark = _js_theme_entry (js , "dark" )
7171
7272 assert html_href == js_dark ["href" ], (
73- "highlight.js theme URL drifted between index.html and app .js — "
74- f"html={ html_href !r} , app .js HLJS_THEME_SHEETS.dark={ js_dark ['href' ]!r} . "
73+ "highlight.js theme URL drifted between index.html and theme .js — "
74+ f"html={ html_href !r} , theme .js HLJS_THEME_SHEETS.dark={ js_dark ['href' ]!r} . "
7575 "On a version bump both must update together (issue #19)."
7676 )
7777 assert html_integrity == js_dark ["integrity" ], (
78- "highlight.js theme SRI hash drifted between index.html and app .js — "
78+ "highlight.js theme SRI hash drifted between index.html and theme .js — "
7979 f"html={ html_integrity !r} , "
80- f"app .js HLJS_THEME_SHEETS.dark={ js_dark ['integrity' ]!r} ."
80+ f"theme .js HLJS_THEME_SHEETS.dark={ js_dark ['integrity' ]!r} ."
8181 )
8282
8383
8484def test_light_theme_url_and_hash_match_between_hljs_init_and_theme_js ():
8585 init_js = HLJS_THEME_INIT_JS .read_text (encoding = "utf-8" )
86- theme_js = APP_JS .read_text (encoding = "utf-8" )
86+ theme_js = THEME_JS .read_text (encoding = "utf-8" )
8787
8888 init = _js_string_assignments (init_js , ("integrity" , "href" ))
8989 js_light = _js_theme_entry (theme_js , "light" )
0 commit comments