Skip to content

1.8.12 — Mermaid diagrams + code line numbers#46

Merged
spagu merged 3 commits into
mainfrom
1.8.12
Jul 22, 2026
Merged

1.8.12 — Mermaid diagrams + code line numbers#46
spagu merged 3 commits into
mainfrom
1.8.12

Conversation

@spagu

@spagu spagu commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Why

The published guides/blog (e.g. cloudflare-workers-redirects-and-stripe) showed Mermaid fences that never rendered, and code blocks had no highlighting or line numbers.

What's in it

Mermaid diagrams (GO-073)

  • mermaid: true rewrites a ```mermaid fence into a <pre class="mermaid"> block before markdown conversion, so the diagram source passes through verbatim instead of being HTML-escaped (--&gt;) — which is exactly why the fences failed to parse before.
  • The mermaid.js runtime is injected only on pages that contain a diagram, mirroring the page-scoped KaTeX approach. Off by default; a fence stays a plain code block when disabled. Nested fences and unclosed fences are handled like the math rewriter.

Line numbers for code highlighting (GO-074)

  • highlight_line_numbers: true prefixes every Chroma-highlighted block with line numbers (requires highlight: true), via chromahtml.WithLineNumbers.

Docs site

  • docs-site.yaml now enables highlight, highlight_line_numbers and mermaid, so the guides/blog render coloured code with line numbers and working diagrams.

Verification

  • go build, gofmt, go vet clean; gosec 0, golangci-lint 0; full test suite green.
  • New tests: mermaid fence rewriting (top-level / nested / unclosed), page-scoped injection idempotency, line numbers on/off, and an end-to-end conversion asserting the arrow is not escaped.
  • E2E: rebuilt docs-site.yaml; the blog post now emits <pre class="mermaid"> with raw -->, the runtime once, inline highlight colours and per-line numbers.
  • No dependency downgrade — chroma stays v2.27.0 (now a direct dep).

Please review — do not merge yet.

spagu added 3 commits July 22, 2026 10:24
…hangelog

Completes the 1.8.12 code-rendering work (feature code in 75bb0ff):
- unit + end-to-end tests: mermaid fence rewriting (top-level, nested, unclosed),
  page-scoped runtime injection, and highlight line numbers on/off
- docs/CONFIGURATION.md: mermaid + highlight_line_numbers
- .ssg.yaml.example and CHANGELOG [1.8.12]
@sonarqubecloud

Copy link
Copy Markdown

@spagu
spagu merged commit 8eb4f05 into main Jul 22, 2026
24 checks passed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.52066% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/generator/render_transforms.go 66.66% 1 Missing and 1 partial ⚠️
internal/generator/generator.go 91.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

2 participants