Skip to content

fix(components): text boxes keep paragraph breaks and non-Latin headings get ToC anchors - #304

Merged
sydevs-bot merged 3 commits into
mainfrom
claude/fix-text-box-paragraphs-and-anchors
Nov 20, 2026
Merged

sydevs-bot merged 3 commits into
mainfrom
claude/fix-text-box-paragraphs-and-anchors

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Visitors reading Bulgarian, Ukrainian, Russian, Greek, Armenian or Persian pages can now link to a heading. Before this change, a heading in those scripts had no id, so nothing could link to it, and a ToC entry for one rendered href="#", which only jumped to the top of the page. Now the heading's anchor uses its own letters (#какво-е-кундалини, #τα-οφέλη-του-διαλογισμού), and a ToC entry links to that anchor. No live page carries both a ToC block and a non-Latin heading today, so the ToC half of this reaches visitors once an editor adds one.
  • Latin anchors do not change. Every heading written in Latin letters keeps exactly the anchor it had, so links that were already shared, and # links that editors typed, still work. An emoji, a keycap or the micro sign in a Latin heading still never ends up in its anchor.
  • Editors: a line break in a text box's text now starts a new paragraph, whichever style is picked (white box, ornate or overlay). Before, only the ornate box split paragraphs. The white box and the overlay showed several paragraphs as one run-on block. A box with a single paragraph renders exactly as before.
  • Developers: lib/paragraphs.ts (toParagraphs) is now the one paragraph rule for ContentTextBox, ContentOverlay and OrnateTextBox. lib/slugify.ts is still the single function shared by the heading converter and the ToC block, so heading ids and ToC links always match. The ContentTextBox Ladle story has a new "Paragraphs" section.

