[Android] Leading and consecutive spaces are lost when HTML is parsed (iOS keeps them)

Ouverte
#877 1 commentaire 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@szydlovsky y travaille déjà.

Depuis le 27/11/2026.

  • #889 par @szydlovsky — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
android, react-native
Domaine
mobile

Piste de recherche

Start with the EnrichedParser.characters() method, which drops spaces that follow another space or a newline, and with the Android serializer that writes a raw space at the start of a paragraph. Run the example app's test screen with <html><p> a b </p><p> c</p></html> to reproduce the difference from iOS. The issue asks the maintainers to choose between keeping whitespace on Android and writing &nbsp; on both platforms, so confirm the direction before editing. Done means both platforms give the same output for that input and the round trip keeps the leading space.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Description

The same HTML gives different text on Android and iOS. Android drops a space at the start of a paragraph and collapses consecutive spaces. iOS keeps both.

This has two effects:

  1. A paragraph that starts with a space loses that space on a plain getHTML → setValue round trip on Android. Android itself serializes it as <p> a</p>.
  2. HTML written by iOS loses spaces when it is loaded on Android. iOS serializes two spaces as two raw spaces, Android reads them as one.
Steps to reproduce
  1. Open the example app and go to the test screen.
  2. Tap Set Value and submit <html><p> a b </p><p> c</p></html>.
  3. Tap Show HTML.
Output
iOS <p> a b </p><p> c</p>
Android <p>a b </p><p>c</p>

Round trip on Android only: type a (space, then a), read the HTML (<p> a</p>), set it back. The result is <p>a</p>.

Where it comes from

EnrichedParser.characters() ignores a space that follows another space or a newline. The Android serializer writes &nbsp; for consecutive spaces, so its own output survives for that case, but it writes a raw space at the start of a paragraph. The iOS serializer writes raw spaces in both cases.

Question

Which direction do you prefer?

  • Android keeps whitespace as written when it parses the library's own <html>…</html> format, or
  • both serializers write &nbsp; wherever a raw space would be collapsed.

I can open a PR for either one.

Environment
  • Library: main at 23cc179d
  • iOS 26.2 simulator (iPhone 17 Pro), Android API 30 emulator
Langage dominant
C
Étoiles
1.4k
Forks
80
Merge moyen
4 j 19 h
PR mergées (30 j)
21

Préparer son environnement

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de software-mansion/react-native-enriched-html

Toutes les issues de software-mansion/react-native-enriched-html

Issues similaires

Plus d'issues C

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.