Open cactysman opened 5 months ago
I also confirmed that it's not goldmark's fault with the following code (using a simple goldmark setup that should probably suffice) producing identical results no matter where the refs are placed.
package main
import (
"bytes"
"fmt"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
)
func main() {
md := goldmark.New(
goldmark.WithExtensions(
extension.GFM,
extension.DefinitionList,
),
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
)
var bufA bytes.Buffer
var bufB bytes.Buffer
sourceA := []byte("[a]: https://example.com\n\n# hi\n\n[link][a]")
sourceB := []byte("# hi\n\n[link][a]\n\n[a]: https://example.com")
if err := md.Convert(sourceA, &bufA); err != nil {
panic(err)
}
fmt.Println("START1" + bufA.String() + "END1\n")
if err := md.Convert(sourceB, &bufB); err != nil {
panic(err)
}
fmt.Println("START2" + bufB.String() + "END2")
}
START1<h1 id="hi">hi</h1>
<p><a href="https://example.com">link</a></p>
END1
START2<h1 id="hi">hi</h1>
<p><a href="https://example.com">link</a></p>
END2
Reference-style links placed on top of the document add a leading line break to the document.
Setup
To Reproduce
Source Code
Expected behavior The actual output of the markdown document should probably be trimmed, or at least not include that extra line break on top.
Screenshots