Update rendering tests
This commit is contained in:
parent
5f1f9efe7a
commit
c53c403790
|
@ -22,7 +22,7 @@ fn can_do_render_content_simple() {
|
||||||
let config = Config::default();
|
let config = Config::default();
|
||||||
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("hello", &context).unwrap();
|
let res = render_content("hello", &context).unwrap();
|
||||||
assert_eq!(res.0, "<p>hello</p>\n");
|
assert_eq!(res.body, "<p>hello</p>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -34,7 +34,7 @@ fn doesnt_highlight_code_block_with_highlighting_off() {
|
||||||
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("```\n$ gutenberg server\n```", &context).unwrap();
|
let res = render_content("```\n$ gutenberg server\n```", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<pre><code>$ gutenberg server\n</code></pre>\n"
|
"<pre><code>$ gutenberg server\n</code></pre>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ fn can_highlight_code_block_no_lang() {
|
||||||
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("```\n$ gutenberg server\n$ ping\n```", &context).unwrap();
|
let res = render_content("```\n$ gutenberg server\n$ ping\n```", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<pre style=\"background-color:#2b303b\">\n<span style=\"background-color:#2b303b;color:#c0c5ce;\">$ gutenberg server\n</span><span style=\"background-color:#2b303b;color:#c0c5ce;\">$ ping\n</span></pre>"
|
"<pre style=\"background-color:#2b303b\">\n<span style=\"background-color:#2b303b;color:#c0c5ce;\">$ gutenberg server\n</span><span style=\"background-color:#2b303b;color:#c0c5ce;\">$ ping\n</span></pre>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ fn can_highlight_code_block_with_lang() {
|
||||||
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("```python\nlist.append(1)\n```", &context).unwrap();
|
let res = render_content("```python\nlist.append(1)\n```", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<pre style=\"background-color:#2b303b\">\n<span style=\"background-color:#2b303b;color:#c0c5ce;\">list.</span><span style=\"background-color:#2b303b;color:#bf616a;\">append</span><span style=\"background-color:#2b303b;color:#c0c5ce;\">(</span><span style=\"background-color:#2b303b;color:#d08770;\">1</span><span style=\"background-color:#2b303b;color:#c0c5ce;\">)\n</span></pre>"
|
"<pre style=\"background-color:#2b303b\">\n<span style=\"background-color:#2b303b;color:#c0c5ce;\">list.</span><span style=\"background-color:#2b303b;color:#bf616a;\">append</span><span style=\"background-color:#2b303b;color:#c0c5ce;\">(</span><span style=\"background-color:#2b303b;color:#d08770;\">1</span><span style=\"background-color:#2b303b;color:#c0c5ce;\">)\n</span></pre>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ fn can_higlight_code_block_with_unknown_lang() {
|
||||||
let res = render_content("```yolo\nlist.append(1)\n```", &context).unwrap();
|
let res = render_content("```yolo\nlist.append(1)\n```", &context).unwrap();
|
||||||
// defaults to plain text
|
// defaults to plain text
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<pre style=\"background-color:#2b303b\">\n<span style=\"background-color:#2b303b;color:#c0c5ce;\">list.append(1)\n</span></pre>"
|
"<pre style=\"background-color:#2b303b\">\n<span style=\"background-color:#2b303b;color:#c0c5ce;\">list.append(1)\n</span></pre>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ Hello
|
||||||
|
|
||||||
{{ youtube(id="ub36ffWAqgQ") }}
|
{{ youtube(id="ub36ffWAqgQ") }}
|
||||||
"#, &context).unwrap();
|
"#, &context).unwrap();
|
||||||
assert!(res.0.contains("<p>Hello</p>\n<div >"));
|
assert!(res.body.contains("<p>Hello</p>\n<div >"));
|
||||||
assert!(res.0.contains(r#"<iframe src="https://www.youtube.com/embed/ub36ffWAqgQ""#));
|
assert!(res.body.contains(r#"<iframe src="https://www.youtube.com/embed/ub36ffWAqgQ""#));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -106,7 +106,7 @@ fn can_render_shortcode_with_markdown_char_in_args_name() {
|
||||||
];
|
];
|
||||||
for i in input {
|
for i in input {
|
||||||
let res = render_content(&format!("{{{{ youtube(id=\"hey\", {}=1) }}}}", i), &context).unwrap();
|
let res = render_content(&format!("{{{{ youtube(id=\"hey\", {}=1) }}}}", i), &context).unwrap();
|
||||||
assert!(res.0.contains(r#"<iframe src="https://www.youtube.com/embed/hey""#));
|
assert!(res.body.contains(r#"<iframe src="https://www.youtube.com/embed/hey""#));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ fn can_render_shortcode_with_markdown_char_in_args_value() {
|
||||||
];
|
];
|
||||||
for i in input {
|
for i in input {
|
||||||
let res = render_content(&format!("{{{{ youtube(id=\"{}\") }}}}", i), &context).unwrap();
|
let res = render_content(&format!("{{{{ youtube(id=\"{}\") }}}}", i), &context).unwrap();
|
||||||
assert!(res.0.contains(&format!(r#"<iframe src="https://www.youtube.com/embed/{}""#, i)));
|
assert!(res.body.contains(&format!(r#"<iframe src="https://www.youtube.com/embed/{}""#, i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ fn can_render_body_shortcode_with_markdown_char_in_name() {
|
||||||
|
|
||||||
let res = render_content(&format!("{{% {}(author=\"Bob\") %}}\nhey\n{{% end %}}", i), &context).unwrap();
|
let res = render_content(&format!("{{% {}(author=\"Bob\") %}}\nhey\n{{% end %}}", i), &context).unwrap();
|
||||||
println!("{:?}", res);
|
println!("{:?}", res);
|
||||||
assert!(res.0.contains("<blockquote>hey - Bob</blockquote>"));
|
assert!(res.body.contains("<blockquote>hey - Bob</blockquote>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ Here is another paragraph.
|
||||||
|
|
||||||
let res = render_content(markdown_string, &context).unwrap();
|
let res = render_content(markdown_string, &context).unwrap();
|
||||||
println!("{:?}", res);
|
println!("{:?}", res);
|
||||||
assert_eq!(res.0, expected);
|
assert_eq!(res.body, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -207,7 +207,7 @@ Here is another paragraph.
|
||||||
|
|
||||||
let res = render_content(markdown_string, &context).unwrap();
|
let res = render_content(markdown_string, &context).unwrap();
|
||||||
println!("{:?}", res);
|
println!("{:?}", res);
|
||||||
assert_eq!(res.0, expected);
|
assert_eq!(res.body, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -229,11 +229,11 @@ Hello
|
||||||
{{ gist(url="https://gist.github.com/Keats/32d26f699dcc13ebd41b") }}
|
{{ gist(url="https://gist.github.com/Keats/32d26f699dcc13ebd41b") }}
|
||||||
|
|
||||||
"#, &context).unwrap();
|
"#, &context).unwrap();
|
||||||
assert!(res.0.contains("<p>Hello</p>\n<div >"));
|
assert!(res.body.contains("<p>Hello</p>\n<div >"));
|
||||||
assert!(res.0.contains(r#"<iframe src="https://www.youtube.com/embed/ub36ffWAqgQ""#));
|
assert!(res.body.contains(r#"<iframe src="https://www.youtube.com/embed/ub36ffWAqgQ""#));
|
||||||
assert!(res.0.contains(r#"<iframe src="https://www.youtube.com/embed/ub36ffWAqgQ?autoplay=1""#));
|
assert!(res.body.contains(r#"<iframe src="https://www.youtube.com/embed/ub36ffWAqgQ?autoplay=1""#));
|
||||||
assert!(res.0.contains(r#"<iframe src="https://www.streamable.com/e/c0ic""#));
|
assert!(res.body.contains(r#"<iframe src="https://www.streamable.com/e/c0ic""#));
|
||||||
assert!(res.0.contains(r#"//player.vimeo.com/video/210073083""#));
|
assert!(res.body.contains(r#"//player.vimeo.com/video/210073083""#));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -243,7 +243,7 @@ fn doesnt_render_ignored_shortcodes() {
|
||||||
config.highlight_code = false;
|
config.highlight_code = false;
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content(r#"```{{/* youtube(id="w7Ft2ymGmfc") */}}```"#, &context).unwrap();
|
let res = render_content(r#"```{{/* youtube(id="w7Ft2ymGmfc") */}}```"#, &context).unwrap();
|
||||||
assert_eq!(res.0, "<p><code>{{ youtube(id="w7Ft2ymGmfc") }}</code></p>\n");
|
assert_eq!(res.body, "<p><code>{{ youtube(id="w7Ft2ymGmfc") }}</code></p>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -261,7 +261,7 @@ Hello
|
||||||
A quote
|
A quote
|
||||||
{% end %}
|
{% end %}
|
||||||
"#, &context).unwrap();
|
"#, &context).unwrap();
|
||||||
assert_eq!(res.0, "<p>Hello</p>\n<blockquote>A quote - Keats</blockquote>\n");
|
assert_eq!(res.body, "<p>Hello</p>\n<blockquote>A quote - Keats</blockquote>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -287,7 +287,7 @@ fn can_make_valid_relative_link() {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
res.0.contains(r#"<p><a href="https://vincent.is/about">rel link</a>, <a href="https://vincent.is/about">abs link</a></p>"#)
|
res.body.contains(r#"<p><a href="https://vincent.is/about">rel link</a>, <a href="https://vincent.is/about">abs link</a></p>"#)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ fn can_make_relative_links_with_anchors() {
|
||||||
let res = render_content(r#"[rel link](./pages/about.md#cv)"#, &context).unwrap();
|
let res = render_content(r#"[rel link](./pages/about.md#cv)"#, &context).unwrap();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
res.0.contains(r#"<p><a href="https://vincent.is/about#cv">rel link</a></p>"#)
|
res.body.contains(r#"<p><a href="https://vincent.is/about#cv">rel link</a></p>"#)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ fn can_add_id_to_headers() {
|
||||||
let config = Config::default();
|
let config = Config::default();
|
||||||
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content(r#"# Hello"#, &context).unwrap();
|
let res = render_content(r#"# Hello"#, &context).unwrap();
|
||||||
assert_eq!(res.0, "<h1 id=\"hello\">Hello</h1>\n");
|
assert_eq!(res.body, "<h1 id=\"hello\">Hello</h1>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -332,7 +332,7 @@ fn can_add_id_to_headers_same_slug() {
|
||||||
let config = Config::default();
|
let config = Config::default();
|
||||||
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("# Hello\n# Hello", &context).unwrap();
|
let res = render_content("# Hello\n# Hello", &context).unwrap();
|
||||||
assert_eq!(res.0, "<h1 id=\"hello\">Hello</h1>\n<h1 id=\"hello-1\">Hello</h1>\n");
|
assert_eq!(res.body, "<h1 id=\"hello\">Hello</h1>\n<h1 id=\"hello-1\">Hello</h1>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -342,7 +342,7 @@ fn can_insert_anchor_left() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
||||||
let res = render_content("# Hello", &context).unwrap();
|
let res = render_content("# Hello", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"hello\"><a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\nHello</h1>\n"
|
"<h1 id=\"hello\"><a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\nHello</h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ fn can_insert_anchor_right() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Right);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Right);
|
||||||
let res = render_content("# Hello", &context).unwrap();
|
let res = render_content("# Hello", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"hello\">Hello<a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\n</h1>\n"
|
"<h1 id=\"hello\">Hello<a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\n</h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ fn can_insert_anchor_with_exclamation_mark() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
||||||
let res = render_content("# Hello!", &context).unwrap();
|
let res = render_content("# Hello!", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"hello\"><a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\nHello!</h1>\n"
|
"<h1 id=\"hello\"><a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\nHello!</h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ fn can_insert_anchor_with_link() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
||||||
let res = render_content("## [Rust](https://rust-lang.org)", &context).unwrap();
|
let res = render_content("## [Rust](https://rust-lang.org)", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h2 id=\"rust\"><a class=\"gutenberg-anchor\" href=\"#rust\" aria-label=\"Anchor link for: rust\">🔗</a>\n<a href=\"https://rust-lang.org\">Rust</a></h2>\n"
|
"<h2 id=\"rust\"><a class=\"gutenberg-anchor\" href=\"#rust\" aria-label=\"Anchor link for: rust\">🔗</a>\n<a href=\"https://rust-lang.org\">Rust</a></h2>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ fn can_insert_anchor_with_other_special_chars() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left);
|
||||||
let res = render_content("# Hello*_()", &context).unwrap();
|
let res = render_content("# Hello*_()", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"hello\"><a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\nHello*_()</h1>\n"
|
"<h1 id=\"hello\"><a class=\"gutenberg-anchor\" href=\"#hello\" aria-label=\"Anchor link for: hello\">🔗</a>\nHello*_()</h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ fn can_make_toc() {
|
||||||
### Last one
|
### Last one
|
||||||
"#, &context).unwrap();
|
"#, &context).unwrap();
|
||||||
|
|
||||||
let toc = res.1;
|
let toc = res.toc;
|
||||||
assert_eq!(toc.len(), 1);
|
assert_eq!(toc.len(), 1);
|
||||||
assert_eq!(toc[0].children.len(), 2);
|
assert_eq!(toc[0].children.len(), 2);
|
||||||
assert_eq!(toc[0].children[1].children.len(), 1);
|
assert_eq!(toc[0].children[1].children.len(), 1);
|
||||||
|
@ -433,7 +433,7 @@ fn can_understand_backtick_in_titles() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("# `Hello`", &context).unwrap();
|
let res = render_content("# `Hello`", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"hello\"><code>Hello</code></h1>\n"
|
"<h1 id=\"hello\"><code>Hello</code></h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,7 @@ fn can_understand_backtick_in_paragraphs() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("Hello `world`", &context).unwrap();
|
let res = render_content("Hello `world`", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<p>Hello <code>world</code></p>\n"
|
"<p>Hello <code>world</code></p>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ fn can_understand_links_in_header() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("# [Rust](https://rust-lang.org)", &context).unwrap();
|
let res = render_content("# [Rust](https://rust-lang.org)", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"rust\"><a href=\"https://rust-lang.org\">Rust</a></h1>\n"
|
"<h1 id=\"rust\"><a href=\"https://rust-lang.org\">Rust</a></h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ fn can_understand_link_with_title_in_header() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("# [Rust](https://rust-lang.org \"Rust homepage\")", &context).unwrap();
|
let res = render_content("# [Rust](https://rust-lang.org \"Rust homepage\")", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"rust\"><a href=\"https://rust-lang.org\" title=\"Rust homepage\">Rust</a></h1>\n"
|
"<h1 id=\"rust\"><a href=\"https://rust-lang.org\" title=\"Rust homepage\">Rust</a></h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ fn can_make_valid_relative_link_in_header() {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<h1 id=\"rel-link\"><a href=\"https://vincent.is/about/\">rel link</a></h1>\n"
|
"<h1 id=\"rel-link\"><a href=\"https://vincent.is/about/\">rel link</a></h1>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,7 @@ fn can_make_permalinks_with_colocated_assets_for_link() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("[an image](image.jpg)", &context).unwrap();
|
let res = render_content("[an image](image.jpg)", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<p><a href=\"https://vincent.is/about/image.jpg\">an image</a></p>\n"
|
"<p><a href=\"https://vincent.is/about/image.jpg\">an image</a></p>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ fn can_make_permalinks_with_colocated_assets_for_image() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("![alt text](image.jpg)", &context).unwrap();
|
let res = render_content("![alt text](image.jpg)", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<p><img src=\"https://vincent.is/about/image.jpg\" alt=\"alt text\" /></p>\n"
|
"<p><img src=\"https://vincent.is/about/image.jpg\" alt=\"alt text\" /></p>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ Some text
|
||||||
</div>
|
</div>
|
||||||
"#, &context).unwrap();
|
"#, &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<p>Some text</p>\n<h1>Helo</h1>\n<div>\n<a href=\"mobx-flow.png\">\n <img src=\"mobx-flow.png\" alt=\"MobX flow\">\n </a>\n</div>\n"
|
"<p>Some text</p>\n<h1>Helo</h1>\n<div>\n<a href=\"mobx-flow.png\">\n <img src=\"mobx-flow.png\" alt=\"MobX flow\">\n </a>\n</div>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ fn can_validate_valid_external_links() {
|
||||||
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None);
|
||||||
let res = render_content("[a link](http://google.com)", &context).unwrap();
|
let res = render_content("[a link](http://google.com)", &context).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.0,
|
res.body,
|
||||||
"<p><a href=\"http://google.com\">a link</a></p>\n"
|
"<p><a href=\"http://google.com\">a link</a></p>\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue