feat: support for toml meta

This commit is contained in:
DarkCat09 2025-03-10 17:23:42 +04:00
parent a1ad036fa9
commit 16a5c2d707
Signed by: DarkCat09
SSH key fingerprint: SHA256:SnH1iYY/ogxxRmt1I6piy+aVUUzrOWvfksQWfhZ8JUM

View file

@ -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> {