Skip to content

Commit 5d8fca0

Browse files
committed
Replace hand-rolled MarkdownToHTML with goldmark
Replace the ~350-line regex pipeline (convertInline, placeholder extraction/restoration, line-by-line parser) with goldmark configured for Trix editor compatibility via three custom components: - trixTransformer: forces tight lists, converts soft breaks to hard inside list items and blockquotes, inserts <br> between blank-line-separated blocks for Trix paragraph spacing - trixRenderer: compact blockquote output, HTML escaping for raw HTML blocks (vs <!-- raw HTML omitted -->), TrixBreak and EscapedAt node rendering - escapedAtParser: intercepts \@ before goldmark's standard escape handling to preserve mention-suppression syntax HTMLToMarkdown gains <br>-aware round-trip support: blockquote and list handlers now normalize <br> tags before splitting, so multiline blockquotes and list continuations survive the edit loop (MarkdownToHTML → HTMLToMarkdown) faithfully. Also fixes multiline blockquote/paragraph regex matching ((?i) → (?is)) and trims trailing newlines from code fence content. Promotes goldmark from indirect to direct dependency (v1.7.13, already present via glamour).
1 parent 4c6860b commit 5d8fca0

3 files changed

Lines changed: 755 additions & 477 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
github.com/spf13/cobra v1.10.2
2020
github.com/spf13/pflag v1.0.10
2121
github.com/stretchr/testify v1.11.1
22+
github.com/yuin/goldmark v1.7.13
2223
github.com/zalando/go-keyring v0.2.8
2324
golang.org/x/mod v0.34.0
2425
golang.org/x/sys v0.42.0
@@ -70,7 +71,6 @@ require (
7071
github.com/rivo/uniseg v0.4.7 // indirect
7172
github.com/rogpeppe/go-internal v1.14.1 // indirect
7273
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
73-
github.com/yuin/goldmark v1.7.13 // indirect
7474
github.com/yuin/goldmark-emoji v1.0.6 // indirect
7575
golang.org/x/net v0.38.0 // indirect
7676
golang.org/x/sync v0.20.0 // indirect

0 commit comments

Comments
 (0)