use std::collections::HashMap; use tera::Tera; use config::Config; use front_matter::InsertAnchor; use rendering::{render_content, RenderContext}; macro_rules! colored_html_line { ( $s:expr ) => {{ let mut result = "".to_string(); result.push_str($s); result.push_str("\n"); result }}; } macro_rules! colored_html { ( $($s:expr),* $(,)* ) => {{ let mut result = "
\n".to_string();
$(
result.push_str(colored_html_line!($s).as_str());
)*
result.push_str("
");
result
}};
}
#[test]
fn hide_lines_simple() {
let tera_ctx = Tera::default();
let permalinks_ctx = HashMap::new();
let mut config = Config::default_for_test();
config.markdown.highlight_code = true;
let context = RenderContext::new(
&tera_ctx,
&config,
&config.default_language,
"",
&permalinks_ctx,
InsertAnchor::None,
);
let res = render_content(
r#"
```hide_lines=2
foo
bar
baz
bat
```
"#,
&context,
)
.unwrap();
assert_eq!(res.body, colored_html!("foo\nbaz\nbat",));
}