mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fixes #65
This commit is contained in:
parent
6d2e5fddae
commit
64d4e16bf4
2 changed files with 24 additions and 1 deletions
|
|
@ -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">↩︎</a></p>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue