Skip to content

Commit

Permalink
Add failing test for issue getzola#160
Browse files Browse the repository at this point in the history
  • Loading branch information
reillysiemens committed Oct 29, 2017
1 parent bfdfe3b commit 97230e9
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions components/rendering/tests/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,49 @@ fn can_render_body_shortcode_with_markdown_char_in_name() {
}
}

#[test]
fn can_render_body_shortcode_with_args_and_paragraph_after() {
let permalinks_ctx = HashMap::new();
let mut tera = Tera::default();
tera.extend(&GUTENBERG_TERA).unwrap();

let shortcode_name = "figure";
let shortcode = r#"
<figure>
<img src="{{ src }}" alt="{{ alt }}">
<figcaption>
{{ body }} <a href="{{ src }}">View full size.</a>
</figcaption>
</figure>
"#;

let markdown_string = r#"
{% figure(src="foo.png", alt="Bar") %}
This is a figure caption.
{% end %}
Here is _another_ paragraph with
`markdown`.
"#;

let expected = r#"
<figure>
<img src="foo.png" alt="Bar">
<figcaption>
This is a figure caption. <a href="foo.png">View full size.</a>
</figcaption>
</figure>
<p>Here is <em>another</em> paragraph with <code>markdown</code>.</p>
"#;

tera.add_raw_template(&format!("shortcodes/{}.html", shortcode_name), shortcode).unwrap();
let context = Context::new(&tera, true, "base16-ocean-dark".to_string(), "", &permalinks_ctx, InsertAnchor::None);

let res = markdown_to_html(markdown_string, &context).unwrap();
println!("{:?}", res);
assert_eq!(res.0, expected);
}

#[test]
fn can_render_several_shortcode_in_row() {
let permalinks_ctx = HashMap::new();
Expand Down

0 comments on commit 97230e9

Please sign in to comment.