Add test for continue reading after shortcode

This commit is contained in:
Vincent Prouillet 2020-09-23 19:21:21 +02:00
parent 59d9d26f0e
commit 664cb14ffd

View file

@ -937,7 +937,7 @@ Bla bla"#;
<p>Bla bla</p> <p>Bla bla</p>
"#; "#;
tera.add_raw_template(&format!("shortcodes/{}.md", "quote"), shortcode).unwrap(); tera.add_raw_template("shortcodes/quote.md", shortcode).unwrap();
let config = Config::default(); let config = Config::default();
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None);
@ -1003,3 +1003,36 @@ fn can_render_commented_out_shortcodes_fine() {
let res = render_content(markdown_string, &context).unwrap(); let res = render_content(markdown_string, &context).unwrap();
assert_eq!(res.body, expected); assert_eq!(res.body, expected);
} }
// https://zola.discourse.group/t/zola-12-issue-with-continue-reading/590/7
#[test]
fn can_render_read_more_after_shortcode() {
let permalinks_ctx = HashMap::new();
let mut tera = Tera::default();
tera.extend(&ZOLA_TERA).unwrap();
let shortcode = r#"<p>Quote: {{body}}</p>"#;
let markdown_string = r#"
# Title
Some text
{{ quote(body="Nothing is impossible. The word itself says - I'm Possible" author="Audrey Hepburn")}}
<!-- more -->
Again more text"#;
let expected = r#"<h1 id="title">Title</h1>
<p>Some text</p>
<p>Quote: Nothing is impossible. The word itself says - I'm Possible</p>
<span id="continue-reading"></span>
<p>Again more text</p>
"#;
tera.add_raw_template("shortcodes/quote.md", shortcode).unwrap();
let config = Config::default();
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None);
let res = render_content(markdown_string, &context).unwrap();
assert_eq!(res.body, expected);
}