From 64d4e16bf4548242453a87665afd78954f1aae3e Mon Sep 17 00:00:00 2001 From: yuin Date: Wed, 18 Dec 2019 11:37:07 +0900 Subject: [PATCH] Fixes #65 --- extension/_test/footnote.txt | 18 ++++++++++++++++++ extension/footnote.go | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/extension/_test/footnote.txt b/extension/_test/footnote.txt index 34cb5c0..9b06721 100644 --- a/extension/_test/footnote.txt +++ b/extension/_test/footnote.txt @@ -48,3 +48,21 @@ This[^3] is[^1] text with footnotes[^2]. //= = = = = = = = = = = = = = = = = = = = = = = =// + + +5 +//- - - - - - - - -// +test![^1] + +[^1]: footnote +//- - - - - - - - -// +

test1

+
+
+
    +
  1. +

    footnote ↩︎

    +
  2. +
+
+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/extension/footnote.go b/extension/footnote.go index 592d7f4..ede72db 100644 --- a/extension/footnote.go +++ b/extension/footnote.go @@ -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 }