yuin / goldmark

:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
MIT License
3.73k stars 257 forks source link

Parser prints strong as emphasis #392

Closed khanakia closed 1 year ago

khanakia commented 1 year ago

goldmark has https://github.com/yuin/goldmark/discussions in github. You should post only issues here. Feature requests and questions should be posted at discussions.

Please answer the following before submitting your issue:

  1. What version of goldmark are you using? : 1.5.4
  2. What version of Go are you using? : 1.20.1
  3. What operating system and processor architecture are you using? : Mac
  4. What did you do? : ran the below code
  5. What did you expect to see? : it should print strong
  6. What did you see instead? : it printed emphasis
  7. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?: yes
var source = `
**This is text**
`
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())
        return s, err
    })
}

Outputs

Document
Paragraph
Emphasis
Text
Text
Emphasis
Paragraph
Document

It should print like this according to https://spec.commonmark.org/dingus/

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">

<document xmlns="http://commonmark.org/xml/1.0">
  <paragraph>
    <strong>
      <text>This is text</text>
    </strong>
  </paragraph>
</document>

It print emphasis instead of strong

yuin commented 1 year ago

Spec is definied only for HTML outputs

khanakia commented 1 year ago

What do you mean by "Spec is definied only for HTML outputs" ?