Findings addressed

  • F8a (the non-Latin part): slugify returned '' for Cyrillic, Greek, Armenian and Persian.
    • Evidence: on origin/main, lib/slugify.ts:22 kept only [a-z0-9]. Both callers use this function: components/molecules/blocks/TableOfContents/TableOfContents.tsx:46 (href={#${anchor}}) and components/organisms/RichText/RichText.tsx:107 (the heading id).
    • Measured over every live SahajCloud heading and ToC entry in 19 locales (3,046 entries): 121 are non-Latin, in bg, el, hy, ru and uk. On main, 112 of them had no anchor and 9 kept only their digits (1, 2018). With this branch, none of them has an empty anchor.
    • The 2,925 entries written only in Latin or script-neutral characters keep their exact anchors.
    • I also compared the rule itself with main's. Every Latin, Common and Inherited code point gives the same anchor as on main, alone and in context, and so do 300,000 random strings made of those code points.
    • No live Persian content exists yet, so Persian is covered by synthetic cases: a ZWNJ splits a word, Persian digits are kept, and آ keeps its mark.
    • How the new rule works:
      • Each Latin or script-neutral character is folded on its own, the way main folds it. This happens before the text is decomposed, so µ and ℵ never turn into a Greek or a Hebrew letter.
      • A combining mark is kept only when it follows a letter of another script, so й stays й and ά stays ά.
      • Armenian marks written inside a word (Ի՞նչ) are dropped instead of splitting the word.
    • Tests:
      • New lib/slugify.test.ts. The Latin cases are taken from live headings, plus a separate set for emoji, keycaps and µ. There are also non-Latin cases and cases that give no anchor.
      • TableOfContents.test.tsx: "links a heading in a non-Latin script to its anchor, not to "#"".
      • RichText.test.tsx: "anchors a non-Latin heading, and the table of contents links to the same id".
      • The non-Latin cases fail on main. The emoji, keycap and µ cases fail on the branch's first version of the fix (4430b06).
  • F15j / fix(textbox): a multi-paragraph text box renders as one block #286: text-box paragraph breaks were handled one way in OrnateTextBox and not at all in ContentTextBox and ContentOverlay (string input).
    • Evidence: on origin/main, ContentTextBox.tsx:140 rendered description in a single <p>, and ContentOverlay.tsx:114 wrapped a string as [text].
    • Now all three call toParagraphs (lib/paragraphs.ts:10). It splits on every run of line breaks, trims each paragraph, and drops empty ones. That is the rule OrnateTextBox already used.
    • Why a single line break counts: the only live text with a single line break (the overlay on /mooladhara-chakra) uses it to start each tip.
    • Measured over all 40 live English text-box blocks, rendered through the converter: 37 are byte-identical. The multi-paragraph /mooladhara-chakra overlay now splits, as intended. Two overlays with no text (app-privacy-policy, meditate-america) lose an empty <p class=""> that drew nothing.
    • Tests:
      • New lib/paragraphs.test.ts.
      • ContentTextBox.test.tsx and ContentOverlay.test.tsx pin the exact single-paragraph <p> markup. These pass before and after the change. They also check that two paragraphs render as two <p> elements; that check fails on main.
      • blockConverters.test.tsx adds "paragraph breaks", which covers the white-box, ornate and overlay styles. The white-box and overlay cases fail on main.

Not in this PR

  • Where an anchor's spelling comes from is fix(rich-text): two headings that slugify alike share one anchor id #266, not this PR. On this thread the reviewer chose a separate ticket over changing this PR, so it no longer holds the merge. SahajCloud stores a slug on each ToC entry, computed with the slugify package, but nothing upstream stamps an id on the heading itself, so the id is derived here whichever rule wins. Measured on the live content: the stored slug already equals this branch's anchor on 1,103 of 1,135 ToC entries, and the 32 that differ are & (terms-and-conditions) and a decimal point (81-what-we-share). Adopting the package here would move 66 of 1,789 live Latin anchors, cut all 12 live Armenian headings to stubs (Մաս 1. Ուղիներ → m-1) and collide two headings on one page.
  • Latin letters with no ASCII decomposition (ß, œ, ł, ø, Turkish ı) still split a word, for example çıkış → c-k-s. This is on purpose: changing it would change Latin anchors that already exist. Folding them (ß → ss, ı → i) would be a separate decision.
  • Headings with no letter or digit at all (only punctuation or only emoji) still have no anchor, and their ToC entry still renders href="#". No live heading looks like this.
  • The ohm sign (U+2126) is Greek script in Unicode, so it stays in an anchor as ω, the same as any Greek letter.
  • Duplicate headings are handled in fix(rich-text): two headings that slugify alike share one anchor id #266. The approach decided there is the upstream occurrence field that chore(contracts): re-sync copied contracts from SahajCloud #292 brings in.
  • subtitle in ContentTextBox stays a single <p>. It is a one-line field, and the fix(textbox): a multi-paragraph text box renders as one block #286 acceptance criteria cover only the body text.
  • PR preview checks for the fix(textbox): a multi-paragraph text box renders as one block #286 checklist are still to do once CI has built this PR: the Ladle story should show two paragraphs, and the home page text boxes should read as before.
  • No new translation key. This PR adds no visible string.

Reconciled with open PRs

Closes #286

Notes for reviewer

  • Which rule spells a heading's anchor went to fix(rich-text): two headings that slugify alike share one anchor id #266, the open ticket for
    duplicate heading ids: the same files, and the same requirement that existing ids not move. It
    carries the question as open question 1, with three options and a recommendation, so
    @sydevs-bot implement there waits until it is answered.
  • Added there from this review: SahajCloud already mints the layout block's tab anchors with the
    slugify package (src/lib/richEditor/blocks/LayoutBlock.ts:12) and this repo renders them as a
    link href (LayoutBlock.tsx:139), while the heading id they would land on is spelled by
    lib/slugify.ts. The stored TocHeading.slug is read by nothing.
  • This PR keeps deriving the anchor here, which is what fix(rich-text): two headings that slugify alike share one anchor id #266 question 1 would
    revisit.

Test results

Lean gate (.claude/skills/pr-prep/check.sh) on the head commit:

  • Lint: 0 errors, 1,084 warnings, the same count as the origin/main baseline.
  • tsc --noEmit: passed.
  • Vitest: 131 files, 1,274 of 1,274 tests passed.
  • pnpm build: not run, because this bundle is not a build bundle.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw

…ts no anchor

`slugify` kept only a-z and 0-9, so every heading in a non-Latin script
collapsed to '': the RichText heading converter emitted no `id`, and the
table of contents linked each such entry to `href="#"`, which scrolls to
the top. Of the 121 non-Latin headings live in SahajCloud today (bg, el,
hy, ru, uk), 112 had no anchor at all and nine kept only their digits.

Letters, marks and digits of any other script now stay in the anchor,
lowercased, with everything else collapsing to "-". A Latin letter still
folds its diacritics (é becomes e); a letter of another script keeps its
marks (й stays й, ά stays ά), recomposed with NFC. Armenian writes its
question, exclamation and emphasis marks inside the word (Ի՞նչ), so those
drop rather than split it.

Latin output is unchanged on purpose: an anchor already in a shared link
or an editor's `#` link has to keep resolving. Latin and script-neutral
characters outside a-z and 0-9 still separate, so ß, ı, œ and ł split a
word exactly as before. Across all 2,924 Latin headings live in
SahajCloud the old and new anchors are byte-identical, and the new spec
pins a sample of them.

Two equal headings still share one id; that is #266, which waits on the
upstream `occurrence` field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The `textbox` block reaches one of three organisms, and they treated a
paragraph break three ways. OrnateTextBox split its text into one <p>
per paragraph; ContentTextBox and ContentOverlay rendered the whole
string in a single <p>, so the breaks SahajCloud stores collapsed into
one run of text. ContentOverlay could already render an array of
paragraphs, but the converter hands it a string.

OrnateTextBox's split moves to `lib/paragraphs.ts` and all three render
through it, so a break reads the same whichever style an editor picks.
Every run of line breaks starts a paragraph, not only a blank line: that
is the rule OrnateTextBox already shipped, and the one live text that
uses a single break (/mooladhara-chakra's overlay) uses it to start each
tip. ContentTextBox's paragraphs sit directly in its gap-6 column, which
spaces them at 1.5rem, prose-lg's paragraph margin for this text size.

Single-paragraph text renders byte-identical: of the 40 English text
boxes live in SahajCloud, 37 render exactly as before. The other three
are /mooladhara-chakra's multi-paragraph overlay, and two overlays with
no text, which lose an empty <p class=""> that drew nothing. An empty
description no longer leaves an empty <p> in ContentTextBox's column
either (no live side box has one).

The ContentTextBox story gains a two-paragraph example.

Closes #286.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
…it was

Keeping a non-Latin letter's marks let every other combining mark
through as well. Only U+0300-036F was handled, and the separator never
matches a mark, so an emoji's variation selector or keycap and a mark
such as U+20D7 after a Latin letter stayed in the id: "We ❤️ meditation"
became "we-<U+FE0F>-meditation", an emoji-only heading got an invisible
id instead of none, and "🧘‍♀️ Yoga" an id that starts with U+FE0F. The
script check also ran after NFKD, so µ and ℵ were already Greek and
Hebrew letters and stayed in a Latin heading's anchor.

Each Latin or script-neutral character now folds on its own before the
text decomposes, exactly as every anchor was spelled before. A run of
marks is kept only after a letter of another script, and otherwise
folds the same way. Over every string made only of Latin, Common and
Inherited code points (each one alone and in context, plus 300,000
random strings), the result equals origin/main's. Over all 3,046 live
headings and ToC entries in 19 locales, no anchor differs from the
previous commit's, and none of the 121 non-Latin headings is empty.

The ohm sign (U+2126) is Greek script in Unicode, so it stays as ω like
any other Greek letter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web 6ac4922 Commit Preview URL

Branch Preview URL
Nov 19 2026, 09:25 PM

Comment thread lib/slugify.ts Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 23:49Z address-review · attempt 1 · session · done
  • 23:49Z address-review · attempt 1 · session
  • 22:43Z address-review · attempt 1 · session · done
  • 22:43Z address-review · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Review answered. Nothing pushed: the one ask is a question, and I built nothing on a guess.

Thread — a slug library, or SahajCloud's slug — answered, left open. Nothing upstream stamps a heading id, so the id is derived here whichever rule wins. Measured on live content: SahajCloud's own slugify would move 66 of 1,789 Latin anchors and cut all 12 Armenian headings to stubs (Մաս 1. Ուղիներ → m-1). Two options are in the thread; the choice is yours, and it holds the merge.

origin/main merged into the branch cleanly and kept local — pushing it alone would only re-run CI.

PR body: the first bullet claimed non-Latin readers can now use the table of contents. No live page carries both a ToC block and a non-Latin heading, so today's gain is the heading anchor itself. Corrected, with the measurements under Not in this PR.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Review answered. Nothing pushed: the ask was answered B, which is a ticket, not a code change.

Thread — a slug library, or SahajCloud's slug — resolved. The work joins #266, the open ticket for duplicate heading ids: the same files, and the same requirement that existing ids not move. It now carries the choice as open question 1, so implement there waits on your answer. That is the cost of joining rather than filing new — #266 was ready to build and is not until question 1 is settled.

Found while grounding it, added to #266 and to the body: SahajCloud already spells the layout block's tab anchors with the slugify package, while the heading id they land on is spelled here. The stored TocHeading.slug is read by nothing.

PR body: the Not in this PR bullet no longer says the thread holds the merge, and ## Notes for reviewer links #266.

origin/main merged cleanly into the branch, 8 commits, kept local — pushing it alone would only re-run CI.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 20, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-design 6ac4922 Commit Preview URL

Branch Preview URL
Nov 19 2026, 09:25 PM

@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit c13f333 Nov 20, 2026
48 of 50 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-text-box-paragraphs-and-anchors branch November 20, 2026 00:55
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 20, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 20, 2026
#304 merged, so lib/paragraphs.ts arrived on main as an add/add conflict.
Both sides hold the same function; kept this branch's doc comment, which
also names HeroQuote, now that HeroQuote renders through toParagraphs.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVUbtF4Dek2YdSL8fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(textbox): a multi-paragraph text box renders as one block

3 participants