Disable code line numbers by default; add page-level opt-in#236
Merged
Disable code line numbers by default; add page-level opt-in#236
Conversation
Closes #208. Line numbers now appear only on posts that set `code-line-numbers: true` in frontmatter — matches the Quarto authoring pattern people already know. Mechanism: - hugo.toml: flip `[markup.highlight] lineNos` to false - render-codeblock hook: when the page sets `code-line-numbers`, merge `linenos: true` into chroma options for every block on that page Style refresh for line-numbered blocks: - color → `--color-gray-500` (8.79:1 contrast on blue-100, AAA) - white 1px separator between gutter and code - horizontal padding moved off `<table>` (Tailwind preflight forces border-collapse:collapse, which makes table padding a no-op) and onto the cell `<pre>` elements where it actually renders Opted in two posts that need numbering for prose references: - shinychat-tool-ui (per-cell `#| code-line-numbers` in source got stripped by Quarto's GFM renderer; page-level brings it back — line-range highlights like "7-10" remain unrendered) - latex-output-tables (also switched `format: html` → `format: hugo-md` and tightened YAML strictness for `code-fold`)
✅ Deploy Preview for posit-open-source canceled.
|
Publishing checklist
|
Add the new `code-line-numbers` toggle to the authoring guide (under .qmd content reference, alongside code-folding) and the metadata schema in CLAUDE.md.
Blog YAML Checks
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #208.
Summary
code-line-numbers: truein frontmatter — same key Quarto authors already use.layouts/_default/_markup/render-codeblock.html) reads the page param and forceslinenos=trueinto chroma options when set..lntablepadding was a no-op because Tailwind preflight forcesborder-collapse: collapse, which kills<table>padding — moved onto the cell<pre>elements).shinychat-tool-uiandlatex-output-tables.Caveats
code-line-numbers(document, per-cell, and per-block forms) when rendering to GFM, so page-level opt-in is currently the only honored form. Per-cell line-range highlights like"7-10"inshinychat-tool-uiremain unrendered — they were already unrendered in production before this PR.latex-output-tablesgot an incidental fix:format: html→format: hugo-md(the post was outputting HTML even though the project default is hugo-md, an artifact of the original port) andcode-fold: yes→code-fold: truefor Quarto's strict YAML. The re-rendered.mdincludes a code-fold details wrapper around the first Python block as a result.Test plan
/blog/2026-04-23_mori-0-1-0/)/blog/2025-11-20_shinychat-tool-ui/and/blog/2024-11-13_latex-output-tables/