summaryrefslogtreecommitdiff
path: root/crates/typst-syntax/src/lexer.rs
diff options
context:
space:
mode:
authorIan Wrzesinski <wrzian@umich.edu>2024-10-22 00:13:56 -0400
committerIan Wrzesinski <wrzian@umich.edu>2024-11-03 20:28:49 -0500
commit26c61be1dc761306ea7f256b73344a22d843b622 (patch)
tree1f6be43f446d438e44d7838616e04a38da4d4f0c /crates/typst-syntax/src/lexer.rs
parent4ce0b069f6478163eed2d2fd1860905bd47a5f46 (diff)
15. Convert Markup mode to use newline modes
(And break out Newline info into separate struct)
Diffstat (limited to 'crates/typst-syntax/src/lexer.rs')
-rw-r--r--crates/typst-syntax/src/lexer.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs
index 4a43c15f..d09c6f84 100644
--- a/crates/typst-syntax/src/lexer.rs
+++ b/crates/typst-syntax/src/lexer.rs
@@ -68,6 +68,11 @@ impl<'s> Lexer<'s> {
pub fn newline(&self) -> bool {
self.newline
}
+
+ /// The number of characters until the most recent newline.
+ pub fn column(&self) -> usize {
+ self.s.before().chars().rev().take_while(|&c| !is_newline(c)).count()
+ }
}
impl Lexer<'_> {