diff --git a/crates/compiler/parse/src/highlight.rs b/crates/compiler/parse/src/highlight.rs index 67fdcf0bc1..24df977723 100644 --- a/crates/compiler/parse/src/highlight.rs +++ b/crates/compiler/parse/src/highlight.rs @@ -39,6 +39,7 @@ pub enum Token { LessThan, Comma, Backslash, + Slash, Brace, Bracket, Paren, @@ -315,6 +316,13 @@ fn highlight_inner<'a>( Token::Backslash, )); } + '/' => { + state.advance_mut(1); + tokens.push(Loc::at( + Region::between(start, state.pos()), + Token::Slash, + )); + } '{' | '}' => { state.advance_mut(1); tokens.push(Loc::at(Region::between(start, state.pos()), Token::Brace)); @@ -631,4 +639,27 @@ mod tests { ] ) } + + #[test] + fn test_highlight_slash() { + let text = "first / second"; + let tokens = highlight(text); + assert_eq!( + tokens, + vec![ + Loc::at( + Region::between(Position::new(0), Position::new(5)), + Token::LowerIdent + ), + Loc::at( + Region::between(Position::new(6), Position::new(7)), + Token::Slash + ), + Loc::at( + Region::between(Position::new(8), Position::new(14)), + Token::LowerIdent + ), + ] + ) + } } diff --git a/examples/static-site-gen/platform/src/highlight.rs b/examples/static-site-gen/platform/src/highlight.rs index e61f542e2f..3e3b193f7c 100644 --- a/examples/static-site-gen/platform/src/highlight.rs +++ b/examples/static-site-gen/platform/src/highlight.rs @@ -50,7 +50,7 @@ pub fn highlight_roc_code(code: &str) -> String { Token::Colon => { buf = push_html_span(buf, current_text, "colon"); } - Token::GreaterThan | Token::Minus | Token::LessThan | Token::Plus | Token::Equals => { + Token::Slash | Token::GreaterThan | Token::Minus | Token::LessThan | Token::Plus | Token::Equals => { buf = push_html_span(buf, current_text, "op"); } Token::Paren => {