From f9e314e5eaaab6fa258aadeca2cd6ce76338012c Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 18 Aug 2026 04:32:54 +0000 Subject: [PATCH] Enable markdown-it typographer and breaks; remove custom dash rule --- docs/design-principles.md | 9 +++++++-- pagerite/markdown.py | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/design-principles.md b/docs/design-principles.md index 36cedf4..e82e0a3 100644 --- a/docs/design-principles.md +++ b/docs/design-principles.md @@ -51,8 +51,13 @@ evolves. single-trusted-author assumption above. - Renderer: **markdown-it-py** with mdit-py-plugins (footnotes, definition lists, task lists, brace-attributes; tables and strikethrough from the - default preset), with `html=True` for raw passthrough. Fenced code blocks - are highlighted server-side with **Pygments** (`nowrap` spans styled by + default preset), with `html=True` for raw passthrough, + `typographer=True` for SmartyPants-style replacements in body text (curly + quotes, `--` / `---` → en / em dashes, `...` → ellipsis, `(c)` → ©, etc.), + and `breaks=True` so single line breaks inside paragraphs become `
`. + Code spans/blocks and raw HTML are left untouched. Fenced code blocks are + highlighted server-side with + **Pygments** (`nowrap` spans styled by `/_assets/pygments-*.css`, which maps every token class onto the `--code-*` variables; the base stylesheet defines light and dark palette sets resolved via `light-dark()`, so each theme gets the set matching its `color-scheme` diff --git a/pagerite/markdown.py b/pagerite/markdown.py index 8b3fa8f..e8d41cd 100644 --- a/pagerite/markdown.py +++ b/pagerite/markdown.py @@ -6,6 +6,12 @@ single author is trusted. Extensions: tables and strikethrough (from the brace-attributes (`{.class width=300}` on any element, images in particular). +markdown-it's typographer is enabled, so body text gets SmartyPants-style +replacements: straight quotes become curly, ``--`` / ``---`` become en / em +dashes, ``...`` becomes an ellipsis, ``(c)`` becomes ©, and so on. Single +line breaks inside paragraphs become ``
`` (``breaks: True``). Code +spans/blocks and raw HTML are left untouched. + Images get special treatment: a relative `src` is resolved against the page's own path (so `![alt](photo.avif)` in `/docs/design` is served from `/docs/design/photo.avif`), and an image with a title becomes a @@ -110,7 +116,15 @@ def _tag_task_checkboxes(state) -> None: md = ( - MarkdownIt("default", {"html": True, "highlight": _highlight}) + MarkdownIt( + "default", + { + "html": True, + "highlight": _highlight, + "typographer": True, + "breaks": True, + }, + ) .use(attrs_plugin) .use(footnote_plugin) .use(deflist_plugin)