Render unsafe latex html string using Html View
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 28/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- angular, typescript
- Domaine
- mobile-dev
Piste de recherche
Commencez par la propriété html de HtmlView et le chemin de binding Angular [html] ; l'échec signalé est value.search is not a function lorsqu'une valeur approuvée par DomSanitizer est fournie. Reproduisez-le avec le HTML KaTeX fourni et vérifiez que c'est terminé en le rendant sans l'exception ni l'avertissement de valeur sûre, tout en préservant le balisage attendu.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
- CLI: "@angular/compiler-cli": "~18.0.0",
- Cross-platform modules:
- Android Runtime: "@nativescript/android": "8.8.1-next.2024-07-19-10014251437",
- iOS Runtime:
- Plugin(s): "katex": "^0.16.11",, "@types/katex": "^0.16.7",
- NativeScript-Angular: "@nativescript/angular": "^18.0.0",
- Angular: "@angular/core": "~18.0.0",
Describe the bug
I created unsafe html string using
this._safeHtml = this.domSanitizer.bypassSecurityTrustHtml(htmlString);
Attempting to render this content using Html View using property binding like so
<HtmlView [html]="_safeHtml"></HtmlView>
results to the following error
An uncaught Exception occurred on "main" thread.
Calling js method onCreateView failed
TypeError: value.search is not a function
StackTrace:
[html:setNative]...
NB:
- Using the approach below:
<HtmlView html="{{_safeHtml}}"></HtmlView>
does not render the string(latex string) as expected and also throws a
safevalue must use [property]=binding error on the screen.
- The string renders as expected in pure angular project using the following code:
<div [innerHTML]="_safeHtml"></div>
A sample string to be rendered looks like so
<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>s</mi><mi>u</mi><msubsup><mi>m</mi><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></msubsup><mo stretchy="false">(</mo><msubsup><mi>x</mi><mi>i</mi><mn>2</mn></msubsup><mo>−</mo><mi>o</mi><mi>v</mi><mi>e</mi><mi>r</mi><mi>l</mi><mi>i</mi><mi>n</mi><mi>e</mi><msup><mi>x</mi><mn>2</mn></msup><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">sum_{i=1}^n(x_i^2 - overline{x}^2)</annotation></semantics></math></span>
What could be a recommended way to solve this situation or a walkaround?
To Reproduce
Expected behavior
Sample project
Additional context
- Langage dominant
- TypeScript
- Étoiles
- 55
- Forks
- 13
- Merge moyen
- 16 min
- PR mergées (30 j)
- 1
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NativeScript/angular
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
NativeScript/angular#170 · 1 commentaire ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
NativeScript/angular#164 ·
-
My types are gone Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 45/100
NativeScript/angular#163 · 1 commentaire ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 38/100
NativeScript/angular#158 · 1 réaction ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
NativeScript/angular#155 ·
Toutes les issues de NativeScript/angular
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
-
Add: Star Sports 2 Telugu HD Ouvertecheck:passed streams:add
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100