feat(reader): add optional justified EPUB body text - #686
Merged
codedogQBY merged 3 commits intoAug 17, 2026
Merged
Conversation
cha1latte
marked this pull request as ready for review
August 16, 2026 19:28
k6G52m4Dz75W
added a commit
to k6G52m4Dz75W/ReadAny
that referenced
this pull request
Sep 10, 2026
… br scan Replace the DOM-scan justified-text.js (PR codedogQBY#686) with a light, cross-platform strategy shared by mobile WebView and desktop foliate: - CSS fallback in @layer readany-justify: body { text-align: justify } is the default, but unlayered book styles always win, so author alignment can never be overridden. :where() keeps specificity at 0. - :where(*:has(> br)) { text-align: start } so direct-br poetry/lyrics lines are not stretched; using :has(> br) (direct child) avoids cascading start onto unrelated siblings of a br-bearing outer container. - Code/tables/captions/forms excluded with text-align: start. - A tiny JS pass reads the computed alignment of only br-bearing block-level elements and pins author-aligned ones (center/right/end, however expressed) inline, so the book's alignment survives our start rule. Pins are tagged and un-pinned on disable (clean undo) or on vertical/fixed layouts. - Vertical/fixed documents are tagged data-readany-vertical (via getDirection on desktop, isVerticalDoc on mobile) so the justify CSS scopes to horizontal text. - justifyBodyText setting retained (default on); when off the layer is not injected.
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
Why
Body alignment is currently controlled entirely by each EPUB, so readers cannot request consistent justified prose. This adds that control without overriding content whose layout or alignment is intentional.
Validation
pnpm --filter @readany/core test— 584 passedpnpm --filter @readany/app-expo test— 9 passedpnpm --filter @readany/app-expo exec tsc --noEmitpnpm --filter @readany/app-expo build:readernode --check packages/app-expo/assets/reader/justified-text.jsgit diff --checkThe Android device proof used the Shlai integration APK built by GitHub Actions from commit
da63ccd79fda3216b20caf7e15bed5408654f742(run 31965394987), which contains this PR unchanged.