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

未关闭
#877 1 条评论 0 个 reaction 已指派 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 小时
30 天内合并 PR
21

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

software-mansion/react-native-enriched-html 的其他 Issue

查看 software-mansion/react-native-enriched-html 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。