use super::*;
#[test]
fn footnotes() {
html_opts!(
[extension.footnotes],
concat!(
"Here is a[^nowhere] footnote reference,[^1] and another.[^longnote]\n",
"\n",
"This is another note.[^note] And footnote[^longnote] is referenced again.\n",
"\n",
"[^note]: Hi.\n",
"\n",
"[^1]: Here is the footnote.\n",
"\n",
"[^longnote]: Here's one with multiple blocks.\n",
"\n",
" Subsequent paragraphs are indented.\n",
"\n",
" code\n",
"\n",
"This is regular content.\n",
"\n",
"[^unused]: This is not used.\n"
),
concat!(
"
Here is a[^nowhere] footnote reference, and another.
\n",
"This is another note. And footnote is referenced again.
\n",
"This is regular content.
\n",
"\n"
),
);
}
#[test]
fn footnote_does_not_eat_exclamation() {
html_opts!(
[extension.footnotes],
concat!("Here's my footnote![^a]\n", "\n", "[^a]: Yep.\n"),
concat!(
"Here's my footnote!
\n",
"\n"
),
);
}
#[test]
fn footnote_in_table() {
html_opts!(
[extension.table, extension.footnotes],
concat!(
"A footnote in a paragraph[^1]\n",
"\n",
"| Column1 | Column2 |\n",
"| --------- | ------- |\n",
"| foot [^1] | note |\n",
"\n",
"[^1]: a footnote\n",
),
concat!(
"A footnote in a paragraph
\n",
"\n",
"\n",
"\n",
"| Column1 | \n",
"Column2 | \n",
"
\n",
"\n",
"\n",
"\n",
"| foot | \n",
"note | \n",
"
\n",
"\n",
"
\n",
"\n",
)
);
}
#[test]
fn footnote_with_superscript() {
html_opts!(
[extension.superscript, extension.footnotes],
concat!(
"Here is a footnote reference.[^1]\n",
"\n",
"Here is a longer footnote reference.[^ref]\n",
"\n",
"e = mc^2^.\n",
"\n",
"[^1]: Here is the footnote.\n",
"[^ref]: Here is another footnote.\n",
),
concat!(
"Here is a footnote reference.
\n",
"Here is a longer footnote reference.
\n",
"e = mc2.
\n",
"\n"
),
);
}
#[test]
fn footnote_escapes_name() {
html_opts!(
[extension.footnotes],
concat!(
"Here is a footnote reference.[^😄ref]\n",
"\n",
"[^😄ref]: Here is the footnote.\n",
),
concat!(
"Here is a footnote reference.
\n",
"\n"
),
);
}
#[test]
fn footnote_case_insensitive_and_case_preserving() {
html_opts!(
[extension.footnotes],
concat!(
"Here is a footnote reference.[^AB] and [^ab]\n",
"\n",
"[^aB]: Here is the footnote.\n",
),
concat!(
"Here is a footnote reference. and
\n",
"\n"
),
);
}
#[test]
fn footnote_name_parsed_into_multiple_nodes() {
html_opts!(
[extension.footnotes],
concat!("Foo.[^_ab]\n", "\n", "[^_ab]: Here is the footnote.\n",),
concat!(
"Foo.
\n",
"\n"
),
);
}
#[test]
fn footnote_invalid_with_missing_name() {
html_opts!(
[extension.footnotes],
"Foo.[^]\n\n[^]: Here is the footnote.\n",
"Foo.[^]
\n[^]: Here is the footnote.
\n"
);
}
#[test]
fn footnote_does_not_allow_spaces_in_name() {
html_opts!(
[extension.footnotes],
"Foo.[^one two]\n\n[^one two]: Here is the footnote.\n",
"Foo.[^one two]
\n[^one two]: Here is the footnote.
\n"
);
}
#[test]
fn footnote_does_not_expand_emphasis_in_name() {
html_opts!(
[extension.footnotes],
"Foo[^**one**]\n[^**one**]: bar\n",
concat!(
"Foo
\n",
"\n"
),
);
}
#[test]
fn sourcepos() {
assert_ast_match!(
[extension.footnotes],
"Here is a footnote reference.[^1]\n"
"\n"
"[^1]: Here is the footnote.\n"
"\n"
"Here is a longer footnote reference.[^ref]\n"
"\n"
"[^ref]: Here is another footnote.\n",
(document (1:1-7:33) [
(paragraph (1:1-1:33) [
(text (1:1-1:29) "Here is a footnote reference.")
(footnote_reference (1:30-1:33))
])
(paragraph (5:1-5:42) [
(text (5:1-5:36) "Here is a longer footnote reference.")
(footnote_reference (5:37-5:42))
])
(footnote_definition (3:1-3:27) [
(paragraph (3:7-3:27) [
(text (3:7-3:27) "Here is the footnote.")
])
])
(footnote_definition (7:1-7:33) [
(paragraph (7:9-7:33) [
(text (7:9-7:33) "Here is another footnote.")
])
])
])
);
}
#[test]
fn leave_footnote_definitions() {
assert_ast_match!(
[extension.footnotes, parse.leave_footnote_definitions],
"Here is a footnote reference.[^1]\n"
"\n"
"[^1]: Here is the footnote.\n"
"\n"
"Here is a longer footnote reference.[^ref]\n"
"\n"
"[^ref]: Here is another footnote.\n",
(document (1:1-7:33) [
(paragraph (1:1-1:33) [
(text (1:1-1:29) "Here is a footnote reference.")
(footnote_reference (1:30-1:33))
])
(footnote_definition (3:1-3:27) [
(paragraph (3:7-3:27) [
(text (3:7-3:27) "Here is the footnote.")
])
])
(paragraph (5:1-5:42) [
(text (5:1-5:36) "Here is a longer footnote reference.")
(footnote_reference (5:37-5:42))
])
(footnote_definition (7:1-7:33) [
(paragraph (7:9-7:33) [
(text (7:9-7:33) "Here is another footnote.")
])
])
])
);
}