-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliturgia.js
66 lines (62 loc) · 1.91 KB
/
liturgia.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function parseLiturgia() {
let res = [];
let next = "";
let dal = false;
let rif = false;
let salmo = false;
let alleluia = false;
let risposta = "";
for (let line of liturgia.split("\n")) {
line = line.replace("[", "\\[");
line = next + line.trim();
next = "";
if (line == "Prima Lettura" ||
line == "Seconda Lettura" ||
line == "Vangelo") {
if (line != "Prima Lettura") {
res.push("---");
}
line = "#" + line;
next = "/";
dal = true;
salmo = false;
alleluia = false;
} else if (line == "Salmo Responsoriale") {
res.push("---");
line = "#" + line;
next = "## ";
dal = false;
rit = true;
salmo = true;
alleluia = false;
} else if (line == "Acclamazione al Vangelo") {
res.push("---");
line = "." + line;
alleluia = true;
} else if (alleluia && (line == "Alleluia, alleluia." || line == "Alleluia.")) {
line = "## " + line;
} else if (dal && line.startsWith("Dal")) {
dal = false;
rif = true;
if (line.includes("Vangelo")){
line = "## {croce}" + line;
} else {
line = "## " + line;
}
} else if (rif) {
rif = false;
res[res.length - 1] += " (" + line.replace(" ", "~") + ")";
line = "";
} else if (salmo && line.startsWith("R. ")) {
line = "/ {risposta} " + line.substr(3);
risposta = line;
} else if (salmo) {
if (line.endsWith("R.")) {
line = line.substr(0, line.length-2);
line += "\n" + risposta;
}
}
res.push(line);
}
return res.join("\n");
}