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

Offen
#877 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@szydlovsky arbeitet bereits daran.

Seit 27.11.2026.

  • #889 von @szydlovsky — offen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
android, react-native
Bereich
mobile

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
Vorherrschende Sprache
C
Sterne
1.4k
Forks
80
Ø Merge
4 T. 19 Std.
Gemergte PRs (30 T.)
21

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus software-mansion/react-native-enriched-html

Alle Issues in software-mansion/react-native-enriched-html

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.