Skip to content

fix: add fallback to unsupported MathML tags in MathJax - #5127

Merged
dnlsilva merged 4 commits into
developfrom
add-katex-webview-fallback
Aug 16, 2023
Merged

dnlsilva merged 4 commits into
developfrom
add-katex-webview-fallback

Conversation

@dnlsilva

@dnlsilva dnlsilva commented Jul 4, 2023 •

Copy link
Copy Markdown
Contributor

Proposed changes

We currently support Katex that use the MathJax pattern, but if they use some other pattern when writing a MathML tag, the lib we are using does not support it. (Usually tags that create html components, since html is not native, it's web code)
So this PR adds a fallback in case the informed MathML tag is not supported, it renders a webview with the correct tags.
It's not the best solution because rendering webview is costly for the system, but the only way to render html components is via webview.

To check if the script is a valid MathJax script or not, just go to the official website (https://www.mathjax.org/#demo) and insert it.
Example with the script used to "break" the app.

Screenshot 2023-07-04 at 13 43 08

Issue(s)

How to test or reproduce

Send a message like "KaTeX".
Examples:

  • Plain MathML script:
    \[ f(x) = \int_{-\infty}^\infty \hat f(\xi)\,e^{2 \pi i \xi x} \,d\xi \]
    Expected output:
    Screenshot 2023-07-04 at 13 47 37

  • MathML script with html tags:
    \[\colorbox{white}{\color{black} \boxed{ \begin{matrix} \;\;\;\;\overlinesegment{\underlinesegment{ \Huge Neues\;EntityModel \; in \; Bearbeitung} } & \\ \;\;develop\end{matrix}}}\]
    Expected output:
    Screenshot 2023-07-04 at 13 51 01

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Jira: NATIVE-358

@dnlsilva
dnlsilva merged commit f78f6f3 into develop Aug 16, 2023
@dnlsilva
dnlsilva deleted the add-katex-webview-fallback branch August 16, 2023 12:02
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