Skip to content

feat: support whiteSpace: 'pre-wrap' in prepareRichInline - #193

Open
ChuanfengZhang wants to merge 1 commit into
chenglou:mainfrom
ChuanfengZhang:main
Open

feat: support whiteSpace: 'pre-wrap' in prepareRichInline#193
ChuanfengZhang wants to merge 1 commit into
chenglou:mainfrom
ChuanfengZhang:main

Conversation

@ChuanfengZhang

Copy link
Copy Markdown

This allows rich text items to preserve leading and trailing spaces, mirroring the behavior of white-space: pre-wrap in CSS. Includes tests for the new mode and ensures backward compatibility with the default 'normal' mode.

This allows rich text items to preserve leading and trailing spaces, mirroring the behavior of white-space: pre-wrap in CSS. Includes tests for the new mode and ensures backward compatibility with the default 'normal' mode.
@Stubenhocker1399

Copy link
Copy Markdown

Is it expected that with these changes calls to measureRichInlineStats with a maxWidth set can be overflowed by long running sequences of spaces?

@ChuanfengZhang

Copy link
Copy Markdown
Author

Is it expected that with these changes calls to measureRichInlineStats with a maxWidth set can be overflowed by long running sequences of spaces?

Yes.

@Stubenhocker1399

Copy link
Copy Markdown

Would be really useful to support this without overflowing the set maximum width, as otherwise setting a maximum width loses its purpose.

@12joan

12joan commented Jul 2, 2026

Copy link
Copy Markdown

I'm not sure trailing white space on inline items is handled correctly at the moment even for the default white-space: normal mode.

In HTML, <u>Hello </u>world is rendered with an underline under the space, as you would expect. Pretext strips this space and replaces it with a gapBefore on world, so there's no underline on the space.

In addition, when rendering this Pretext output using HTML, the lack of a space character has a negative impact on accessibility and usability. For example, if you copy the content of https://chenglou.me/pretext/rich-note/ as plain text, you get this:

Ship@maya'srich-notecard oncepre-wraplands. Status
blockedbyvertical textresearch, but 北京 copy and Arabic QA
are both green ✅. KeepجاهزforCmd+Kdocs; the review bundle
now includes 中文 labels, عربي fallback, and one more launch
pass 🚀 forFri 2:30 PM. KeeplayoutNextLine()public, tag this
P1, keep3 reviewers, and route feedback todesign sync.

I'm not sure what the solution is, but it would probably be worth taking this into consideration before making any changes to how white space is handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants