aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-16 16:49:29 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-16 16:49:53 +0200
commit6ee90b34c87354baf8e03d5469a92cf5dd17a82b (patch)
treecfa64be772be6464e6f790dabccf8a77e7afe60e /src/compiler.rs
parent93d0b7c6465f4ffe220b3ddada729746b11eb6ce (diff)
downloadmarkdown-rs-6ee90b34c87354baf8e03d5469a92cf5dd17a82b.tar.gz
markdown-rs-6ee90b34c87354baf8e03d5469a92cf5dd17a82b.tar.bz2
markdown-rs-6ee90b34c87354baf8e03d5469a92cf5dd17a82b.zip
Add support for frontmatter
Diffstat (limited to 'src/compiler.rs')
-rw-r--r--src/compiler.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/compiler.rs b/src/compiler.rs
index db0df9b..a5b2bf5 100644
--- a/src/compiler.rs
+++ b/src/compiler.rs
@@ -319,6 +319,7 @@ fn enter(context: &mut CompileContext) {
Name::Definition => on_enter_definition(context),
Name::DefinitionDestinationString => on_enter_definition_destination_string(context),
Name::Emphasis => on_enter_emphasis(context),
+ Name::Frontmatter => on_enter_frontmatter(context),
Name::HtmlFlow => on_enter_html_flow(context),
Name::HtmlText => on_enter_html_text(context),
Name::Image => on_enter_image(context),
@@ -361,6 +362,7 @@ fn exit(context: &mut CompileContext) {
Name::DefinitionLabelString => on_exit_definition_label_string(context),
Name::DefinitionTitleString => on_exit_definition_title_string(context),
Name::Emphasis => on_exit_emphasis(context),
+ Name::Frontmatter => on_exit_frontmatter(context),
Name::HardBreakEscape | Name::HardBreakTrailing => on_exit_break(context),
Name::HeadingAtx => on_exit_heading_atx(context),
Name::HeadingAtxSequence => on_exit_heading_atx_sequence(context),
@@ -451,6 +453,11 @@ fn on_enter_emphasis(context: &mut CompileContext) {
}
}
+/// Handle [`Enter`][Kind::Enter]:[`Frontmatter`][Name::Frontmatter].
+fn on_enter_frontmatter(context: &mut CompileContext) {
+ context.buffer();
+}
+
/// Handle [`Enter`][Kind::Enter]:[`HtmlFlow`][Name::HtmlFlow].
fn on_enter_html_flow(context: &mut CompileContext) {
context.line_ending_if_needed();
@@ -908,6 +915,12 @@ fn on_exit_emphasis(context: &mut CompileContext) {
}
}
+/// Handle [`Exit`][Kind::Exit]:[`Frontmatter`][Name::Frontmatter].
+fn on_exit_frontmatter(context: &mut CompileContext) {
+ context.resume();
+ context.slurp_one_line_ending = true;
+}
+
/// Handle [`Exit`][Kind::Exit]:[`HeadingAtx`][Name::HeadingAtx].
fn on_exit_heading_atx(context: &mut CompileContext) {
let rank = context