();
+ let (def_id, ref_id) = definitions.add_ref(&label)?;
+
+ let length = label.len() + 3; // 3 for '[^' and ']'
+
+ // return new node and length of this structure
+ Some((
+ Node::new(FootnoteReference {
+ label: Some(label),
+ ref_id,
+ def_id,
+ }),
+ length,
+ ))
+ }
+}
diff --git a/crates/lib/md-footnote/tests/fixtures.rs b/crates/lib/md-footnote/tests/fixtures.rs
new file mode 100644
index 0000000..88c26b1
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures.rs
@@ -0,0 +1,15 @@
+use std::path::PathBuf;
+use testing::fixture;
+
+#[fixture("tests/fixtures/[!_]*.md")]
+fn test_html(file: PathBuf) {
+ let f = md_dev::read_fixture_file(file);
+
+ let parser = &mut markdown_it::MarkdownIt::new();
+ markdown_it::plugins::sourcepos::add(parser);
+ markdown_it::plugins::cmark::add(parser);
+ md_footnote::add(parser);
+ let actual = parser.parse(&f.input).render();
+
+ md_dev::assert_no_diff(f, &actual);
+}
diff --git a/crates/lib/md-footnote/tests/fixtures/0.md b/crates/lib/md-footnote/tests/fixtures/0.md
new file mode 100644
index 0000000..629ec61
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/0.md
@@ -0,0 +1,31 @@
+Basic test
+
+......
+
+[^a]
+[^a]
+
+[^a]: Multi
+line
+
+ Multi-paragraph
+
+[^a]: duplicate
+
+normal paragraph
+
+......
+
+
+
+normal paragraph
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/1.md b/crates/lib/md-footnote/tests/fixtures/1.md
new file mode 100644
index 0000000..2f6de52
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/1.md
@@ -0,0 +1,45 @@
+Pandoc example
+
+......
+
+Here is a footnote reference,[^1] and another.[^longnote]
+
+[^1]: Here is the footnote.
+
+[^longnote]: Here's one with multiple blocks.
+
+ Subsequent paragraphs are indented to show that they
+belong to the previous footnote.
+
+ { some.code }
+
+ The whole paragraph can be indented, or just the first
+ line. In this way, multi-paragraph footnotes work like
+ multi-paragraph list items.
+
+This paragraph won't be part of the note, because it
+isn't indented.
+
+......
+
+Here is a footnote reference, and another.
+This paragraph won't be part of the note, because it
+isn't indented.
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/10.md b/crates/lib/md-footnote/tests/fixtures/10.md
new file mode 100644
index 0000000..63d22bf
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/10.md
@@ -0,0 +1,19 @@
+Newline after footnote identifier
+
+......
+
+[^a]
+
+[^a]:
+b
+
+......
+
+
+b
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/2.md b/crates/lib/md-footnote/tests/fixtures/2.md
new file mode 100644
index 0000000..824fcb5
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/2.md
@@ -0,0 +1,27 @@
+They could terminate each other
+
+......
+
+[^1][^2][^3]
+
+[^1]: foo
+[^2]: bar
+[^3]: baz
+
+......
+
+
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/3.md b/crates/lib/md-footnote/tests/fixtures/3.md
new file mode 100644
index 0000000..caee05b
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/3.md
@@ -0,0 +1,23 @@
+They could be inside blockquotes, and are lazy
+
+......
+
+[^foo]
+
+> [^foo]: bar
+baz
+
+......
+
+
+
+
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/4.md b/crates/lib/md-footnote/tests/fixtures/4.md
new file mode 100644
index 0000000..1573c00
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/4.md
@@ -0,0 +1,14 @@
+Their labels could not contain spaces or newlines
+
+......
+
+[^ foo]: bar baz
+
+[^foo
+]: bar baz
+
+......
+
+[^ foo]: bar baz
+[^foo
+]: bar baz
diff --git a/crates/lib/md-footnote/tests/fixtures/5.md b/crates/lib/md-footnote/tests/fixtures/5.md
new file mode 100644
index 0000000..6c58dcd
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/5.md
@@ -0,0 +1,19 @@
+Duplicate footnotes:
+
+......
+
+[^xxxxx] [^xxxxx]
+
+[^xxxxx]: foo
+
+......
+
+
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/6.md b/crates/lib/md-footnote/tests/fixtures/6.md
new file mode 100644
index 0000000..a5c78db
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/6.md
@@ -0,0 +1,28 @@
+Indents
+
+
+......
+
+[^xxxxx] [^yyyyy]
+
+[^xxxxx]: foo
+ ---
+
+[^yyyyy]: foo
+ ---
+
+......
+
+
+
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/8.md b/crates/lib/md-footnote/tests/fixtures/8.md
new file mode 100644
index 0000000..2688187
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/8.md
@@ -0,0 +1,19 @@
+Indents for the first line (tabs)
+
+......
+
+[^xxxxx]
+
+[^xxxxx]: foo
+
+......
+
+
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/9.md b/crates/lib/md-footnote/tests/fixtures/9.md
new file mode 100644
index 0000000..ef8ce62
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/9.md
@@ -0,0 +1,37 @@
+Nested blocks
+
+......
+
+[^a]
+
+[^a]: abc
+
+ def
+hij
+
+ - list
+
+ > block
+
+terminates here
+
+......
+
+
+terminates here
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/_7.md b/crates/lib/md-footnote/tests/fixtures/_7.md
new file mode 100644
index 0000000..687ab55
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/_7.md
@@ -0,0 +1,24 @@
+Indents for the first line
+.............
+
+[^xxxxx] [^yyyyy]
+
+[^xxxxx]: foo
+
+[^yyyyy]: foo
+
+.............
+
+
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/inline-1.md b/crates/lib/md-footnote/tests/fixtures/inline-1.md
new file mode 100644
index 0000000..cabe0c7
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/inline-1.md
@@ -0,0 +1,21 @@
+We support inline notes too (pandoc example)
+
+......
+
+Here is an inline note.^[Inlines notes are easier to write, since
+you don't have to pick an identifier and move down to type the
+note.]
+
+......
+
+Here is an inline note.
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/inline-2.md b/crates/lib/md-footnote/tests/fixtures/inline-2.md
new file mode 100644
index 0000000..262485b
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/inline-2.md
@@ -0,0 +1,17 @@
+Inline footnotes can have arbitrary markup
+
+......
+
+foo^[ *bar* ]
+
+......
+
+foo
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/inline-3.md b/crates/lib/md-footnote/tests/fixtures/inline-3.md
new file mode 100644
index 0000000..052fbfb
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/inline-3.md
@@ -0,0 +1,19 @@
+Should allow links in inline footnotes
+
+......
+
+Example^[this is another example [a]]
+
+[a]: https://github.com
+
+......
+
+Example
+
+
diff --git a/crates/lib/md-footnote/tests/fixtures/inline-4.md b/crates/lib/md-footnote/tests/fixtures/inline-4.md
new file mode 100644
index 0000000..5d03d91
--- /dev/null
+++ b/crates/lib/md-footnote/tests/fixtures/inline-4.md
@@ -0,0 +1,19 @@
+nested inline footnotes
+
+......
+
+[Example^[this is another example [a]]][a]
+
+[a]: https://github.com
+
+......
+
+Example
+
+