[Android] Leading and consecutive spaces are lost when HTML is parsed (iOS keeps them)
维护者通常 2 天内回复
评估
- 难度
- 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 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:
- A paragraph that starts with a space loses that space on a plain
getHTML→setValueround trip on Android. Android itself serializes it as<p> a</p>. - 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
- Open the example app and go to the test screen.
- Tap Set Value and submit
<html><p> a b </p><p> c</p></html>. - 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 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
wherever a raw space would be collapsed.
I can open a PR for either one.
Environment
- Library:
mainat 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 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
software-mansion/react-native-enriched-html 的其他 Issue
-
[Web] Leading, trailing, and consecutive spaces in <p> and <codeblock> are stripped by setContent on mount / setValue可能已有人在做 @pcbeingused333 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
software-mansion/react-native-enriched-html#886 ·
维护者通常 2 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 74/100
software-mansion/react-native-enriched-html#885 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
software-mansion/react-native-enriched-html#881 · 1 条评论 ·
维护者通常 2 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 58/100
software-mansion/react-native-enriched-html#880 ·
维护者通常 2 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
software-mansion/react-native-enriched-html#878 ·
维护者通常 2 天内回复
查看 software-mansion/react-native-enriched-html 的全部 Issue
相似的 Issue
-
[Android Auto] MU1017 (MHI2Q_JP_AUG22_P1017) cluster map works with a pinned profile — values inside未关闭
难度 1/5 1 小时以内 新手友好度 92/100
kamgurgul/mib2q-carplay#74 ·
-
Claude:NotNeeded GPT:NotABug triage
难度 2/5 1-3 小时 新手友好度 78/100
open5gs/open5gs#5195 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
FriendsofECCE/ECCE#1358 ·
-
documentation needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
X11Libre/xserver#4255 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 84/100
antoxa2584x/nfsu2-sw#52 ·