| name | mishnah-text-tweaks |
| description | Add or modify punctuation and text replacement rules in the Mishnah Hebrew or English text processing functions. Use when the user wants to tweak how Mishnah text is displayed โ changing commas to colons, periods to question marks, replacing transliterations, etc. |
Mishnah Text Tweaks
File
All rules live in client/src/lib/text-processing.ts:
- Hebrew rules:
processMishnahHebrewText() (~line 126)
- English rules:
processMishnahEnglishText() (~line 174)
How the Hebrew Processing Map Works
The function removes nikud first, then applies a chain of .replace() calls that transform punctuation. Rules are grouped by type:
Comma โ Colon (speech/attribution markers)
Patterns like ืืืืจ, โ ืืืืจ: and ืืืจ ืจืื X, โ ืืืจ ืจืื X:.
Used when a comma incorrectly separates a speaker from their statement.
Comma/Period โ Question Mark (interrogative phrases)
Patterns like (ืืืืื X), โ (ืืืืื X)? and (ืืืฆื X). โ (ืืืฆื X)?.
Used when a question phrase is incorrectly terminated with a comma or period instead of a question mark.
Comma โ Colon (structural markers)
Patterns like ืื ืืืื, โ ืื ืืืื:.
Used when a structural phrase introduces a rule or list.
How the English Processing Map Works
The function strips HTML, then applies replacements in three phases:
- Term replacements โ transliteration corrections (e.g.,
Joshua โ Yehoshua, Beth Hillel โ Beit Hillel)
- Punctuation corrections โ e.g.,
said, โ said:
- Line splitting โ splits on sentence-ending punctuation for line-by-line display (abbreviations like
i.e., e.g., R' are protected from splitting)
Adding a New Rule
Step 1: Identify the pattern type
The user will typically provide:
- The Hebrew/English phrase
- The current (wrong) punctuation
- The desired (correct) punctuation
- An example URL like
https://chavrutai.com/mishnah/Tractate/Chapter#Mishnah
Step 2: Choose the regex pattern
Fixed phrase (no variable words):
.replace(/ืื ืืืื,/g, 'ืื ืืืื:')
Phrase + variable trailing words (one or more words follow the phrase before the punctuation):
.replace(/(ืืืืื\s+[^,\n]+),/g, '$1?')
.replace(/(ืืืืืชื\s+[^.\n]+)\./g, '$1?')
Phrase + named element (e.g., rabbi name):
.replace(/ืืืจ ืจืื ([^,\n]+),/g, 'ืืืจ ืจืื $1:')
Step 3: Place the rule in the correct group
- Comma โ colon rules go with the other attribution/structural colon rules
- Comma/Period โ question mark rules go with the other interrogative rules
- If a phrase needs both comma and period variants, add both (comma variant first, period variant after)
Step 4: Watch for ordering
- More specific patterns must come before more general ones (e.g.,
ืืืจ ืื ืจืื X, before ืืืจ ืื, before ืืืจ,)
- If a phrase already has a comma variant and you're adding a period variant, place the period variant after the comma one
Existing Hebrew Rules Reference
Comma โ Colon
| Pattern | Example |
|---|
ืืืืจืื, | speakers say: |
ืืืืจ, | he says: |
ืืืจื ืื, | they said to him: |
(ืืืจื ืืื X), | they said to them X: |
ืืืจื ืืื, | they said to them: |
ืืืจ ืืื, | he said to them: |
ืืืจ ืื ืจืื X, | Rabbi X said to him: |
ืืืจ ืจืื X, | Rabbi X said: |
ืืืจ ืื, | he said to him: |
(ืืืจ X), | X said: |
ืืืจ, | he said: |
ืืืื ืื, | and these are: |
(ืืื X). | these X: |
ืฉื ื ืื, | the second to him: |
ืฉืืืฉื ืื, | the third to him: |
ืื ืืืื, | this is the rule: |
Comma/Period โ Question Mark
| Pattern | Example |
|---|
(ืืืืื X), | which is X? |
(ืืืืื X). | which is X? |
(ืืืืื ืืื X), | and which is X? |
(ืื ืืื X). | what is between X? |
(ืืืฆื X)[,.] | how does X? |
ืืืฆื. / ืืืฆื, | how? |
ืืื ืืืจืื ืืืืจืื, | in what case? |
ืืืืชื, | when? |
(ืืืืื X), | in which X? |
(ืืืืื X). | in which X? |
(ืืืืืชื X). | from when X? |
Existing English Rules Reference
Term Replacements
JoshuaโYehoshua, JudahโYehuda, YoseโYosei, IshmaelโYishmael, AkibaโAkiva, ZadokโTzadok, EleazarโElazar, Beth HillelโBeit Hillel, Beth ShammaiโBeit Shammai, R.โR', thyselfโyourself, thyโyour, Mt.โMount
Punctuation
said, โ said:
Testing
After adding a rule, visit the specific Mishnah URL the user provided to confirm the change renders correctly. The app hot-reloads on save.