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

Footnote references drop preceding exclamation point character #176

Closed 13rac1 closed 3 years ago

13rac1 commented 3 years ago

Summary

The fix in #65 enables Goldmark to handle references preceded by an exclamation point, but drops the character itself. This test: https://github.com/yuin/goldmark/blob/9e0189df270cb443c204b51e89e2b0749b98370c/extension/_test/footnote.txt#L53-L68

Should be:

5
//- - - - - - - - -//
test![^1]

[^1]: footnote
//- - - - - - - - -//
<p>test!<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1" role="doc-endnote">
<p>footnote <a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>
//= = = = = = = = = = = = = = = = = = = = = = = =//

Questions

  1. What version of goldmark are you using? :

HEAD

  1. What version of Go are you using? :

1.15.6

  1. What operating system and processor architecture are you using? :

Ubuntu 20.04 on AMD64

  1. What did you do? :
  1. Enabled the footnote extension.
  2. test![^1]
  1. What did you expect to see? :
<p>test!<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
  1. What did you see instead? :
<p>test<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
  1. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?:

Not needed.

13rac1 commented 3 years ago

Thanks! I wasn't sure of the best implementation, this works for me