diff --git a/org/inline.go b/org/inline.go index 53f60d3..21400d0 100644 --- a/org/inline.go +++ b/org/inline.go @@ -49,7 +49,7 @@ var videoExtensionRegexp = regexp.MustCompile(`^[.](webm|mp4)$`) var subScriptSuperScriptRegexp = regexp.MustCompile(`^([_^]){([^{}]+?)}`) var timestampRegexp = regexp.MustCompile(`^<(\d{4}-\d{2}-\d{2})( [A-Za-z]+)?( \d{2}:\d{2})?( \+\d+[dwmy])?>`) -var footnoteRegexp = regexp.MustCompile(`^\[fn:([\w-]+?)(:(.*?))?\]`) +var footnoteRegexp = regexp.MustCompile(`^\[fn:([\w-]*?)(:(.*?))?\]`) var statisticsTokenRegexp = regexp.MustCompile(`^\[(\d+/\d+|\d+%)\]`) var timestampFormat = "2006-01-02 Mon 15:04" @@ -168,6 +168,9 @@ func (d *Document) parseOpeningBracket(input string, start int) (int, Node) { func (d *Document) parseFootnoteReference(input string, start int) (int, Node) { if m := footnoteRegexp.FindStringSubmatch(input[start:]); m != nil { name, definition := m[1], m[3] + if name == "" && definition == "" { + return 0, nil + } link := FootnoteLink{name, nil} if definition != "" { link.Definition = &FootnoteDefinition{name, []Node{Paragraph{d.parseInline(definition)}}, true} diff --git a/org/testdata/footnotes.html b/org/testdata/footnotes.html index d71b549..7486773 100644 --- a/org/testdata/footnotes.html +++ b/org/testdata/footnotes.html @@ -27,8 +27,13 @@ inline footnotes are also supported via 3. +
+ +Footnote definitions are not printed where they appear. -Rather, they are gathered and exported at the end of the document in the footnote section. 3 +Rather, they are gathered and exported at the end of the document in the footnote section. 4
-Please note that the footnotes section is not automatically excluded from the export like in emacs. 4 +Please note that the footnotes section is not automatically excluded from the export like in emacs. 5
-this is not part of 4 anymore as there are 2 blank lines in between! +this is not part of 5 anymore as there are 2 blank lines in between!
+the anonymous inline footnote definition +
+so this definition will not be at the end of this section in the exported document. Rather, it will be somewhere down below in the footnotes section.
There's multiple reasons for that. Among others, doing so requires i18n (to recognize the section) and silently diff --git a/org/testdata/footnotes.org b/org/testdata/footnotes.org index ca8fcef..cdb32d1 100644 --- a/org/testdata/footnotes.org +++ b/org/testdata/footnotes.org @@ -2,6 +2,7 @@ - normal footnote reference [fn:1] [fn:6] - further references to the same footnote should not [fn:1] render duplicates in the footnote list - inline footnotes are also supported via [fn:2:the inline footnote definition]. +- anonymous inline footnotes are also supported via [fn::the anonymous inline footnote definition]. - Footnote definitions are not printed where they appear. Rather, they are gathered and exported at the end of the document in the footnote section. [fn:4] diff --git a/org/testdata/footnotes.pretty_org b/org/testdata/footnotes.pretty_org index ca8fcef..cdb32d1 100644 --- a/org/testdata/footnotes.pretty_org +++ b/org/testdata/footnotes.pretty_org @@ -2,6 +2,7 @@ - normal footnote reference [fn:1] [fn:6] - further references to the same footnote should not [fn:1] render duplicates in the footnote list - inline footnotes are also supported via [fn:2:the inline footnote definition]. +- anonymous inline footnotes are also supported via [fn::the anonymous inline footnote definition]. - Footnote definitions are not printed where they appear. Rather, they are gathered and exported at the end of the document in the footnote section. [fn:4]