aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gfm_footnote.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
commita0c84c505d733be2e987a333a34244c1befb56cb (patch)
tree0545a747b6f2f627a71bd31949ad622bbc56c176 /tests/gfm_footnote.rs
parent9cb9e37c33173c16cbafd345f43e43b5a550537d (diff)
downloadmarkdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.gz
markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.bz2
markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.zip
Add support for compiling to mdast
See: <https://github.com/syntax-tree/mdast>.
Diffstat (limited to '')
-rw-r--r--tests/gfm_footnote.rs45
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/gfm_footnote.rs b/tests/gfm_footnote.rs
index 42c70d3..8785239 100644
--- a/tests/gfm_footnote.rs
+++ b/tests/gfm_footnote.rs
@@ -1,5 +1,8 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Constructs, Options};
+use micromark::{
+ mdast::{FootnoteDefinition, FootnoteReference, Node, Paragraph, Position, Root, Text},
+ micromark, micromark_to_mdast, micromark_with_options, Constructs, Options,
+};
use pretty_assertions::assert_eq;
#[test]
@@ -1597,5 +1600,45 @@ multi-paragraph list items. <a href="#user-content-fnref-longnote" data-footnote
"should match references and definitions like GitHub"
);
+ assert_eq!(
+ micromark_to_mdast("[^a]: b\n\tc\n\nd [^a] e.", &gfm)?,
+ Node::Root(Root {
+ children: vec![
+ Node::FootnoteDefinition(FootnoteDefinition {
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Text(Text {
+ value: "b\nc".to_string(),
+ position: Some(Position::new(1, 7, 6, 2, 6, 10))
+ })],
+ position: Some(Position::new(1, 7, 6, 2, 6, 10))
+ })],
+ identifier: "a".to_string(),
+ label: Some("a".to_string()),
+ position: Some(Position::new(1, 1, 0, 3, 1, 11))
+ }),
+ Node::Paragraph(Paragraph {
+ children: vec![
+ Node::Text(Text {
+ value: "d ".to_string(),
+ position: Some(Position::new(4, 1, 12, 4, 3, 14))
+ }),
+ Node::FootnoteReference(FootnoteReference {
+ identifier: "a".to_string(),
+ label: Some("a".to_string()),
+ position: Some(Position::new(4, 3, 14, 4, 7, 18))
+ }),
+ Node::Text(Text {
+ value: " e.".to_string(),
+ position: Some(Position::new(4, 7, 18, 4, 10, 21))
+ })
+ ],
+ position: Some(Position::new(4, 1, 12, 4, 10, 21))
+ })
+ ],
+ position: Some(Position::new(1, 1, 0, 4, 10, 21))
+ }),
+ "should support GFM footnotes as `FootnoteDefinition`, `FootnoteReference`s in mdast"
+ );
+
Ok(())
}