Skip to content

Instantly share code, notes, and snippets.

@Orc
Last active August 17, 2023 08:38
Show Gist options
  • Save Orc/ad8f34065b72ffebbd0792b1efbf4f02 to your computer and use it in GitHub Desktop.
Save Orc/ad8f34065b72ffebbd0792b1efbf4f02 to your computer and use it in GitHub Desktop.
diff.text
diff --git a/generate.c b/generate.c
index ee6159a..2ffe03f 100644
--- a/generate.c
+++ b/generate.c
@@ -775,26 +775,29 @@ linkylinky(int image, MMIOT *f)
else {
int goodlink, implicit_mark = mmiottell(f);
- if ( isspace(peek(f,1)) )
- pull(f);
-
- if ( peek(f,1) == '[' ) {
- pull(f); /* consume leading '[' */
- goodlink = linkylabel(f, &key.tag);
+ if ( is_flag_set(&f->flags, MKD_EXTRA_FOOTNOTE)
+ && !is_flag_set(&f->flags, MKD_STRICT)
+ && (!image)
+ && S(name)
+ && T(name)[0] == '^' ) {
+ extra_footnote = 1;
+ goodlink = 1;
}
else {
- /* new markdown implicit name syntax doesn't
- * require a second []
- */
- mmiotseek(f, implicit_mark);
- goodlink = !is_flag_set(&f->flags, MKD_1_COMPAT);
-
- if ( is_flag_set(&f->flags, MKD_EXTRA_FOOTNOTE)
- && !is_flag_set(&f->flags, MKD_STRICT)
- && (!image)
- && S(name)
- && T(name)[0] == '^' )
- extra_footnote = 1;
+ if ( isspace(peek(f,1)) )
+ pull(f);
+
+ if ( peek(f,1) == '[' ) {
+ pull(f); /* consume leading '[' */
+ goodlink = linkylabel(f, &key.tag);
+ }
+ else {
+ /* new markdown implicit name syntax doesn't
+ * require a second []
+ */
+ mmiotseek(f, implicit_mark);
+ goodlink = !is_flag_set(&f->flags, MKD_1_COMPAT);
+ }
}
if ( goodlink ) {
diff --git a/tests/extrafootnotes.t b/tests/extrafootnotes.t
index d7a5ed5..8d05913 100644
--- a/tests/extrafootnotes.t
+++ b/tests/extrafootnotes.t
@@ -28,6 +28,20 @@ yes?<a href="#footref:1" rev="footnote">&#8617;</a></li>
</ol>
</div>'
+try -ffootnote 'footnotes(two adjacent footnotes)' 'Hello[^1][^2]
+
+[^1]: world
+[^2]: from Hamburg' '<p>Hello<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup><sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup></p>
+<div class="footnotes">
+<hr/>
+<ol>
+<li id="fn:1">
+world<a href="#fnref:1" rev="footnote">&#8617;</a></li>
+<li id="fn:2">
+from Hamburg<a href="#fnref:2" rev="footnote">&#8617;</a></li>
+</ol>
+</div>'
+
try -fnofootnote 'footnotes (-fnofootnote)' "$FOOTIE" \
'<p>I haz a footnote<a href="yes?">^1</a></p>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment