Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve formula parser #131

Merged
merged 9 commits into from
Mar 1, 2024
Merged

Conversation

Myriad-Dreamin
Copy link
Collaborator

@Myriad-Dreamin Myriad-Dreamin commented Feb 21, 2024

I have refactored the parser and added some tests for formulas.

During testing, I find a bug:

mitex/crates/mitex/src/lib.rs

Lines 1151 to 1156 in b85675a

// todo: fix this bug
assert_debug_snapshot!(convert_text(r#"$ a $"#), @r###"
Ok(
"$ a $",
)
"###);

And two optional semantic errors to handle:

mitex/crates/mitex/src/lib.rs

Lines 1157 to 1168 in b85675a

// todo: fix semantic incorrect cases
assert_debug_snapshot!(convert_text(r#"$$ a $ $ b $$"#), @r###"
Ok(
"$ a $ $ b $",
)
"###);
// todo: fix semantic incorrect cases
assert_debug_snapshot!(convert_text(r#"\[a\)\(b\]"#), @r###"
Ok(
"$ a $$b $",
)
"###);

@OrangeX4
Copy link
Member

Now, in text mode, we translate $ a $ as #math.equation(block: false, $ a $); instead of using bare equation, to address the first bug. However, I'm not quite sure about the next two optional semantic errors, but they seem to be just edge cases. Should we not prioritize them for now?

@Myriad-Dreamin
Copy link
Collaborator Author

Now, in text mode, we translate $ a $ as #math.equation(block: false, $ a $); instead of using bare equation, to address the first bug.

Sounds great before we having taken all whitespace into control.

However, I'm not quite sure about the next two optional semantic errors, but they seem to be just edge cases. Should we not prioritize them for now?

You can do it now, but it is not urgent since they don't occur in regular document. In addition, this is not introduced by this PR and has stayed for a long time.

@OrangeX4
Copy link
Member

Ok, I've added formula check.

@Myriad-Dreamin Myriad-Dreamin merged commit 77f8ea8 into main Mar 1, 2024
7 checks passed
@Myriad-Dreamin Myriad-Dreamin deleted the improve-formula-parser branch March 1, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants