Private
Public Access
0
0

feat(markdown): apply active theme syntax palette to code blocks

This commit is contained in:
2026-06-04 23:13:33 -04:00
parent df2e82a82d
commit 1cb68e4e3f
2 changed files with 32 additions and 0 deletions
+25
View File
@@ -54,3 +54,28 @@ def test_duplicate_table_content_both_get_replaced():
full = "".join(str(c) for c in mock_md.render.call_args_list)
assert "| A | B |" not in full, f"Raw table text leaked on duplicate: {full!r}"
def test_render_applies_current_syntax_palette(monkeypatch):
"""When a theme is active, the render path should call apply_syntax_palette
so new code-block editors pick up the theme's syntax palette."""
from unittest.mock import patch
from src import theme_2 as theme
class _Tracker:
last_palette = None
last_call = False
def fake_apply(palette_id):
_Tracker.last_palette = palette_id
_Tracker.last_call = True
monkeypatch.setattr(theme, "apply_syntax_palette", fake_apply)
monkeypatch.setattr(theme, "_current_palette", "solarized_dark")
monkeypatch.setattr(theme, "get_syntax_palette_for_theme", lambda n: "dark")
from src.markdown_helper import MarkdownRenderer
with patch("src.markdown_helper.imgui_md") as mock_md, patch("src.markdown_helper.imgui") as mock_imgui, patch("src.markdown_table.imgui") as mock_table_imgui:
_mock_table_calls(mock_table_imgui)
MarkdownRenderer().render("hello world", context_id="p")
assert _Tracker.last_call, "expected apply_syntax_palette to be called"