Add admin preview views + fix markdown converter
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 5m31s

- Fix _markdown() in lexical_to_sx.py: render markdown to HTML with
  mistune.html() before storing in ~kg-html
- Add shared/sx/prettify.py: sx_to_pretty_sx and json_to_pretty_sx
  produce sx AST for syntax-highlighted DOM (uses canonical serialize())
- Add preview tab to admin header nav
- Add GET /preview/ route with 4 views: prettified sx, prettified
  lexical JSON, sx rendered HTML, lexical rendered HTML
- Add ~blog-preview-panel and ~blog-preview-section components
- Add syntax highlight CSS for sx/JSON tokens

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 00:50:57 +00:00
parent a8e06e87fb
commit 4ede0368dc
6 changed files with 300 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ from __future__ import annotations
import json
from typing import Callable
import mistune
# ---------------------------------------------------------------------------
# Registry
@@ -435,4 +437,5 @@ def _paywall(_node: dict) -> str:
@_converter("markdown")
def _markdown(node: dict) -> str:
md_text = node.get("markdown", "")
return f'(~kg-html :html "{_esc(md_text)}")'
rendered = mistune.html(md_text)
return f'(~kg-html :html "{_esc(rendered)}")'