use super::*;
#[test]
fn basic_inline_footnote() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Here is an inline footnote^[This is the footnote content].\n",
concat!(
"
Here is an inline footnote.
\n",
"\n"
),
);
}
#[test]
fn inline_footnote_with_emphasis() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^[With *emphasis* and **strong**].\n",
concat!(
"Text.
\n",
"\n"
),
);
}
#[test]
fn inline_footnote_with_link() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^[See [example](https://example.com)].\n",
concat!(
"Text.
\n",
"\n"
),
);
}
#[test]
fn multiple_inline_footnotes() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"First^[First note] and second^[Second note].\n",
concat!(
"First ",
"and second.
\n",
"\n"
),
);
}
#[test]
fn mixed_inline_and_regular_footnotes() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
concat!(
"Regular[^1] and inline^[Inline note] and another regular[^2].\n",
"\n",
"[^1]: First regular footnote.\n",
"[^2]: Second regular footnote.\n"
),
concat!(
"Regular ",
"and inline ",
"and another regular.
\n",
"\n"
),
);
}
#[test]
fn empty_inline_footnote_not_parsed() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^[] should not parse.\n",
"Text^[] should not parse.
\n",
);
}
#[test]
fn whitespace_only_inline_footnote_not_parsed() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^[\t\r]more.\n",
"Text^[\n]more.
\n",
);
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^[ ]more.\n",
"Text^[ ]more.
\n",
);
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^[\t\n]more.\n",
"Text^[\n]more.
\n",
);
}
#[test]
fn inline_footnote_without_footnotes_enabled() {
html_opts!(
[extension.inline_footnotes],
"Text^[note] should not parse.\n",
"Text^[note] should not parse.
\n",
);
}
#[test]
fn inline_footnote_with_code() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^[With `code` inline].\n",
concat!(
"Text.
\n",
"\n"
),
);
}
#[test]
fn inline_footnote_multiline() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
concat!(
"Here is an inline note.^[Inline notes are easier to write, since\n",
"you don't have to pick an identifier and move down to type the\n",
"note.]\n"
),
concat!(
"Here is an inline note.
\n",
"\n"
),
);
}
#[test]
fn escaped_caret_not_parsed() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
r"Escaped: \^[not a note]. Real: ^[yes].
",
concat!(
"Escaped: ^[not a note]. Real: .
\n",
"\n"
),
);
}
#[test]
fn whitespace_between_caret_and_bracket() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"Text^ [not a note].\n",
"Text^ [not a note].
\n",
);
}
#[test]
fn escaped_bracket_inside_body() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
r"A ^[square bracket \] inside].
",
concat!(
"A .
\n",
"\n"
),
);
}
#[test]
fn caret_in_other_contexts() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"2^32 is big. ^[note].\n",
concat!(
"2^32 is big. .
\n",
"\n"
),
);
}
#[test]
fn inline_code_protects_marker() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"`^[nope]` and yes ^[ok].\n",
concat!(
"^[nope] and yes .
\n",
"\n"
),
);
}
#[test]
fn back_to_back_inline_footnotes() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"A^[one]^[two].\n",
concat!(
"A",
".
\n",
"\n"
),
);
}
#[test]
fn no_surrounding_spaces() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"word^[tight]word\n",
concat!(
"wordword
\n",
"\n"
),
);
}
#[test]
fn at_paragraph_start() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"^[start] begins.\n",
concat!(
" begins.
\n",
"\n"
),
);
}
#[test]
fn at_paragraph_end() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"ends here ^[fin]\n",
concat!(
"ends here
\n",
"\n"
),
);
}
#[test]
fn inside_emphasis() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"*emph ^[note] text*\n",
concat!(
"emph text
\n",
"\n"
),
);
}
#[test]
fn nested_inline_footnote_supported() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"A ^[outer and ^[inner] literal].\n",
concat!(
"A .
\n",
"\n"
),
);
}
#[test]
fn with_image() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"X ^[see ].\n",
concat!(
"X .
\n",
"\n"
),
);
}
#[test]
fn with_unicode_and_emoji() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"X ^[π ≈ 3.14159 😊].\n",
concat!(
"X .
\n",
"\n"
),
);
}
#[test]
fn in_list_item() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"- a ^[note]\n- b\n",
concat!(
"\n",
"\n"
),
);
}
#[test]
fn in_blockquote() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"> quote ^[q].\n",
concat!(
"\n",
"quote .
\n",
"
\n",
"\n"
),
);
}
#[test]
fn in_heading() {
html_opts!(
[extension.footnotes, extension.inline_footnotes],
"# H ^[note]\n",
concat!(
"H
\n",
"\n"
),
);
}
#[test]
fn in_table_cell() {
html_opts!(
[
extension.footnotes,
extension.inline_footnotes,
extension.table
],
"| H |\n| - |\n| c ^[cell] |\n",
concat!(
"\n",
"\n",
"\n",
"| H | \n",
"
\n",
"\n",
"\n",
"\n",
"| c | \n",
"
\n",
"\n",
"
\n",
"\n"
),
);
}