Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ At release time the section is retitled to the version and the prose lead is wri

## Unreleased

### Fixed

- A MkDocs admonition written without a blank line after its marker is no longer flattened into one paragraph, which stopped it rendering as a callout (#31, contributed by Karl Isenberg).
That spelling is a single paragraph to CommonMark, since the indented body is a lazy continuation rather than the code block the blank-line spelling produces.
The marker line is now immovable and the body carries the 4-space indent the extension requires, the same treatment a footnote definition already gets.

## v0.1.5 (2026-08-09)

Narrower promises, structurally enforced.
Expand Down
12 changes: 12 additions & 0 deletions internal/blockmap/blockmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,18 @@ func build(p ast.Node, source []byte, inBlockquote bool, fmEnd int, precededByTa
// nesting), not a replacement for it.
contPrefix += " "
}
if admonitionMarkerRE.MatchString(trimmed[0]) {
// A MkDocs admonition written without a blank line after its
// marker is one paragraph here: the indented body is a lazy
// continuation, not the code block the blank-line spelling
// produces. Joining the marker into the body destroys the
// callout, and so does dropping the body's indent, so the marker
// line is immovable and the body carries the 4-space indent the
// extension requires. Same treatment as the footnote definition
// above, for the same reason.
boundary[0] = true
contPrefix += " "
}

return Paragraph{
Node: p,
Expand Down
21 changes: 21 additions & 0 deletions internal/blockmap/blockmap_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,27 @@ func TestBacktickInBareURLNeedsURLFirst(t *testing.T) {
}
}

// A MkDocs admonition written without a blank line after its marker is a
// single paragraph: the indented body is a lazy continuation. Reflowing it
// as ordinary prose joins the marker into the body and drops the indent,
// and the callout stops being one.
func TestLazyAdmonitionKeepsItsShape(t *testing.T) {
const src = "!!! tip \"Title here\"\n The recommended shape is the v2 API at\n a decomposed resource. Second sentence here.\n"
b := []byte(src)
doc := gm.New().Parser().Parse(text.NewReader(b))
paras := Paragraphs(doc, b)
if len(paras) != 1 {
t.Fatalf("got %d paragraphs, want 1", len(paras))
}
p := paras[0]
if !p.Boundary[0] {
t.Error("marker line is not a boundary, so reflow may join it into the body")
}
if p.ContPrefix != " " {
t.Errorf("ContPrefix = %q, want the 4-space body indent", p.ContPrefix)
}
}

func TestParenGuardNarrowing(t *testing.T) {
cases := []struct {
name string
Expand Down