Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/stage_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ impl From<NorgToken> for String {
/// A list of characters which are considered "special", i.e. for parsing of attached modifiers.
const SPECIAL_CHARS: &str = "*-~/_!%^,\"'`$:@|=.#+<>()[]{}\\";

/// List of chars that proceed "end" tags
const TAG_CHARS: &str = "|@=";

/// Parses a `.norg` document and breaks it up into tokens.
pub fn stage_1() -> impl Parser<char, Vec<NorgToken>, Error = chumsky::error::Simple<char>> {
let ws = filter(|c: &char| c.is_inline_whitespace() || c.is_separator_space())
Expand All @@ -72,7 +75,7 @@ pub fn stage_1() -> impl Parser<char, Vec<NorgToken>, Error = chumsky::error::Si

let escape = just('\\').ignore_then(any()).map(NorgToken::Escape);

let tag_end = one_of(SPECIAL_CHARS)
let tag_end = one_of(TAG_CHARS)
.then_ignore(keyword("end"))
.then_ignore(choice((one_of("\n\r").rewind().map(|_| ()), end())))
.map(NorgToken::End);
Expand Down
3 changes: 2 additions & 1 deletion src/stage_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ fn tokens_to_paragraph_segment(tokens: Vec<NorgToken>) -> ParagraphTokenList {
result.insert(0, c);

Some(ParagraphSegmentToken::Text(result))
}
},
Some(NorgToken::End(x)) => Some(ParagraphSegmentToken::Text(format!("{x}end"))),
None => None,
_x => {
unreachable!();
Expand Down
Loading