| name | yerushalmi-text-tweaks |
| description | Add or modify punctuation rules in the Yerushalmi (Jerusalem Talmud) Hebrew text processing function. Use when the user wants to tweak how Yerushalmi text is displayed โ converting periods to colons, question marks, or exclamations for specific words and phrases. |
Yerushalmi Text Tweaks
File
All rules live in client/src/lib/text-processing.ts inside processYerushalmiHebrewText() (~line 48).
The function removes nikud first, then runs a chain of .replace() calls that convert periods (.) at the end of specific dialogue / discourse phrases into colons (:), question marks (?), or exclamations (!). Finally it calls processHebrewTextCore() for nikud removal + paragraph splitting.
Unlike the Mishnah processor (which handles comma โ colon because Sefaria's Mishnah text uses commas as soft breaks), the Yerushalmi processor is almost entirely period โ other punctuation, because Sefaria's Yerushalmi text uses periods as the only sentence-ending mark.
How the Hebrew Processing Chain Works
The chain is grouped by transformation type, and within each group more specific (longer) patterns come first to avoid shorter rules consuming the period before a longer rule can match.
Section order (top โ bottom)
- Speech / dialogue: period โ colon โ fixed phrases like
ืืืจ ืืื., ืืืจื ืื., ืืืจ ืืืจ.
- Fixed introductory phrases: period โ colon โ like
ืืืื ืืืจ., ืื ืืื., ืืื ืืืจื., [ืืื]?ืชื ืื ื.
- Multi-word attribution patterns: period โ colon โ patterns where a rabbi name (1โ6 words) sits between fixed markers, like
ืืืจ ืจืื [x]., ืืจืฉ ืจืื [x]., ืจืื [x] ืืฉื [x]., etc.
- Single-word speech markers (optional ื/ื/ื prefix): period โ colon โ like
[ืืื]?ืชื ื., [ืืื]?ืืืจ.
- Rhetorical / interrogative: period โ question mark โ like
ืืื., ืืื., ืื ืืขืฉื., ืื ื ืืืจื ืื.
- Vocative: period โ exclamation โ
ืจืื., ืจืืืชืื.
Boundary convention
Every rule uses the lookbehind (?<![ื-ืช]) to ensure no Hebrew letter precedes the match. This prevents ืืืจ. from matching the substring ืืืจ inside ืืืืจ. (which is a different word) or ืืืืจ. (which has a meaningful prefix).
The [ืืื]? prefix variant is the way to opt in to ื / ื / ื prefix matching for a given base word. Use it when the user explicitly mentions prefix variants (e.g. "ืชื ื / ืืชื ื / ืืชื ื / ืืชื ื") or when the established convention from prior rules makes the prefix variant the obvious choice.
Adding a New Rule
Step 1: Identify the pattern type
The user will typically provide:
- The Hebrew phrase
- The current (wrong) punctuation, almost always
.
- The desired (correct) punctuation:
:, ?, or !
- An example URL like
https://chavrutai.com/yerushalmi/Tractate/Chapter.Halakhah#Section
Step 2: Choose the regex pattern
Fixed phrase (no variable words):
.replace(/(?<![ื-ืช])ืืืื ืืืจ\./g, 'ืืืื ืืืจ:')
Word with optional ื / ื / ื prefix (e.g. ืชื ื / ืืชื ื / ืืชื ื / ืืชื ื):
.replace(/(?<![ื-ืช])([ืืื]?ืชื ื)\./g, '$1:')
Phrase + named element (e.g. rabbi name, 1โ6 Hebrew words, accepting both ืจืื and ืจื):
.replace(/(?<![ื-ืช])(ืืืจ\s+(?:ืจืื|ืจื)\s+(?:[ื-ืชืดืณ'\-]+\s+){0,5}[ื-ืชืดืณ'\-]+)\./g, '$1:')
(?:ืจืื|ืจื) โ alternation, longer alternative listed first
(?:[ื-ืชืดืณ'\-]+\s+){0,5}[ื-ืชืดืณ'\-]+ โ 1โ6 Hebrew word tokens (only Hebrew letters + geresh / gershayim / maqaf, never bare [^.\s]+, which over-matches punctuation-heavy tokens)
- The whole multi-word run is captured as
$1 and replayed with : instead of .
Sandwich pattern (rabbi name between two fixed markers, e.g. ืจืื [x] ืืืืจ.):
.replace(/(?<![ื-ืช])((?:ืจืื|ืจื)\s+(?:[ื-ืชืดืณ'\-]+\s+){0,5}[ื-ืชืดืณ'\-]+\s+ืืืืจ)\./g, '$1:')
Chain pattern (ืจืื [x] ืืฉื [x] ืืฉื [x]. โ multiple ืืฉื links):
.replace(/(?<![ื-ืช])((?:ืจืื|ืจื)\s+(?:[ื-ืชืดืณ'\-]+\s+){0,5}[ื-ืชืดืณ'\-]+\s+ืืฉื\s+(?:[ื-ืชืดืณ'\-]+\s+){0,5}[ื-ืชืดืณ'\-]+\s+ืืฉื\s+(?:[ื-ืชืดืณ'\-]+\s+){0,5}[ื-ืชืดืณ'\-]+)\./g, '$1:')
Step 3: Place the rule in the correct group
- Period โ colon (speech / dialogue) โ with the existing
ืืืจ ืืื. block
- Period โ colon (fixed intro) โ with the
ืืืื ืืืจ. / ืื ืืื. block
- Period โ colon (multi-word attribution) โ with the
ืืืจ ืจืื [x]. / ืืจืฉ ืจืื [x]. block
- Period โ colon (single-word with ื/ื/ื prefix) โ with the
[ืืื]?ืชื ื. block
- Period โ question โ with the
ืืื. / ืื ืขืื. block
- Period โ exclamation โ with the
ืจืื. / ืจืืืชืื. block
Step 4: Watch for ordering
Inside each group, more specific patterns must come before more general ones:
- 3-name
ืืฉื chain before 2-name ืืฉื โ otherwise the shorter pattern wins and the third name is left dangling.
ืื ื ืืืจื ืื. (โ ?) before ืืืจื ืื. (โ :) โ otherwise the colon rule fires first and the question-mark rule never sees a period.
- Multi-word
ืืืจ ืจืื [x]. before single-word [ืืื]?ืืืจ. โ same logic: the longer pattern needs first crack at the period.
Cross-group ordering also matters: the question-mark group runs after the colon group, but you can promote a question-mark rule into the colon group if it shadows a colon rule (e.g. ืื ื ืืืจื ืื. lives in the colon group so it pre-empts ืืืจื ืื.).
Existing Rules Reference
Period โ Colon (speech / dialogue)
| Pattern |
|---|
ืืืจ ืืื. |
ืืืจ ืืื. |
ืืืจืื ืืื. |
ืืืจืื. |
ืืืืจื ืื. |
ืืืจื ืื. |
ืืืจ ืื. |
ืืืฉ ืืืืจืื. |
ืืื ืื ืืชืื. |
ืืืจ ืืืจ. |
Period โ Colon (fixed introductory phrases)
| Pattern |
|---|
ืืืื ืืืจ. |
ืืื ืืืจ. |
ืืื ืื ืื ื ืงืืืืื. |
ืืื ืชืืืจ. |
ืืืชืื. |
ืื ืืื. |
ืืื ืืืจื. |
[ืืื]?ืชื ืื ื. |
Period โ Colon (multi-word attribution, [x] = 1โ6 Hebrew words, both ืจืื and ืจื accepted)
| Pattern |
|---|
ืจืื/ืจื [x] ืืฉื [x] ืืฉื [x]. |
ืจืื/ืจื [x] ืืฉื [x]. |
ืืืจ ืจืื/ืจื [x]. |
ืชื ื ืจืื/ืจื [x]. |
ืชื ื ืจืื/ืจื [x]. |
ืืจืฉ ืจืื/ืจื [x]. |
ืจืื/ืจื [x] ืืืืจ. |
ืจืื/ืจื [x] ืืขื. |
Period โ Colon (single-word, optional ื/ื/ื prefix)
| Pattern |
|---|
[ืืื]?ืชื ื. |
[ืืื]?ืืขื. |
[ืืื]?ืืขื. |
[ืืื]?ืชืืืจ. |
[ืืื]?ืืืืจืื. |
[ืืื]?ืืืืจ. |
[ืืื]?ืืืจ. |
Period โ Question Mark
| Pattern |
|---|
ืื ื ืืืจื ืื. (promoted into the colon group so it pre-empts ืืืจื ืื.) |
ืื ื ืืืจื ืื. (same) |
ืื ืขืื. |
ืื ืืขื. |
ืืื ืคืืืืื. |
ืืื ืืืื. |
ืืื ืืืื. |
ืื ืื ื ืงืืืืื. |
ืืื ืขืืืื. |
ืื ืืขืฉื. |
ืืื. |
ืืื. |
Period โ Exclamation
| Pattern |
|---|
ืจืื. โ ืจืื! |
ืจืืืชืื. โ ืจืืืชืื! |
Documenting the Change
After adding rules, update the "Yerushalmi Hebrew: Phrase-Level Punctuation Cues" entry in client/src/pages/changelog.tsx so the new patterns are listed in the appropriate bucket (period โ colon for speech / fixed phrase / attribution / single-word, period โ question, period โ exclamation). Keep the code samples as <code> tags styled consistently with the surrounding entries.
Testing
After adding a rule, visit the specific Yerushalmi URL the user provided to confirm the change renders correctly. The app hot-reloads on save.
For a quick offline sanity check, paste the new .replace(...) chain into a small Node script with sample inputs and confirm both positive cases (the rule fires) and negative cases (preceded by a Hebrew letter, the rule does not fire โ so ืืืื. should stay as ืืืื. if you only added ืืื.).