fix: smolnet drops a callout marker that has no label

A `> [!kind]` with no title and an empty default label now loses the
marker line entirely, leaving a plain blockquote, instead of printing
an empty bold label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
randogoth 2026-10-22 11:29:03 +03:00
parent b6418b090f
commit cf29dd7174

View file

@ -123,7 +123,9 @@ FOOTNOTE_REF = re.compile(r"\[\^([^\]]+)\]")
LINKREF_DEF = re.compile(r"^\[(\d+)\]:", re.MULTILINE)
# The opening line of a GitHub/Obsidian-style callout, "> [!kind] title".
CALLOUT = re.compile(r"^([ ]{0,3}>[ ]?)\[!(\w+)\][ \t]*(.*)$", re.MULTILINE)
# The trailing newline is part of the match, so a marker with no label can be
# dropped whole instead of leaving the quote to open on a blank line.
CALLOUT = re.compile(r"^([ ]{0,3}>[ ]?)\[!(\w+)\][ \t]*(.*)\n?", re.MULTILINE)
def rot13(text):
@ -334,7 +336,7 @@ def rewrite_callouts(text, kinds):
The HTML build renders these as boxes (an <aside>, via a Markdown
extension in the site itself). gemtext has nothing to draw a box with, and
a quote is the one block it does set apart, so the passage stays one; only
the marker would otherwise print literally as "[!ontology]". Kinds not in
the marker would otherwise print literally as "[!aside]". Kinds not in
`kinds` are left alone, matching the HTML side, which also only boxes the
kinds it was told about.
"""
@ -347,9 +349,12 @@ def rewrite_callouts(text, kinds):
if kind not in kinds:
return match.group(0)
title = match.group(3).strip() or kinds[kind]
if not title:
# No label: the marker line goes, the quote stays.
return ""
# The label as a paragraph of its own inside the quote, so it can't run
# into the passage's first sentence.
return "%s**%s**\n>" % (match.group(1), title)
return "%s**%s**\n>\n" % (match.group(1), title)
return CALLOUT.sub(sub, text)