flutter_html_math 3.0.0-beta.2 flutter_html_math: ^3.0.0-beta.2 copied to clipboard
This extension package allows the <math> tag to be rendered using the flutter_html package
flutter_html_math #
Math widget for flutter_html.
his package renders MathML elements using the flutter_math_fork
plugin.
When rendering MathML, the package takes the MathML data within the <math>
tag and tries to parse it to Tex. Then, it will pass the parsed string to flutter_math_fork
.
Because this package is parsing MathML to Tex, it may not support some functionalities. The current list of supported tags can be found above, but some of these only have partial support at the moment.
Registering the CustomRender
:
Widget html = Html(
customRenders: {
mathMatcher(): mathRender(),
}
);
If the parsing errors, you can use the onMathError
property of mathRender
to catch the error and potentially fix it on your end.
The function exposes the parsed Tex String
, as well as the error and error with type from flutter_math_fork
as a String
.
You can analyze the error and the parsed string, and finally return a new instance of Math.tex()
with the corrected Tex string.
onMathError
example:
Widget html = Html(
customRenders: {
mathMatcher(): mathRender(onMathError: (tex, exception, exceptionWithType) {
print(exception);
//optionally try and correct the Tex string here
return Text(exception);
}),
}
);