Skip to content

Commit

Permalink
Fixes #65
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed Dec 18, 2019
1 parent 6d2e5fd commit 64d4e16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions extension/_test/footnote.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,21 @@ This[^3] is[^1] text with footnotes[^2].
</ol>
</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">

This comment has been minimized.

Copy link
@ardianta

ardianta Jan 17, 2020

Hi @yuin, What if this footnotes using <div>. Because I got warning from W3 Validator by this (<section>) tag.

Selection_203

<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>
//= = = = = = = = = = = = = = = = = = = = = = = =//
7 changes: 6 additions & 1 deletion extension/footnote.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ func NewFootnoteParser() parser.InlineParser {
}

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 {
line, segment := block.PeekLine()
pos := 1
if len(line) > 0 && line[0] == '!' {
pos++
}
if pos >= len(line) || line[pos] != '^' {
return nil
}
Expand Down

0 comments on commit 64d4e16

Please sign in to comment.