From 1aa53d2459b51db73d108f0ff532641ccf8a0287 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 20 Oct 2017 21:02:29 -0600 Subject: [PATCH] fix(md): Add table/ref support Fixes #303 --- src/document.rs | 3 ++- .../markdown_table/_layouts/default.liquid | 12 ++++++++++++ tests/fixtures/markdown_table/index.md | 10 ++++++++++ tests/mod.rs | 5 +++++ tests/target/markdown_table/index.html | 18 ++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/markdown_table/_layouts/default.liquid create mode 100644 tests/fixtures/markdown_table/index.md create mode 100644 tests/target/markdown_table/index.html diff --git a/src/document.rs b/src/document.rs index 00978042..ee0a12fb 100644 --- a/src/document.rs +++ b/src/document.rs @@ -343,7 +343,8 @@ impl Document { frontmatter::SourceFormat::Raw => html, frontmatter::SourceFormat::Markdown => { let mut buf = String::new(); - let parser = cmark::Parser::new(&html); + let options = cmark::OPTION_ENABLE_FOOTNOTES | cmark::OPTION_ENABLE_TABLES; + let parser = cmark::Parser::new_ext(&html, options); cmark::html::push_html(&mut buf, decorate_markdown(parser, syntax_theme)); buf } diff --git a/tests/fixtures/markdown_table/_layouts/default.liquid b/tests/fixtures/markdown_table/_layouts/default.liquid new file mode 100644 index 00000000..389d5c84 --- /dev/null +++ b/tests/fixtures/markdown_table/_layouts/default.liquid @@ -0,0 +1,12 @@ + + + + test + + +

{{ path }}

+ + {{ content }} + + + diff --git a/tests/fixtures/markdown_table/index.md b/tests/fixtures/markdown_table/index.md new file mode 100644 index 00000000..344f4f28 --- /dev/null +++ b/tests/fixtures/markdown_table/index.md @@ -0,0 +1,10 @@ +extends: default.liquid +--- + +test | test +--|-- +12| 123 + +Header 1 | Header 2 +---------|--------- +data 1 | data 2 diff --git a/tests/mod.rs b/tests/mod.rs index c39fb458..b9870fa0 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -252,6 +252,11 @@ pub fn querystrings() { run_test("querystrings").expect("Build error"); } +#[test] +pub fn markdown_table() { + run_test("markdown_table").expect("Build error"); +} + #[cfg(feature = "sass")] #[test] pub fn sass() { diff --git a/tests/target/markdown_table/index.html b/tests/target/markdown_table/index.html new file mode 100644 index 00000000..d20aa20c --- /dev/null +++ b/tests/target/markdown_table/index.html @@ -0,0 +1,18 @@ + + + + test + + +

index.html

+ + + +
test test
12 123
+ + +
Header 1 Header 2
data 1 data 2
+ + + +