NoteDiscovery/backend
pablon 465daa0f78
fix(callouts): render nested code blocks inside GFM/GLFM alerts
The callout preprocessor ran AFTER the fenced-code extraction pass, so
a code block nested inside a callout blockquote (each line prefixed
with `> `) was captured whole \u2014 including the leading `> ` on the
closing fence. When the placeholder was later restored inside the raw
`<div class="callout-body">`, the closing line `> \`\`\`` no longer sat
at 0-3 leading spaces, so CommonMark did not recognize it as a fence
closer. marked.js ran the block unclosed, swallowed the callout's
`</div></div>` and every downstream node, and the render leaked as raw
blockquote text.

Reorder the pipeline so callouts are converted BEFORE code-block
extraction. The scan is fence-aware (backticks and tildes) so a
literal `> [!TYPE]\' inside a top-level code block is not misread as a
callout. Mirrored in backend/export.py so the standalone export matches
the in-app preview.

Verified end-to-end against a 12-case matrix covering GFM (github.com)
and GLFM (gitlab.com) alert syntax: nested backtick fence (bug),
nested tilde fence, all 5 types in UPPERCASE, GitLab lowercase with
custom title, empty callout, plain blockquote passthrough, literal
`[!TIP]` inside top-level backtick and tilde fences (regression),
rich body markdown, paragraph separators, adjacent callouts, and
nested-alert attempts (GFM disallows nesting).

Signed-off-by: pablon <73798198+pablon@users.noreply.github.com>
2026-07-09 15:17:35 +02:00
..
__init__.py Initial commit 2025-11-05 17:48:41 +01:00
export.py fix(callouts): render nested code blocks inside GFM/GLFM alerts 2026-07-09 15:17:35 +02:00
main.py invalidate cache on media operations 2026-06-30 17:44:05 +02:00
note_index.py simplify rebuilt message 2026-06-30 17:24:00 +02:00
plugins.py better app logs 2026-06-30 16:13:01 +02:00
share.py use logger 2026-06-30 16:32:41 +02:00
themes.py use logger 2026-06-30 16:32:41 +02:00
utils.py invalidate cache on media operations 2026-06-30 17:44:05 +02:00