Add syntax highlighting for fenced code blocks in markdown artifacts
Enables codehilite on the markdown renderer (Pygments, 'friendly' style, vendored as static/themes/pygments.css) so fenced code blocks get real syntax highlighting with zero client-side JS - matching the "themes are CSS-only" stance in framework_artifact_rendering.md. Verified live against the running dev instance: a fenced python block renders with highlighted keyword/string/function spans. This was Gap 2 from planning/2026-09-02-artifact_kind_gaps_for_frequent_agent_output.md, picked as the first fix since it needed no new kind or design decision - just enabling an existing markdown extension. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
d9fc28aec0
commit
af9ecf28a9
5 changed files with 102 additions and 2 deletions
|
|
@ -356,3 +356,16 @@ class ArtifactAPITestCase(APITestCase):
|
|||
)
|
||||
self.assertEqual(response.status_code, 400, field)
|
||||
self.assertIn(field, response.data["detail"])
|
||||
|
||||
# -- syntax highlighting -------------------------------------------------
|
||||
|
||||
def test_markdown_fenced_code_block_gets_syntax_highlighted(self):
|
||||
response = self.create_artifact(
|
||||
content="# Test\n\n```python\ndef hello():\n return \"world\"\n```"
|
||||
)
|
||||
artifact = Artifact.objects.get(pk=response.data["id"])
|
||||
stored_html = (self.artifacts_root / artifact.path).read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn('class="codehilite"', stored_html)
|
||||
self.assertIn('<span class="k">def</span>', stored_html)
|
||||
self.assertIn('href="http://testserver/static/themes/pygments.css"', stored_html)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue