Skip to content

Commit

Permalink
fix: fix broken lr (#144)
Browse files Browse the repository at this point in the history
* fix: fix broken lr

* fix: make ci happy
  • Loading branch information
OrangeX4 committed Mar 27, 2024
1 parent f2e9e31 commit 8e5045a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
7 changes: 2 additions & 5 deletions crates/mitex-parser/tests/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,10 @@ mod properties {
#[test]
fn test_lr_symbol() {
fn lr_info(input: &str) -> Option<String> {
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<SyntaxToken>) -> String {
s.map(SnapToken)
Expand Down
18 changes: 13 additions & 5 deletions crates/mitex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(')')?;
Expand Down Expand Up @@ -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 )",
)
"###
);
Expand Down

0 comments on commit 8e5045a

Please sign in to comment.