pub fn to_md_with_config(node: Node, config: &ToMdConfig) -> String
Expand description
Converts a Node to a markdown string with custom config.
§Arguments
node
- ANode
to be converted to markdown.config
- A custom configuration,ToMdConfig
, to use to configure how to render the output markdown.
§Example’s
use html2md_rs::{
structs::{
Node,
NodeType::{Div, Text, H1, P},
ToMdConfig,
},
to_md::to_md_with_config,
};
let input = Node {
tag_name: Some(Div),
children: vec![
Node {
tag_name: Some(H1),
children: vec![Node {
tag_name: Some(Text),
value: Some("Hello world".to_string()),
..Default::default()
}],
..Default::default()
},
Node {
tag_name: Some(P),
children: vec![Node {
tag_name: Some(Text),
value: Some("This will be ignored".to_string()),
..Default::default()
}],
..Default::default()
},
],
..Default::default()
};
let config = ToMdConfig {
ignore_rendering: vec![P],
};
let parsed = to_md_with_config(input, &config);
assert_eq!(parsed, "# Hello world\n");