-
goldmark has https://github.com/yuin/goldmark/discussions in github.
Please answer the following before submitting your issue:
package main
import (
"fmt"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/text"
)
var source = `
**2. Click "Rankings Distribution"
Click "Landscape"
Click "SEO Dashboard
COMPETITIVE RESEARCH
Domain Overview
Traffic Analytics
Organic Research
Keyword Gap
Backlink Gap
KEYWORD RESEARCH
Keyword Overview..."**
`
func main() {
doc := goldmark.DefaultParser().Parse(text.NewReader([]byte(source)))
ast.Walk(doc, func(n ast.Node, entering bool) (ast.WalkStatus, error) {
s := ast.WalkStatus(ast.WalkContinue)
var err error
fmt.Println(n.Kind(), entering, string(n.Text([]byte(source))))
return s, err
})
} Outputs
It should add the softbreak between lines print like this according to https://spec.commonmark.org/dingus/ <text>2. Click </text>
<text>"</text>
<text>Rankings Distribution</text>
<text>"</text>
<softbreak />
<text>Click </text>
<text>"</text>
<text>Landscape</text>
<text>"</text>
<softbreak />
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Spec is defined only for HTML outputs |
Beta Was this translation helpful? Give feedback.
-
I do not understand you can see there is softbreak node the package does NOT provides. Then how do i detect the line breaks ?? |
Beta Was this translation helpful? Give feedback.
-
@yuin can you let me know how i detect line breaks it's very critical to my use case. Thanks |
Beta Was this translation helpful? Give feedback.
-
@yuin any update on the issue ? |
Beta Was this translation helpful? Give feedback.
-
@khanakia Match on the if t, ok := n.(*ast.Text); ok {
if t.SoftLineBreak() {
fmt.Println("ends with softbreak")
}
} |
Beta Was this translation helpful? Give feedback.
@khanakia Match on the
*ast.Text
node and check the Text.SoftLineBreak method to see if a text ends with a soft break. There's no separate soft break node in the Goldmark AST.