mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #4489] [MERGED] Add right-to-left rendering support to the docs viewer #6397
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6397
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4489
Author: @kolacheee
Created: 8/2/2026
Status: ✅ Merged
Merged: 8/3/2026
Merged by: @kolacheee
Base:
staging← Head:agent/docs-rtl-viewer📝 Commits (5)
c029fb6Add right-to-left rendering support to the docs viewer8277c71Reference #4489 in the changelog entry52a7b53Merge branch 'staging' into agent/docs-rtl-viewer0885af1Merge branch 'staging' into agent/docs-rtl-viewer464518dMerge branch 'staging' into agent/docs-rtl-viewer📊 Changes
6 files changed (+151 additions, -32 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/client/src/components/modals/DocsViewerModal.tsx(+46 -18)📝
packages/client/src/lib/markdown.tsx(+12 -7)📝
packages/client/src/styles/globals.css(+37 -6)📝
packages/shared/src/constants/docs-languages.ts(+13 -0)📝
scripts/regressions/docs-language.regression.ts(+42 -1)📄 Description
Why
The Documentation Language roadmap has one language left: Arabic, the only right-to-left locale in the app's Language list. Rendering an RTL pack through today's viewer corrupts it in ways translators cannot write around — inside an RTL paragraph the bidi algorithm reorders code spans (
--flag valuerenders asflag value--,{{char}}as}}char{{), fences inheritdirection: rtland scramble whole lines, list markers sit on the opposite side of their padding, and search highlights sever Arabic cursive joining mid-word. This PR lands the viewer-side groundwork first, on its own, so it can be regression-tested against the eleven shipped LTR packs before a single Arabic word exists. The scoping investigation behind it covered 18 items; the Arabic pack itself follows as the usual per-languagedocs-i18ncycle once this merges.What
Shared (
packages/shared/src/constants/docs-languages.ts)DocsLanguageLabelgains an optionaldirectionfield ("ltr"/"rtl"); omitted means LTR, so the eleven existing rows are untouched.docsLanguageDirection(code)helper: unknown or unmarked codes read"ltr". Thearrow itself is not added here — it ships with the Arabic pack so the selector never offers a language whose pack does not exist yet.Markdown renderer (
packages/client/src/lib/markdown.tsx, shared with chat)dir="ltr"on the React-node path. The HTML string path deliberately carries nodirattribute: that path is re-sanitized bysanitizeChatHtml, whose attribute allowlist stripsdir(verified against the real DOMPurify config), so its LTR forcing lives in the stylesheet instead (below).diris intentionally NOT added to the sanitizer allowlist — that would let arbitrary card HTML flip text direction in chat.:---/---:separators now emits logicalstart/endinstead ofleft/right— identical in LTR, correct reading-order alignment in RTL.Styles (
packages/client/src/styles/globals.css)padding-inline-start,text-align: start,inset-inline-end)..mari-md-codeblockand.mari-md-inline-codeforcedirection: ltrin CSS — the only protection on the sanitized chat HTML path, and defence-in-depth everywhere else. Deliberately notext-alignon the fence:directionalone realigns it, and atext-alignwould override card/theme CSS that chat honors today.strongruns getunicode-bidi: isolatescoped to a new.docs-reader-contentclass so embedded LTR runs (English UI labels, URLs) cannot drag punctuation around inside RTL docs prose. Scoped rather than on the shared.mari-message-contentbecause isolation would change how existing RTL chat prose reorders..docs-search-markloses its0 0.1eminline padding with no substitute inset (native-find style): padding inside a word severs Arabic contextual letter forms and the lam-alef ligature at every highlight boundary, and a box-shadow replacement was measured to grow the tint vertically and double-paint where two marks abut. The docs reader also zeroes==highlight==padding (.docs-reader-content .mari-md-highlight) for the same shaping reason — chat keeps its padded look.Docs viewer (
packages/client/src/components/modals/DocsViewerModal.tsx)dirfromdocsLanguageDirection(doc.language)— keyed off the served doc, not the pack, so an untranslated English fallback inside an RTL pack stays LTR.dir="auto"; file paths and the on-disk root getdir="ltr"so ellipsis/truncation clip the correct end; the search input getsdir="auto"for caret and clear-button placement.pe-1,ps-6,text-start,border-s/ps-3). These matter independently of docs direction: the app already flips<html dir="rtl">under the Arabic UI locale, and the modal chrome mirrors with the rest of the app (kept deliberately — pinning the modal LTR inside a mirrored app would be incoherent).formatUpdatedAtnow formats with the UI locale (resolvedLanguageprecedent fromrelative-time.ts) instead of the browser locale, so the date always matches the language of the sentence around it.Regressions (
scripts/regressions/docs-language.regression.ts)docsLanguageDirectioncontract: unknown/null/non-Latin-but-LTR codes →ltr; a declaredrtlrow →rtl.doc.language(neverindex.language); the JSX code paths must carrydir="ltr"; and the two code CSS rules must keepdirection: ltr(the stylesheet is the only protection on the sanitized chat path).Deliberate visible deltas for existing packs (exactly three)
Everything else was verified as a rendering no-op for LTR packs and for chat, including by an adversarial review pass that measured candidate deltas in a live browser (that pass is what scoped the isolate rule away from chat, removed a redundant
text-align, and replaced the originally planned box-shadow inset with the no-inset highlight).What deliberately does NOT change
Search matching (already code-unit-literal and Arabic-safe), the server (no direction logic exists there), the language selectors, the chat sanitizer allowlist, the code-block Copy button (correct because fences are forced LTR), and the app-wide physical-CSS inventory outside this modal. The
arlabel-map row ships with the Arabic pack.Validation
pnpm regression:docs— passes (direction contract + source/CSS pins included).pnpm check— passes.:---/---:tables, task lists, arrow paths, lam-alef search probes) materialized in a throwawayDATA_DIR. DOM/computed-style assertions all pass: reader panertlfor the Arabic doc andltrfor the English fallback in the same pack; code spans byte-correct (--flag value,{{char}},{ "port": 7860 },7860-7870); list markers at inline start; table:---→start/---:→end with column 1 rightmost; searchكتابmatching insideالكتابwith shaping-safe marks; and under an Arabic UI locale the modal chrome mirrors (border-spaints right) while English content stays LTR.Summary by CodeRabbit
New Features
Bug Fixes
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.