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

オープン
#877 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@szydlovsky がすでに取り組んでいます。

2026年11月27日 から。

  • #889 @szydlovsky による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
android, react-native
領域
mobile

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
C
スター
1.4k
フォーク
80
平均マージ
4日 19時間
マージ済み PR(30日)
21

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

software-mansion/react-native-enriched-html のほかの issue

software-mansion/react-native-enriched-html の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。