feat: markdown implementation
#18
1 changed files with 10 additions and 1 deletions
|
@ -51,6 +51,7 @@ pub struct FileMetadata {
|
||||||
pub struct Metadata {
|
pub struct Metadata {
|
||||||
pub info: FileMetadata,
|
pub info: FileMetadata,
|
||||||
pub mermaid: bool,
|
pub mermaid: bool,
|
||||||
|
pub syntax_highlight: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_md(filename: &str) -> (Metadata, String) {
|
pub fn read_md(filename: &str) -> (Metadata, String) {
|
||||||
|
@ -93,8 +94,15 @@ pub fn read_md(filename: &str) -> (Metadata, String) {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Find if document contains mermaid diagram
|
// Find if document contains mermaid diagram
|
||||||
|
let mermaid = Some(String::from("mermaid"));
|
||||||
let presence_mermaid = md_nodes.iter().any(|x| match x {
|
let presence_mermaid = md_nodes.iter().any(|x| match x {
|
||||||
markdown::mdast::Node::Code(code) => code.lang == Some(String::from("mermaid")),
|
markdown::mdast::Node::Code(code) => code.lang == mermaid,
|
||||||
|
_ => false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find if document contains code to highlight
|
||||||
|
let presence_code = md_nodes.iter().any(|x| match x {
|
||||||
|
markdown::mdast::Node::Code(code) => code.lang != mermaid,
|
||||||
_ => false,
|
_ => false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -102,6 +110,7 @@ pub fn read_md(filename: &str) -> (Metadata, String) {
|
||||||
Metadata {
|
Metadata {
|
||||||
info: metadata,
|
info: metadata,
|
||||||
mermaid: presence_mermaid,
|
mermaid: presence_mermaid,
|
||||||
|
syntax_highlight: presence_code,
|
||||||
},
|
},
|
||||||
html,
|
html,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue