diff --git a/crates/mitex-parser/tests/properties.rs b/crates/mitex-parser/tests/properties.rs index 8df1b1d..53238ff 100644 --- a/crates/mitex-parser/tests/properties.rs +++ b/crates/mitex-parser/tests/properties.rs @@ -84,13 +84,10 @@ mod properties { #[test] fn test_lr_symbol() { fn lr_info(input: &str) -> Option { - let Some(e) = parse(input) + let e = parse(input) .descendants() .find(|node| matches!(node.kind(), SyntaxKind::ItemLR)) - .and_then(LRItem::cast) - else { - return None; - }; + .and_then(LRItem::cast)?; fn pretty_sym(s: Option) -> String { s.map(SnapToken) diff --git a/crates/mitex/src/lib.rs b/crates/mitex/src/lib.rs index 64cd7f9..a6391af 100644 --- a/crates/mitex/src/lib.rs +++ b/crates/mitex/src/lib.rs @@ -241,6 +241,8 @@ impl Converter { _ => self.convert(f, rowan::NodeOrToken::Token(token), spec)?, }, } + // add space + f.write_char(' ')?; } if name == "right" { f.write_char(')')?; @@ -949,29 +951,35 @@ mod tests { fn test_convert_lr() { assert_debug_snapshot!(convert_math(r#"$\left.\right.$"#), @r###" Ok( - "lr()", + "lr( )", ) "###); assert_debug_snapshot!(convert_math(r#"$\left.a\right.$"#), @r###" Ok( - "lr(a )", + "lr( a )", ) "###); assert_debug_snapshot!(convert_math(r#"$\alpha\left.\right.$"#), @r###" Ok( - "alpha lr()", + "alpha lr( )", ) "### ); assert_debug_snapshot!(convert_math(r#"$\left . a \right \|$"#), @r###" Ok( - "lr( a ||)", + "lr( a || )", ) "### ); assert_debug_snapshot!(convert_math(r#"$\left\langle a\right\|$"#), @r###" Ok( - "lr(angle.l a ||)", + "lr(angle.l a || )", + ) + "### + ); + assert_debug_snapshot!(convert_math(r#"$\left\lbrack\lbrack x\rbrack\right\rbrack$"#), @r###" + Ok( + "lr(bracket.l bracket.l x bracket.r bracket.r )", ) "### );