CaTeX
CaTeX copied to clipboard
Request: Static function to check whether tex string is valid or not
Description
First of all I want to say thank you for this library. This is exactly what we need for the math app we are currently working on.
About my feature request: It would be great if there was a static function that can be used to check whether a Tex string is valid or not before the widget is built. Thx a lot.
Thanks! That is a feature request we actually have ourselves 🙂
The function already exists - I will expose it in a PR soon 👍🏽
(if you are curious: Parser().parse().createWidget()
is what you are looking for; https://github.com/simpleclub/CaTeX/blob/15c1a208004364d73eb306398d202de316d6cb5b/lib/src/widgets.dart#L64)
Thanks for your answer. I tried the function Parser().parse().createWidget()
. Surprisingly, it does not throw an error if I use an invalid string like r'\e'
. That's the code I used:
try {
NodeWidget _rootNode = Parser(r'\e', mode: startParsingMode).parse().createWidget(defaultCaTeXContext);
} on CaTeXException catch (e) {
window.console.log(e);
}
If I use the same string to build a widget, the CaTeXException
is thrown. Any ideas? But it is not that urgent. I can wait for the PR.
@michaelniedermayr Yes, that is an issue at the moment → symbols are evaluated at render box creation time (and they should not).
The current way to handle it is described here, but I want to change it 🙂