Skip to content

Commit 245fbbd

Browse files
new parenthesis
1 parent e63aea4 commit 245fbbd

2 files changed

Lines changed: 38 additions & 25 deletions

File tree

packages/core/assets/models.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"type": "oracao",
55
"tom": "solene",
66
"optionalEnd": "<c><sp>R/</sp>.</c> A(g) mém.(gh) (::)",
7-
"optionalStart": "(c4) <c><sp>V/</sp>.</c> O(h)re(gh)mos.(h) (::)",
8-
"start": "(c4) <c><sp>V/</sp>.</c> ",
7+
"optionalStart": "(c4) <c><sp>V/</sp>.</c>() O(h)re(gh)mos.(h) (::)",
8+
"start": "(c4) <c><sp>V/</sp>.</c>() ",
99
"default": "(g) (hr hr hr) (g) (g) (hr1) (hr) (h) (::)",
1010
"patterns": [
1111
{
@@ -37,8 +37,8 @@
3737
"type": "oracao",
3838
"tom": "simples",
3939
"optionalEnd": "<c><sp>R/</sp>.</c> A(h) mém.(h) (::)",
40-
"optionalStart": "(c3) <c><sp>V/</sp>.</c> O(h) re(h) mos:(f) (::)",
41-
"start": "(c3) <c><sp>V/</sp>.</c> ",
40+
"optionalStart": "(c3) <c><sp>V/</sp>.</c>() O(h) re(h) mos:(f) (::)",
41+
"start": "(c3) <c><sp>V/</sp>.</c>() ",
4242
"default": "(h) (hr hr hr) (hr1) (dr) (d) (:)",
4343
"patterns": [
4444
{
@@ -74,8 +74,8 @@
7474
"type": "oracao",
7575
"tom": "simples",
7676
"optionalEnd": "<c><sp>R/</sp>.</c> A(h) mém.(h) (::)",
77-
"optionalStart": "(c3) <c><sp>V/</sp>.</c> O(h) re(h) mos:(h) (::)",
78-
"start": "(c3) <c><sp>V/</sp>.</c> ",
77+
"optionalStart": "(c3) <c><sp>V/</sp>.</c>() O(h) re(h) mos:(h) (::)",
78+
"start": "(c3) <c><sp>V/</sp>.</c>() ",
7979
"default": "(h) (hr hr hr) (hr1) (hr) (h) (:)",
8080
"patterns": [
8181
{
@@ -132,8 +132,8 @@
132132
"type": "prefacio",
133133
"tom": "solene",
134134
"optionalEnd": "",
135-
"optionalStart": "(c3) <c><sp>V/</sp>.</c> O(e) Se(f)nhor(g) es(g)te(g)ja(e) con(f)vos(gf)co.(f) (::) <c><sp>R/</sp>.</c> E(e)l{e~e}s(f)tá(g) no(g) mei(g)o(e) de(f) nós(gf) (::Z) <c><sp>V/</sp>.</c> Co(f)ra(g)ções(h) ao(g) al(fg)to.(fe) (::) <c><sp>R/</sp>.</c> O(g) nos(g)so(g) co(f)ra(g)ção(h) es(g)tá(f) em(g) Deus.(fe) (::Z) <c><sp>V/</sp>.</c> De(gf)mos(e) gra(ef)ças(g) ao(f) Se(g)nhor(hg) nos(fe)so(fg) Deus.(fgf) (::) <c><sp>R/</sp>.</c> É(f) nos(f)so(f) de(g)ver(h) e(g) nos(g)sa(f) sal(g)va(f)ção.(fe) (::Z) ",
136-
"start": "(c3) <c><sp>V/</sp>.</c> ",
135+
"optionalStart": "(c3) <c><sp>V/</sp>.</c>() O(e) Se(f)nhor(g) es(g)te(g)ja(e) con(f)vos(gf)co.(f) (::) <c><sp>R/</sp>.</c> E(e)l{e~e}s(f)tá(g) no(g) mei(g)o(e) de(f) nós(gf) (::Z) <c><sp>V/</sp>.</c>() Co(f)ra(g)ções(h) ao(g) al(fg)to.(fe) (::) <c><sp>R/</sp>.</c> O(g) nos(g)so(g) co(f)ra(g)ção(h) es(g)tá(f) em(g) Deus.(fe) (::Z) <c><sp>V/</sp>.</c>() De(gf)mos(e) gra(ef)ças(g) ao(f) Se(g)nhor(hg) nos(fe)so(fg) Deus.(fgf) (::) <c><sp>R/</sp>.</c> É(f) nos(f)so(f) de(g)ver(h) e(g) nos(g)sa(f) sal(g)va(f)ção.(fe) (::Z) ",
136+
"start": "(c3) <c><sp>V/</sp>.</c>() ",
137137
"default": "(g) (gr gr gr) (fe) (ef) (g) (fgr1) (fr) (f) (:)",
138138
"patterns": [
139139
{
@@ -153,8 +153,8 @@
153153
"type": "prefacio",
154154
"tom": "simples",
155155
"optionalEnd": "",
156-
"optionalStart": "(c3) <c><sp>V/</sp>.</c> O(f) Se(g)nhor(h) es(h)te(h)ja(f) con(g)vos(h)co.(g) (::) <c><sp>R/</sp>.</c> E(f)l{e~e}s(g)tá(h) no(h) mei(h)o(f) de(g) nós(hg) (::Z) <c><sp>V/</sp>.</c> Co(g)ra(h)ções(i) ao(h) al(g)to.(g) (::) <c><sp>R/</sp>.</c> O(h) nos(h)so(h) co(g)ra(h)ção(i) es(h)tá(g) em(h) Deus.(gf) (::Z) <c><sp>V/</sp>.</c> De(ih)mos(g) gra(h)ças(h) ao(h) Se(h)nhor(h) nos(f)so(g) Deus.(hg) (::) <c><sp>R/</sp>.</c> É(g) nos( g)so(g) de(h)ver(i) e(h) nos(h)sa(g) sal(h)va(g)ção.(gf) (::Z)",
157-
"start": "(c3) <c><sp>V/</sp>.</c> ",
156+
"optionalStart": "(c3) <c><sp>V/</sp>.</c>() O(f) Se(g)nhor(h) es(h)te(h)ja(f) con(g)vos(h)co.(g) (::) <c><sp>R/</sp>.</c> E(f)l{e~e}s(g)tá(h) no(h) mei(h)o(f) de(g) nós(hg) (::Z) <c><sp>V/</sp>.</c>() Co(g)ra(h)ções(i) ao(h) al(g)to.(g) (::) <c><sp>R/</sp>.</c> O(h) nos(h)so(h) co(g)ra(h)ção(i) es(h)tá(g) em(h) Deus.(gf) (::Z) <c><sp>V/</sp>.</c>() De(ih)mos(g) gra(h)ças(h) ao(h) Se(h)nhor(h) nos(f)so(g) Deus.(hg) (::) <c><sp>R/</sp>.</c> É(g) nos( g)so(g) de(h)ver(i) e(h) nos(h)sa(g) sal(h)va(g)ção.(gf) (::Z)",
157+
"start": "(c3) <c><sp>V/</sp>.</c>() ",
158158
"default": "(g) (gr gr gr) (e) (f) (gr1) (fr) (f) (:)",
159159
"patterns": [
160160
{
@@ -174,8 +174,8 @@
174174
"type": "bencao",
175175
"tom": "solene",
176176
"optionalEnd": "",
177-
"optionalStart": "(c4) <c><sp>V/</sp>.</c> ",
178-
"start": "(c4) <c><sp>V/</sp>.</c> ",
177+
"optionalStart": "(c4) <c><sp>V/</sp>.</c>() ",
178+
"start": "(c4) <c><sp>V/</sp>.</c>() ",
179179
"default": "(h) (hr hr hr) (g) (h) (hr1g) (gr) (g) (::)",
180180
"patterns": [
181181
{
@@ -229,8 +229,8 @@
229229
"name": "Evangelho tom A",
230230
"type": "leitura",
231231
"tom": "",
232-
"optionalEnd": "<c><sp>V/</sp>.</c>Pa(h)la(h)vra(h) da(h) Sal(f)va(h)ção.(h) (::) <c><sp>R/</sp>.</c> Gló(h)ri(h){a~a}(h) vós,(f) Se(h)nhor.(h) (::Z)",
233-
"optionalStart": "<c><sp>V/</sp>.</c> O(h) Se(h)nhor(h) es(h)te(h)ja(h) con(h)vos(h)co.(h) (::) <c><sp>R/</sp>.</c> E(h)le(h) es(h)tá(h) no(h) meio(h) de(h) nós.(h) (::Z)",
232+
"optionalEnd": "<c><sp>V/</sp>.</c>()Pa(h)la(h)vra(h) da(h) Sal(f)va(h)ção.(h) (::) <c><sp>R/</sp>.</c> Gló(h)ri(h){a~a}(h) vós,(f) Se(h)nhor.(h) (::Z)",
233+
"optionalStart": "<c><sp>V/</sp>.</c>() O(h) Se(h)nhor(h) es(h)te(h)ja(h) con(h)vos(h)co.(h) (::) <c><sp>R/</sp>.</c> E(h)le(h) es(h)tá(h) no(h) meio(h) de(h) nós.(h) (::Z)",
234234
"start": "(c4) ",
235235
"default": "(h) (hr hr hr) (f) (h) (h) (h) (:)",
236236
"patterns": [
@@ -282,8 +282,8 @@
282282
"type": "custom",
283283
"tom": "simples",
284284
"optionalEnd": "",
285-
"optionalStart": "(c4) <c><sp>V/</sp>.</c>",
286-
"start": "(c4) <c><sp>V/</sp>.</c>",
285+
"optionalStart": "(c4) <c><sp>V/</sp>.</c>()",
286+
"start": "(c4) <c><sp>V/</sp>.</c>()",
287287
"default": "(h) (hr hr hr) (::)",
288288
"patterns": [],
289289
"find": [],
@@ -294,8 +294,8 @@
294294
"type": "custom",
295295
"tom": "solene",
296296
"optionalEnd": "",
297-
"optionalStart": "(c4) <c><sp>V/</sp>.</c>",
298-
"start": "(c4) <c><sp>V/</sp>.</c>",
297+
"optionalStart": "(c4) <c><sp>V/</sp>.</c>()",
298+
"start": "(c4) <c><sp>V/</sp>.</c>()",
299299
"default": "(h) (hr hr hr) (::)",
300300
"patterns": [],
301301
"find": [],

packages/core/src/augustinus.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,28 @@ function applyModel(lyrics: string, gabcModel: string, psalm: boolean, doElision
6262
const taggedParts: string[] = [];
6363
const placeholder = "||TAGGEDPART||";
6464

65-
let deTaggedLyrics = lyrics.replace(/(<[^>]+>.*?<\/[^>]+>)/g, (match) => {
65+
let deTaggedLyrics = lyrics.replace(/(<[^>]+>)/g, (match) => {
6666
taggedParts.push(match);
6767
return placeholder;
6868
});
6969

7070
let wordsWithNotePlaceholders: string[] = deTaggedLyrics.split(/\s+/).filter(w => w).map(word => {
71-
if (word === placeholder) {
72-
return taggedParts.shift() || "";
71+
const processToken = (token: string) => {
72+
if (token === placeholder) {
73+
return taggedParts.shift() || "";
74+
}
75+
if (!/[a-zA-Z\u00C0-\u00FF]/i.test(token)) {
76+
return token;
77+
}
78+
const syllableArray = syllable(token).split(/(?<=@)/);
79+
const tonicIndex = syllableArray.length - tonic(syllableArray);
80+
return syllableArray.map((s, i) => (i === tonicIndex && !unstressedMonosyllables.includes(s)) ? "#" + s : s).join("") + "@";
7381
}
74-
const syllableArray = syllable(word).split(/(?<=@)/);
75-
const tonicIndex = syllableArray.length - tonic(syllableArray);
76-
return syllableArray.map((s, i) => (i === tonicIndex && !unstressedMonosyllables.includes(s)) ? "#" + s : s).join("") + "@";
82+
83+
if (word.includes(placeholder)) {
84+
return word.split(/(\|\|TAGGEDPART\|\|)/).filter(t => t).map(processToken).join("");
85+
}
86+
return processToken(word);
7787
});
7888

7989
let gabcOutput: string = "";
@@ -302,7 +312,10 @@ export default function generateGabc(input: string, modelObject: Model, paramete
302312
input = input.replace(/[0-9]/g, "");
303313
}
304314
if (parametersObject.removeParenthesis) {
305-
input = input.replace(/\(.*\)/g, "");
315+
input = input.replace(/\(.*?\)/g, "");
316+
} else {
317+
input = input.replaceAll("(", "<v>(</v>");
318+
input = input.replaceAll(")", "<v>)</v>");
306319
}
307320
let regexEndings: string = "([\\" + parametersObject.separator;
308321
for (let i = 0; i < modelObject.patterns.length; i++) {

0 commit comments

Comments
 (0)