Commit bae0cfa
committed
Fix duplicate link-ref transformer in newParserInternal
Copilot review caught a real bug: goldmark.New() calls DefaultParser()
which already installs DefaultParagraphTransformers(), so the previous
goldmark.WithParserOptions(parser.WithParagraphTransformers(defaults...))
call appended a second link-reference transformer on top. The reset
closure only touched the appended instance; the one inside the default
parser kept pinning the last parsed document's bytes.
Build the parser explicitly with parser.NewParser (one set of block,
inline, and paragraph parsers including the lrp captured for reset)
and install it via goldmark.WithParser, then let goldmark.New's
extension Extend hooks register the additional block / inline parsers
they need. After this change there is exactly one link-ref transformer
in the resulting parser, and the closure returned to NewPooledParser
callers resets that instance.
https://claude.ai/code/session_0144ZKUS2Zrg7xBft54qyoti1 parent 98e117e commit bae0cfa
1 file changed
Lines changed: 21 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| |||
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
111 | 112 | | |
112 | | - | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
115 | 125 | | |
116 | | - | |
| 126 | + | |
117 | 127 | | |
0 commit comments