aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/definition.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/construct/definition.rs53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/construct/definition.rs b/src/construct/definition.rs
index 61c4d34..69d8d9b 100644
--- a/src/construct/definition.rs
+++ b/src/construct/definition.rs
@@ -57,8 +57,10 @@
//! <!-- To do: describe how references and definitions match -->
use crate::construct::{
- partial_destination::start as destination, partial_label::start as label,
- partial_space_or_tab::space_or_tab_opt, partial_title::start as title,
+ partial_destination::{start as destination, Options as DestinationOptions},
+ partial_label::{start as label, Options as LabelOptions},
+ partial_space_or_tab::space_or_tab_opt,
+ partial_title::{start as title, Options as TitleOptions},
};
use crate::tokenizer::{Code, State, StateFnResult, TokenType, Tokenizer};
@@ -79,7 +81,20 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
/// ```
pub fn before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
match code {
- Code::Char('[') => tokenizer.go(label, label_after)(tokenizer, code),
+ Code::Char('[') => tokenizer.go(
+ |t, c| {
+ label(
+ t,
+ c,
+ LabelOptions {
+ label: TokenType::DefinitionLabel,
+ marker: TokenType::DefinitionLabelMarker,
+ string: TokenType::DefinitionLabelString,
+ },
+ )
+ },
+ label_after,
+ )(tokenizer, code),
_ => (State::Nok, None),
}
}
@@ -152,7 +167,22 @@ fn destination_before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
code,
Code::None | Code::CarriageReturnLineFeed | Code::Char('\r' | '\n')
) {
- tokenizer.go(destination, destination_after)(tokenizer, code)
+ tokenizer.go(
+ |t, c| {
+ destination(
+ t,
+ c,
+ DestinationOptions {
+ destination: TokenType::DefinitionDestination,
+ literal: TokenType::DefinitionDestinationLiteral,
+ marker: TokenType::DefinitionDestinationLiteralMarker,
+ raw: TokenType::DefinitionDestinationRaw,
+ string: TokenType::DefinitionDestinationString,
+ },
+ )
+ },
+ destination_after,
+ )(tokenizer, code)
} else {
(State::Nok, None)
}
@@ -243,7 +273,20 @@ fn title_before_marker(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
let event = tokenizer.events.last().unwrap();
if event.token_type == TokenType::LineEnding || event.token_type == TokenType::Whitespace {
- tokenizer.go(title, title_after)(tokenizer, code)
+ tokenizer.go(
+ |t, c| {
+ title(
+ t,
+ c,
+ TitleOptions {
+ title: TokenType::DefinitionTitle,
+ marker: TokenType::DefinitionTitleMarker,
+ string: TokenType::DefinitionTitleString,
+ },
+ )
+ },
+ title_after,
+ )(tokenizer, code)
} else {
(State::Nok, None)
}