yuin / goldmark

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

Pipe character inside code span can terminate table #194

Closed jdkato closed 3 years ago

jdkato commented 3 years ago

Using goldmark.WithExtensions(extension.GFM) with the following Markdown snippet

| Table | Table |
|-------|-------|
| Word  | `Notword|` |

results in

<table>
   <thead>
      <tr>
         <th>Table</th>
         <th>Table</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Word</td>
         <td>`Notword</td>
      </tr>
   </tbody>
</table>

I think the expected result here should be

<table>
   <thead>
      <tr>
         <th>Table</th>
         <th>Table</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Word</td>
         <td><code>Notword|</code></td>
      </tr>
   </tbody>
</table>

I'm using Go go1.15.7 darwin/amd64 and Goldmark v1.3.2.

Thanks for your work on this library.


As an aside, since this isn't a topic covered in the CommonMark spec, I've included a comparison with other libraries and there doesn't seem to be a strong consensus: e.g., MD4C (another CommonMark-compliant parser) has what I'd consider to be the "expected" output, while cmark-gfm (GitHub's library) doesn't.

yuin commented 3 years ago

This works as expected. CommonMark does not contain tables. As README says tables are defined in Github Flavored Markdown(GFM). GFM defines pipe characters in code span must be escaped if you want to render it in code spans. https://github.github.com/gfm/#example-200