Skip to content

Add skylighting syntax highlighting support#10

Merged
srid merged 8 commits intomasterfrom
sky
Dec 19, 2025
Merged

Add skylighting syntax highlighting support#10
srid merged 8 commits intomasterfrom
sky

Conversation

@srid
Copy link
Copy Markdown
Owner

@srid srid commented Dec 19, 2025

Adds syntax highlighting for code blocks using the skylighting library. When enabled, code blocks in Pandoc documents will be tokenized and rendered with appropriate elements containing CSS classes for syntax highlighting. Falls back to plain text when language is unknown or highlighting is disabled.

The implementation includes:

  • New Skylighting.hs module that tokenizes code and renders highlighted XML nodes
  • Extension to RenderCtx to support enabling/disabling highlighting
  • Integration into the code block rendering pipeline

Refs: srid/emanote#337

@srid srid marked this pull request as ready for review December 19, 2025 01:48
@srid srid merged commit 81f1ea0 into master Dec 19, 2025
@srid srid deleted the sky branch December 19, 2025 01:56
srid added a commit to srid/emanote that referenced this pull request Dec 19, 2025
Replaces client-side JavaScript syntax highlighters (highlight.js,
prism.js) with static highlighting using skylighting, the same library
used by Pandoc.

Key improvements:
- Code blocks are now highlighted at build time using skylighting (140+
languages supported)
- No JavaScript required, resulting in faster page loads and better
compatibility
- Works seamlessly with live preview mode
- Both light and dark mode themes included
- Configurable via `syntaxHighlighting` option (default: true)

The documentation has been updated to reflect the new approach, and
legacy JavaScript snippets have been removed from example
configurations.

Resolves #337
Uses srid/heist-extra#10
srid added a commit that referenced this pull request Apr 21, 2026
* Add static math rendering via texmath (#11)

Mirrors the skylighting pattern from #10: a new
Heist.Extra.Splices.Pandoc.Texmath module converts LaTeX math to MathML
at build time using texmath's readTeX + writeMathML, producing XmlHtml
nodes browsers render natively without a client-side JS dependency.

Intercept B.Math in Render.hs, gated by a new enableStaticMath field on
RenderCtx (alongside enableSyntaxHighlighting). mkRenderCtx now takes
the extra Bool.

* refactor(hickey+lowy): RenderFeatures record with sum-typed backends

Hickey H1 + Lowy A1: replace positional Bool flags (enableSyntaxHighlighting,
enableStaticMath) with a named RenderFeatures record carrying sum-typed
backends (CodeBackend = NoHighlighting | Skylighting, MathBackend = NoStaticMath
| StaticMathML). mkRenderCtx now takes one RenderFeatures arg instead of two
trailing Bools, so adding a third backend is zero-cost at call sites and the
'which backend' axis is named rather than positional.

Hickey H2: extract renderMathPassthrough so the B.Math case is purely backend
selection, with error handling as a single local case in the static arm.

* refactor(hickey): preserve CRef entities instead of silently dropping

Hickey H3: fromContent previously returned [] for XL.CRef, which would have
silently dropped character references. In practice texmath's MathML writer
emits Unicode directly so this branch is unreachable, but preserve the
entity literally so any future regression is visible rather than invisible.

* fix(police): fact-check — repair merged .gitignore line

Earlier append via heredoc lost the trailing newline and glued
.direnv and .do-results.json into one broken token. Restore both
entries on their own lines.

* refactor(police): elegance — replace hand-rolled XL→XmlHtml walker

/simplify reuse pass: serialize texmath's Text.XML.Light.Element via
showElement, then let xmlhtml's own parseXML rebuild the tree. Drops
the fromElement/fromAttr/fromContent helpers (~20 lines) and the
now-moot CRef-handling branch. Mirrors the existing pattern at
Heist/Extra/TemplateState.hs:69.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant