From 24fec22e912c1aa2569e95683ca95edf1aafce8b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 17 Jun 2022 17:45:50 +0200 Subject: Add support for definitions * Add definitions * Add partials for label, destination, title * Add `go`, to attempt something, and do something else on `ok` --- src/compiler.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/compiler.rs') diff --git a/src/compiler.rs b/src/compiler.rs index 9941fa5..be5d0fe 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -128,6 +128,18 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St | TokenType::CodeTextSequence | TokenType::Content | TokenType::Data + | TokenType::DefinitionLabel + | TokenType::DefinitionLabelMarker + | TokenType::DefinitionLabelData + | TokenType::DefinitionMarker + | TokenType::DefinitionDestination + | TokenType::DefinitionDestinationLiteral + | TokenType::DefinitionDestinationLiteralMarker + | TokenType::DefinitionDestinationRaw + | TokenType::DefinitionDestinationString + | TokenType::DefinitionTitle + | TokenType::DefinitionTitleMarker + | TokenType::DefinitionTitleString | TokenType::HardBreakEscape | TokenType::HardBreakEscapeMarker | TokenType::HardBreakTrailing @@ -148,6 +160,7 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St } TokenType::CodeFencedFenceInfo | TokenType::CodeFencedFenceMeta + | TokenType::Definition | TokenType::HeadingAtxText | TokenType::HeadingSetextText => { buffer(buffers); @@ -201,6 +214,18 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St | TokenType::CodeIndentedPrefixWhitespace | TokenType::CodeTextSequence | TokenType::Content + | TokenType::DefinitionLabel + | TokenType::DefinitionLabelMarker + | TokenType::DefinitionLabelData + | TokenType::DefinitionMarker + | TokenType::DefinitionDestination + | TokenType::DefinitionDestinationLiteral + | TokenType::DefinitionDestinationLiteralMarker + | TokenType::DefinitionDestinationRaw + | TokenType::DefinitionDestinationString + | TokenType::DefinitionTitle + | TokenType::DefinitionTitleMarker + | TokenType::DefinitionTitleString | TokenType::HardBreakEscapeMarker | TokenType::HardBreakTrailingSpace | TokenType::HeadingSetext @@ -353,6 +378,10 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St TokenType::CodeTextLineEnding => { buf_tail_mut(buffers).push(" ".to_string()); } + TokenType::Definition => { + resume(buffers); + slurp_one_line_ending = true; + } TokenType::HardBreakEscape | TokenType::HardBreakTrailing => { buf_tail_mut(buffers).push("
".to_string()); } -- cgit