charlesLoder / havarotjs

A Typescript package for getting syllabic data about Hebrew text with niqqud.
https://www.npmjs.com/package/havarotjs
MIT License
12 stars 6 forks source link

Throwing error on two shevas and one with meteg #169

Closed charlesLoder closed 4 months ago

charlesLoder commented 4 months ago

In certain digital editions, a meteg may be found on a sheva that precedes another sheva — תִּזְֽכְּ֔רוּ

const text = new Text("תִּזְֽכְּ֔רוּ");
console.log(text.syllables.map((syl) => syl.text));

// /syllabifier.js:129
//       const prev = syl[0].text;
//                           ^

// TypeError: Cannot read properties of undefined (reading 'text')
//     at groupShevas (/Users/personal/Documents/code/havarotjs/dist/cjs/utils/syllabifier.js:129:27)
//     at groupClusters (/Users/personal/Documents/code/havarotjs/dist/cjs/utils/syllabifier.js:272:25)
//     at syllabify (/Users/personal/Documents/code/havarotjs/dist/cjs/utils/syllabifier.js:443:27)
//     at get syllables [as syllables] (/Users/personal/Documents/code/havarotjs/dist/cjs/word.js:117:56)
//     at /Users/personal/Documents/code/havarotjs/dist/cjs/text.js:131:42
//     at Array.map (<anonymous>)
//     at get syllables [as syllables] (/Users/personal/Documents/code/havarotjs/dist/cjs/text.js:131:23)
//     at Object.<anonymous> (/Users/personal/Documents/code/havarotjs/test.foo.js:13:18)
//     at Module._compile (node:internal/modules/cjs/loader:1376:14)
//     at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)

// Node.js v20.11.1

The intention of the meteg is unclear (see twitter thread and Adler's discussion).

Regardless of the meteg's intent, it should still syllabify correctly