Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed script vowels #145

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/syllable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ export class Syllable extends Node<Syllable> {
return noTaamim;
}

// for maters, we have to match the vowel character
const match = noTaamim.match(vowelsCaptureGroupWithSheva);
// for maters or text with mixed scripts (e.g. Hebrew and Latin), we have to extract the vowel character
const match = this.text.match(vowelsCaptureGroupWithSheva);
if (match && this.isVowelKeyOfSyllableCharToNameMap(match[0])) {
return match[0];
}
Expand Down
13 changes: 8 additions & 5 deletions test/syllable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe.each`
${"syllable with tsere-yod"} | ${"קָדְשֵׁ֧י"} | ${1} | ${"TSERE"} | ${true}
${"syllable with holam-vav"} | ${"בַּיּ֣וֹם"} | ${1} | ${"HOLAM"} | ${true}
${"syllable with hiriq-yod"} | ${"אָנֹֽכִי"} | ${2} | ${"HIRIQ"} | ${true}
${"syllable with mixed chars"} | ${"rˁִː֣"} | ${0} | ${"HIRIQ"} | ${true}
`("hasVowelName:", ({ description, hebrew, syllableNum, vowelName, result }) => {
const heb = new Text(hebrew);
const syllable = heb.syllables[syllableNum];
Expand Down Expand Up @@ -130,9 +131,10 @@ describe.each`
${"syllable with silent sheva"} | ${"הַֽ֭יְחָבְרְךָ"} | ${2} | ${"\u{05B8}"} | ${false}
${"syllable with none"} | ${"test"} | ${0} | ${null} | ${true}
${"syllable with shureq"} | ${"תִגְּע֖וּ"} | ${2} | ${"\u{05D5}\u{05BC}"} | ${false}
${"syllable with tsere-yod"} | ${"קָדְשֵׁ֧י"} | ${1} | ${"\u{05B5}"} | ${true}
${"syllable with holam-vav"} | ${"בַּיּ֣וֹם"} | ${1} | ${"\u{05B9}"} | ${true}
${"syllable with hiriq-yod"} | ${"אָנֹֽכִי"} | ${2} | ${"\u{05B4}"} | ${true}
${"syllable with tsere-yod"} | ${"קָדְשֵׁ֧י"} | ${1} | ${"\u{05B5}"} | ${false}
${"syllable with holam-vav"} | ${"בַּיּ֣וֹם"} | ${1} | ${"\u{05B9}"} | ${false}
${"syllable with hiriq-yod"} | ${"אָנֹֽכִי"} | ${2} | ${"\u{05B4}"} | ${false}
${"syllable with mixed chars"} | ${"rˁִː֣"} | ${0} | ${"\u{05B4}"} | ${false}
`("vowel:", ({ description, hebrew, syllableNum, vowel, allowNoNiqqud }) => {
// normally don't use `allowNoNiqqud` in testing, but needed to get `null`
const heb = new Text(hebrew, { allowNoNiqqud });
Expand All @@ -153,8 +155,9 @@ describe.each`
${"syllable with none"} | ${"test"} | ${0} | ${null} | ${true}
${"syllable with shureq"} | ${"תִגְּע֖וּ"} | ${2} | ${"SHUREQ"} | ${false}
${"syllable with tsere-yod"} | ${"קָדְשֵׁ֧י"} | ${1} | ${"TSERE"} | ${false}
${"syllable with holam-vav"} | ${"בַּיּ֣וֹם"} | ${1} | ${"HOLAM"} | ${true}
${"syllable with hiriq-yod"} | ${"אָנֹֽכִי"} | ${2} | ${"HIRIQ"} | ${true}
${"syllable with holam-vav"} | ${"בַּיּ֣וֹם"} | ${1} | ${"HOLAM"} | ${false}
${"syllable with hiriq-yod"} | ${"אָנֹֽכִי"} | ${2} | ${"HIRIQ"} | ${false}
${"syllable with mixed chars"} | ${"rˁִː֣"} | ${0} | ${"HIRIQ"} | ${true}
`("vowelName:", ({ description, hebrew, syllableNum, vowelName, allowNoNiqqud }) => {
// normally don't use `allowNoNiqqud` in testing, but needed to get `null`
const heb = new Text(hebrew, { allowNoNiqqud });
Expand Down