use crate::{ prelude::*, syntax::content::{ Parseable as _, parser::{ lexeme::Lexeme, token::{Token, oblique::Oblique}, state::State, }, }, }; pub fn parse( lexeme: &Lexeme, state: &mut State, tokens: &mut Vec, ) -> bool { if Oblique::probe(lexeme) { log!("Oblique probed {lexeme}"); tokens.push(Token::Oblique(Oblique::new(!state.switches.oblique))); state.switches.oblique = !state.switches.oblique; return true; } false } #[cfg(test)] mod tests { use crate::{syntax::content::parser, types::Graph}; fn read(input: &str) -> String { parser::read(input, &Graph::new(None).meta.config) } #[test] fn oblique_anchor() { assert_eq!( read("w _|S|_ w"), r#"

w S w

"# ); } #[test] fn oblique_anchor_with_trailing_comma() { assert_eq!( read("w _|S|_, w"), r#"

w S, w

"# ); } #[test] fn oblique() { assert_eq!( read( "_|this anchor is oblique|o as are these literals_ but not these _just these_, not this _and these with an |anchor| again_" ), r#"

this anchor is oblique as are these literals but not these just these, not this and these with an anchor again

"# ); } #[test] fn trailing_oblique() { assert_eq!(read("see _acks_"), "

see acks

"); } #[test] fn trailing_oblique_with_newline() { assert_eq!(read("see _acks_\n"), "

see acks

"); } }