feat: support for toml meta
This commit is contained in:
parent
a1ad036fa9
commit
16a5c2d707
1 changed files with 17 additions and 10 deletions
|
@ -3,7 +3,7 @@ use std::{
|
|||
path::Path,
|
||||
};
|
||||
|
||||
use pulldown_cmark::{CowStr, Options, Parser};
|
||||
use pulldown_cmark::{CowStr, MetadataBlockKind, Options, Parser};
|
||||
|
||||
pub fn compile_md_file(
|
||||
src: impl AsRef<Path>,
|
||||
|
@ -189,8 +189,11 @@ fn render_markdown<'md>(src: &'md str, mut p: ParserVars<'md>) -> std::io::Resul
|
|||
p.state = State::Footnote;
|
||||
}
|
||||
|
||||
MetadataBlock(_) => {
|
||||
p.state = State::Metadata(p.state != State::Start);
|
||||
MetadataBlock(kind) => {
|
||||
p.state = State::Metadata {
|
||||
was_at_start: p.state == State::Start,
|
||||
kind,
|
||||
};
|
||||
}
|
||||
|
||||
other => {
|
||||
|
@ -265,17 +268,18 @@ fn render_markdown<'md>(src: &'md str, mut p: ParserVars<'md>) -> std::io::Resul
|
|||
_ => {}
|
||||
}
|
||||
|
||||
p.state = if p.state == State::Metadata(false) {
|
||||
State::Start
|
||||
} else {
|
||||
State::Paragraph
|
||||
p.state = match p.state {
|
||||
State::Metadata {
|
||||
was_at_start: true, ..
|
||||
} => State::Start,
|
||||
_ => State::Paragraph,
|
||||
};
|
||||
}
|
||||
|
||||
Text(text) => {
|
||||
match p.state {
|
||||
State::Metadata(_) => {
|
||||
// TODO: parse yaml
|
||||
State::Metadata { .. } => {
|
||||
// TODO: parse yaml/toml
|
||||
continue;
|
||||
}
|
||||
_ => {}
|
||||
|
@ -399,7 +403,10 @@ enum State {
|
|||
Footnote,
|
||||
Quote,
|
||||
TableHead,
|
||||
Metadata(bool),
|
||||
Metadata {
|
||||
was_at_start: bool,
|
||||
kind: MetadataBlockKind,
|
||||
},
|
||||
}
|
||||
|
||||
struct GmiLink<'link> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue