-
Notifications
You must be signed in to change notification settings - Fork 1
/
hadran.ts
25 lines (22 loc) · 1008 Bytes
/
hadran.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as fs from "fs";
import {Amud, Section as Segment} from "./apiTypes";
import {books, TalmudMasechet} from "./books";
import {stripHebrewNonletters} from "./hebrew";
export function hadranSegments(masechetName: string): Segment[] {
const masechet = books.byCanonicalName[masechetName] as TalmudMasechet;
const page = JSON.parse(
fs.readFileSync("precomputed_texts/hadran.json", {encoding: "utf-8"})) as Amud;
for (const segment of page.sections) {
segment.en = (segment.en as string).replace(/____/g, masechet.canonicalName);
segment.he = (segment.he as string).replace(
/<small>\(יאמר שם המסכת\)<\/small>/g, `<strong>${masechet.vocalizedHebrewName}</strong>`);
}
return page.sections;
}
const HADRAN_PATTERN = /^(<br>)*(<big><strong>|<strong><big>)?הדרן עלי?ך .*/;
export function isHadran(text: sefaria.TextType): boolean {
if (Array.isArray(text)) {
return isHadran(text[0]);
}
return HADRAN_PATTERN.test(stripHebrewNonletters(text));
}