Skip to content

Add a line limit with tail truncation, and text alignment - #21

Merged
servercimen merged 1 commit into
feature/style-fontsfrom
feature/line-limit-alignment
Nov 20, 2026
Merged

servercimen merged 1 commit into
feature/style-fontsfrom
feature/line-limit-alignment

Conversation

@servercimen

@servercimen servercimen commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

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.lineLimit and textAlignment (TranscriptTextAlignment). TranscriptText also takes 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. A line-limited layout is not reused, because it may hold a shortened block.
  • With a line limit, the growing end of a stream is drawn in tiles, so nothing is drawn below the view.
  • The alignment moves the lines of paragraphs and headings. Lists, quotes, code and tables stay at the leading edge.

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

  • Five new unit tests: a paragraph cut to two lines with the ellipsis glyph on the second, a cut before later blocks, text within the limit unchanged, centred and trailing lines, and list items at the leading edge. swift test: 136 tests pass.
  • Checked on an iPhone 12 mini, iOS 27.0, through SwiftUI's modifiers. .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

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>
@servercimen
servercimen added this pull request to stack #26 November 20, 2026 18:15
@servercimen
servercimen merged commit c71b5f1 into main Nov 20, 2026
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.

Add a line limit with tail truncation, and text alignment

1 participant