This commit is contained in:
yuin 2019-12-18 11:37:07 +09:00
parent 6d2e5fddae
commit 64d4e16bf4
2 changed files with 24 additions and 1 deletions

View file

@ -48,3 +48,21 @@ This[^3] is[^1] text with footnotes[^2].
</ol> </ol>
</section> </section>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
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>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -114,12 +114,17 @@ func NewFootnoteParser() parser.InlineParser {
} }
func (s *footnoteParser) Trigger() []byte { func (s *footnoteParser) Trigger() []byte {
return []byte{'['} // footnote syntax probably conflict with the image syntax.
// So we need trigger this parser with '!'.
return []byte{'!', '['}
} }
func (s *footnoteParser) Parse(parent gast.Node, block text.Reader, pc parser.Context) gast.Node { func (s *footnoteParser) Parse(parent gast.Node, block text.Reader, pc parser.Context) gast.Node {
line, segment := block.PeekLine() line, segment := block.PeekLine()
pos := 1 pos := 1
if len(line) > 0 && line[0] == '!' {
pos++
}
if pos >= len(line) || line[pos] != '^' { if pos >= len(line) || line[pos] != '^' {
return nil return nil
} }