Major clean up and improvements to vimwiki compatibility and documentation.
CI / cargo fmt --check (push) Successful in 33s
CI / cargo clippy (push) Successful in 23s
CI / cargo test (push) Successful in 33s
CI / editor keymaps (push) Successful in 1m25s

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-05-30 18:35:40 +00:00
parent 95645a2b91
commit 8ab6015405
71 changed files with 2496 additions and 1914 deletions
@@ -1,6 +1,6 @@
//! Vimwiki lexer.
//!
//! Hand-rolled, two-pass per SPEC.md §6.6:
//! Hand-rolled, two-pass:
//!
//! - **Block pass:** scan the source line by line, recognise structural
//! constructs (headings, lists, tables, fences, comments, etc.), emit
@@ -12,7 +12,7 @@
//! Both passes share one `Vec<VimwikiToken>` so the parser sees a single,
//! ordered stream. The lexer is permissive: every delimiter is emitted; the
//! parser pairs them and falls back to literal text on mismatches. Spans are
//! stored as 0-indexed byte offsets per SPEC.md §6.5.
//! stored as 0-indexed byte offsets.
//!
//! Multi-line constructs (`{{{ }}}`, `{{$ }}$`, `%%+ +%%`) flip a
//! `BlockMode` so subsequent lines are treated as raw content until the
@@ -97,13 +97,13 @@ pub enum VimwikiTokenKind {
CommentMultiClose,
CommentMultiLine(String),
// ----- Tags (SPEC §12.3) -----
// ----- Tags -----
/// `:tag1:tag2:` — colon-delimited tag line. The lexer treats this as
/// block-level (must be the entire trimmed content of the line).
/// Scope (file / heading / standalone) is the parser's job.
Tag(Vec<String>),
// ----- Page placeholders (SPEC §9) -----
// ----- Page placeholders -----
PlaceholderTitle(Option<String>),
PlaceholderNohtml,
PlaceholderTemplate(Option<String>),
@@ -129,7 +129,7 @@ pub enum VimwikiTokenKind {
TransclusionSep,
RawUrl(String),
/// Lex error — never aborts the whole document (SPEC §6.7).
/// Lex error — never aborts the whole document.
Error(String),
}
@@ -481,7 +481,7 @@ impl<'src> LexState<'src> {
if trimmed.len() < 4 || !trimmed.bytes().all(|b| b == b'-') {
return false;
}
// SPEC §9: four or more dashes. Allow surrounding whitespace.
// Four or more dashes. Allow surrounding whitespace.
let span = Span::new(self.line_start_pos(), self.line_end_pos(line));
self.push(VimwikiTokenKind::HorizontalRule, span);
self.emit_newline(line);