Repository navigation
Add a line limit with tail truncation, and text alignment - #21
Merged
Merged
Conversation
Short text in cards and list rows must often stop after a few lines and end with an ellipsis, and some text must be centred. TranscriptKit always laid out every line at the leading edge. TranscriptStyle has lineLimit and textAlignment, and TranscriptText takes them from SwiftUI's .lineLimit(_:) and .multilineTextAlignment(_:). DocumentLayout stops at the limit and shortens the block at the cut. The last line shown is typeset again from the rest of its block and truncated with "…", or "…" is added when later blocks are left out. The layout's length ends at the cut, so selection and copying cover only what is shown. A table is shown whole or not at all. With a line limit, the growing end of a stream is drawn in tiles, so that nothing is drawn below the view. The alignment moves the lines of paragraphs and headings in their column. Lists, quotes, code and tables stay at the leading edge. Closes #4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Short text in cards and list rows must often stop after a few lines and end with an ellipsis, and some text must be centred.
TranscriptStyle.lineLimitandtextAlignment(TranscriptTextAlignment).TranscriptTextalso takes SwiftUI's.lineLimit(_:)and.multilineTextAlignment(_:).DocumentLayoutstops at the limit and shortens the block at the cut. The last line shown is typeset again from the rest of its block and truncated with "…", or "…" is added when later blocks are left out. The layout's length ends at the cut, so selection and copying cover only what is shown. A table is shown whole or not at all. A line-limited layout is not reused, because it may hold a shortened block.Closes #4.
Stack
This PR is part of a stack. It is based on #20 (
feature/style-fonts), so its diff shows only this change. Merge the stack in order, starting with #17.Tests
swift test: 136 tests pass..lineLimit(2)makes a 189 pt paragraph 45 pt tall, and.multilineTextAlignment(.center)moves the ink of "Short" from x = 1 to x = 151 in a 343 pt view.🤖 Generated with Claude Code