linebender / linebender/parley
Full support for the CSS `white-space` property
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 736
- Forks
- 120
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 53
Description
The CSS white-space property is defined in sections 3 and 4 of the css-text-4 specification: https://drafts.csswg.org/css-text-4/#white-space-property. It is a very important property for accurately reproducing how browsers lay out text. And can also be used to account for differences between desired behaviour between editable and non-editable text around how whitespace is "hung" at the end of lines.
(the emojis in this issue were not generated by AI)
It is considered a "shorthand" property that decomposes into the following longhands:
✅ text-wrap-mode
This property has two variants: wrap and nowrap. nowrap disables wrapping entirely.
enum TextWrapMode {
Wrap,
NoWrap,
}
Status: fully implemented.
⚠️ white-space-collapse
This property controls:
- ⚠️ How whitespace is collapsed
- ❌ How whitespace at the end of the line is "hung" (or not hung)
enum WhiteSpaceCollapse {
Collapse,
Discard,
Preserve,
PreserveBreaks,
PreserveSpaces,
BreakSpaces,
}
See spec (https://drafts.csswg.org/css-text-4/#white-space-collapsing) for the meanings of each variant.
Status: we currently implement only the Collapse and Preserve variants in a somewhat hacky way in the TreeBuilder, and we also only implement the "white space collapsing" behaviour, and do not implement the different "whitespace hanging" behaviours (implementing the latter will require us to pass WhiteSpaceCollapse into layout as a style which we do not currently do).
See also: discussion on https://github.com/linebender/parley/pull/485 which attempted fixes for whitespace hanging behaviour.
⚠️ white-space-trim
Controls "whitespace trimming" at the beggining and end of spans.
enum WhiteSpaceCollapse {
DiscardBefore,
DiscardAfter,
DiscardInner,
}
Status: some basic trimming is implemented hackily in the TreeBuilder, but there are bugs in the current implementation. And it also doesn't allow full control over the trimming using a style.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with TreeBuilder::set_white_space_mode and its current Collapse/Preserve handling, then review the whitespace-hanging discussion in pull request 485. Compare the existing behavior with the CSS Text 4 white-space property, including white-space-collapse and white-space-trim. Done means supporting the specified variants, hanging behavior, and style-controlled trimming rather than only the current TreeBuilder shortcuts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, rust
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100