Skip to content

Commit fe1f481

Browse files
committed
Add ADR for code block syntax highlighting and ADR template
1 parent a366afd commit fe1f481

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ADR 0001: Code Block Syntax Highlighting
2+
3+
**Date:** 2026-03-29
4+
**Status:** Done
5+
6+
## Context
7+
8+
The theme needed support for displaying code blocks in posts and pages. Ghost's Koenig editor outputs `<pre><code class="language-*">` markup but the theme had no styles or syntax highlighting for it.
9+
10+
## Decisions
11+
12+
### Prism.js via CDN
13+
14+
Prism.js is loaded from jsDelivr with the autoloader plugin rather than bundled into `app.js`. This keeps the theme build lean and means any language is supported on demand without maintaining a list of grammar files.
15+
16+
### Token colors from the design system
17+
18+
Syntax token colors are mapped to existing CSS variables (`--color-blue`, `--color-green`, `--color-red`, `--color-yellow`) rather than introducing a third-party theme. This keeps the code blocks feeling native to the site.
19+
20+
### Language label via JS + CSS
21+
22+
Ghost's Markdown card puts `language-*` on the `<code>` element, not the `<pre>`. A script in `post.js` reads the class, extracts the language name, and sets it as `data-language` on the `<pre>`. A CSS `::before` pseudo-element renders the label. This avoids a dependency on Ghost-specific markup that could change.
23+
24+
### Line wrap toggle via `<!--wrap-->` HTML card
25+
26+
Ghost provides no mechanism to add classes to code block elements from the editor. Authors who want line wrapping instead of horizontal scroll can insert an HTML card containing `<!--wrap-->` immediately before a code block. A script in `post.js` detects the comment node and adds a `.wrap` class to the `<pre>`.
27+
28+
## Alternatives Considered
29+
30+
- **Bundling Prism grammars** — would avoid the CDN dependency but add build complexity and require updating the bundle when new languages are needed.
31+
- **A Prism theme (e.g. Tomorrow Night)** — rejected in favor of token colors derived from the design system.
32+
- **Default line wrapping** — rejected because wrapping breaks visual indentation and makes code harder to scan. Opt-in per block is more appropriate.

docs/adr/template.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# ADR XXXX: Title
2+
3+
**Date:** YYYY-MM-DD
4+
**Status:** Proposed
5+
6+
<!-- Status options:
7+
Proposed — under discussion, not yet adopted
8+
Accepted — deliberate choice made after weighing options
9+
Done — written after the fact; documents what was built and why
10+
Deprecated — no longer relevant
11+
Superseded by ADR-XXXX — replaced by a later decision
12+
-->
13+
14+
## Context
15+
16+
What problem were you solving? What constraints or forces shaped the decision?
17+
18+
## Decisions
19+
20+
What was decided, and why?
21+
22+
## Alternatives Considered
23+
24+
What else was on the table and why was it ruled out?

0 commit comments

Comments
 (0)