You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -152,6 +158,7 @@ If you would like to modify or sanitize the HTML before rendering it, then `Html
152
158
|`onLinkTap`| A function that defines what the widget should do when a link is tapped. The function exposes the `src` of the link as a `String` to use in your implementation. |
153
159
|`customRender`| A powerful API that allows you to customize everything when rendering a specific HTML tag. |
154
160
|`onImageError`| A function that defines what the widget should do when an image fails to load. The function exposes the exception `Object` and `StackTrace` to use in your implementation. |
161
+
|`omMathError`| A function that defines what the widget should do when a math fails to render. The function exposes the parsed Tex `String`, as well as the error and error with type from `flutter_math` as a `String`. |
155
162
|`shrinkWrap`| A `bool` used while rendering different widgets to specify whether they should be shrink-wrapped or not, like `ContainerSpan`|
156
163
|`onImageTap`| A function that defines what the widget should do when an image is tapped. The function exposes the `src` of the image as a `String` to use in your implementation. |
157
164
|`blacklistedElements`| A list of elements the `Html` widget should not render. The list should contain the tags of the HTML elements you wish to blacklist. |
@@ -335,6 +342,24 @@ Widget html = Html(
335
342
);
336
343
```
337
344
345
+
### onMathError:
346
+
347
+
A function that defines what the widget should do when a math fails to render. The function exposes the parsed Tex `String`, as well as the error and error with type from `flutter_math` as a `String`.
348
+
349
+
#### Example Usage - onMathError:
350
+
351
+
```dart
352
+
Widget html = Html(
353
+
data: """<!-- Some MathML string that fails to parse -->""",
//your logic here. A Widget must be returned from this function:
356
+
return Text(error);
357
+
//you can also try and fix the parsing yourself:
358
+
return Math.tex(correctedParsedTex);
359
+
},
360
+
);
361
+
```
362
+
338
363
### onImageTap:
339
364
340
365
A function that defines what the widget should do when an image is tapped.
@@ -679,6 +704,41 @@ This package renders svg elements using the [`flutter_svg`](https://pub.dev/pack
679
704
680
705
When rendering SVGs, the package takes the SVG data within the `<svg>` tag and passes it to `flutter_svg`. The `width` and `height` attributes are considered while rendering, if given.
681
706
707
+
### MathML
708
+
709
+
This package renders MathML elements using the [`flutter_math`](https://pub.dev/packages/flutter_math) plugin.
710
+
711
+
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`.
712
+
713
+
Because this package is parsing MathML to Tex, it may not support some functionalities. The current list of supported tags can be found [above](#currently-supported-html-tags), but some of these only have partial support at the moment.
714
+
715
+
If the parsing errors, you can use the [onMathError](#onmatherror) API to catch the error and potentially fix it on your end - you can analyze the error and the parsed string, and finally return a new instance of `Math.tex()` with the corrected Tex string.
716
+
717
+
If you'd like to see more MathML features, feel free to create a PR or file a feature request!
718
+
719
+
### Tex
720
+
721
+
If you have a Tex string you'd like to render inside your HTML you can do that using the same [`flutter_math`](https://pub.dev/packages/flutter_math) plugin.
722
+
723
+
Use a custom tag inside your HTML (an example could be `<tex>`), and place your **raw** Tex string inside.
724
+
725
+
Then, use the `customRender` parameter to add the widget to render Tex. It could look like this:
0 commit comments