Markdown: highlight nested blocks on their own

Every block now maps to its own source lines at any depth: quotes inside
quotes, paragraphs, code, quotes and lists inside list items, and each
table row. A list item's highlight covers only its own text, not its
nested items, and a parent quote is not highlighted with its children.
A Parser subclass marks each block in the rendered HTML; the output is
otherwise identical to render().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-17 03:01:21 -08:00
parent c652ca456b
commit 12990a9c5d
2 changed files with 94 additions and 30 deletions

View file

@ -192,6 +192,9 @@ textarea { tab-size: 4; }
/* the block being edited, in the preview */
.md-preview [data-md-unit] { border-radius: 4px; transition: background-color 0.6s, box-shadow 0.6s; }
.md-preview .md-active { background-color: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); transition: none; }
.md-preview tr[data-md-unit] > * { transition: background-color 0.6s; }
.md-preview tr.md-active { box-shadow: none; }
.md-preview tr.md-active > * { background-color: var(--accent-soft); transition: none; }
.md-workspace[data-mode='split'] .md-preview [data-md-unit] { cursor: text; }
.md-workspace[data-mode='split'] .md-preview :is(a, input, summary) { cursor: pointer; }
.md-workspace[data-mode='edit'] .md-input { max-width: 900px; margin: 0 auto; }
@ -207,8 +210,8 @@ textarea { tab-size: 4; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.6em; }
.prose li + li { margin-top: 0.25em; }
.prose li > input[type='checkbox'] { margin: 0 0.4em 0 -1.3em; vertical-align: middle; }
.prose li:has(> input[type='checkbox']) { list-style: none; }
.prose li > input[type='checkbox'], .prose .md-li-own > input[type='checkbox'] { margin: 0 0.4em 0 -1.3em; vertical-align: middle; }
.prose li:has(> input[type='checkbox'], > .md-li-own > input[type='checkbox']) { list-style: none; }
.prose code { padding: 0.15em 0.35em; border-radius: 4px; background: var(--code-bg); font: 0.88em var(--mono); }
.prose pre { padding: 12px 14px; border-radius: var(--radius); background: var(--code-bg); overflow: auto; }
.prose pre code { padding: 0; background: none; font-size: 13px; }