chordsheetjs 13.2.2 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/module.js CHANGED
@@ -304,6 +304,7 @@ const $72b24102c7d826fd$export$4b194284baed1659 = 'verse';
304
304
  const $72b24102c7d826fd$export$609cc0ea1637d6a0 = 'part';
305
305
  const $72b24102c7d826fd$export$6a5a2eab72b6e3d = 'ly';
306
306
  const $72b24102c7d826fd$export$92249c36c213e508 = 'abc';
307
+ const $72b24102c7d826fd$export$5a2cf64ea612936a = 'textblock';
307
308
  const $72b24102c7d826fd$export$27c95a7104c1f7aa = 'symbol';
308
309
  const $72b24102c7d826fd$export$4d318981b5a83836 = 'numeric';
309
310
  const $72b24102c7d826fd$export$1321df9b16c30c6a = 'numeral';
@@ -2476,7 +2477,7 @@ const $4d72f408c2526a1c$var$PREFERS_FLAT_NUMBERS = [
2476
2477
  var $4d72f408c2526a1c$export$2e2bcd8739ae039 = $4d72f408c2526a1c$var$Key;
2477
2478
 
2478
2479
 
2479
- // Generated by peggy v. 5.0.6 (ts-pegjs plugin v. 3.1.0 )
2480
+ // Generated by peggy v. 5.1.0 (ts-pegjs plugin v. 3.1.0 )
2480
2481
  //
2481
2482
  // https://peggyjs.org/ https://github.com/metadevpro/ts-pegjs
2482
2483
  "use strict";
@@ -4135,7 +4136,7 @@ const $33f7017b34767c5f$export$98e6a39c04603d36 = $33f7017b34767c5f$var$peg$pars
4135
4136
  var $f0449e2486cb2372$export$2e2bcd8739ae039 = $f0449e2486cb2372$var$Chord;
4136
4137
 
4137
4138
 
4138
- // Generated by peggy v. 5.0.6 (ts-pegjs plugin v. 3.1.0 )
4139
+ // Generated by peggy v. 5.1.0 (ts-pegjs plugin v. 3.1.0 )
4139
4140
  //
4140
4141
  // https://peggyjs.org/ https://github.com/metadevpro/ts-pegjs
4141
4142
  "use strict";
@@ -5111,6 +5112,8 @@ const $a41c1115e2898cb2$export$4f5168acae064e01 = 'start_of_chorus';
5111
5112
  const $a41c1115e2898cb2$export$b7e6dcd848b88f43 = 'start_of_grid';
5112
5113
  const $a41c1115e2898cb2$export$634ff7795b596e62 = 'start_of_ly';
5113
5114
  const $a41c1115e2898cb2$export$8dd1111100e0e88d = 'start_of_tab';
5115
+ const $a41c1115e2898cb2$export$4252eb8e075f7d7a = 'start_of_textblock';
5116
+ const $a41c1115e2898cb2$export$f1e557abc415d751 = 'end_of_textblock';
5114
5117
  const $a41c1115e2898cb2$export$deca399f8cd9b7dc = 'start_of_verse';
5115
5118
  const $a41c1115e2898cb2$export$2b9510a208875fc9 = 'start_of_part';
5116
5119
  const $a41c1115e2898cb2$export$5895c693c74b9cf4 = 'subtitle';
@@ -5140,6 +5143,7 @@ const $20fa79e30605b67d$var$START_TAG_TO_SECTION_TYPE = {
5140
5143
  [(0, $a41c1115e2898cb2$export$b7e6dcd848b88f43)]: (0, $72b24102c7d826fd$export$e2b0b9a5e613f348),
5141
5144
  [(0, $a41c1115e2898cb2$export$634ff7795b596e62)]: (0, $72b24102c7d826fd$export$6a5a2eab72b6e3d),
5142
5145
  [(0, $a41c1115e2898cb2$export$8dd1111100e0e88d)]: (0, $72b24102c7d826fd$export$f1c9dd0f5207dd5e),
5146
+ [(0, $a41c1115e2898cb2$export$4252eb8e075f7d7a)]: (0, $72b24102c7d826fd$export$5a2cf64ea612936a),
5143
5147
  [(0, $a41c1115e2898cb2$export$deca399f8cd9b7dc)]: (0, $72b24102c7d826fd$export$4b194284baed1659)
5144
5148
  };
5145
5149
  const $20fa79e30605b67d$var$END_TAG_TO_SECTION_TYPE = {
@@ -5149,6 +5153,7 @@ const $20fa79e30605b67d$var$END_TAG_TO_SECTION_TYPE = {
5149
5153
  [(0, $a41c1115e2898cb2$export$4b28ac1ae75aff60)]: (0, $72b24102c7d826fd$export$e2b0b9a5e613f348),
5150
5154
  [(0, $a41c1115e2898cb2$export$e3f6cdbd95b1f8f)]: (0, $72b24102c7d826fd$export$6a5a2eab72b6e3d),
5151
5155
  [(0, $a41c1115e2898cb2$export$66a0ef3ffeab32b7)]: (0, $72b24102c7d826fd$export$f1c9dd0f5207dd5e),
5156
+ [(0, $a41c1115e2898cb2$export$f1e557abc415d751)]: (0, $72b24102c7d826fd$export$5a2cf64ea612936a),
5152
5157
  [(0, $a41c1115e2898cb2$export$640d294ab83f9040)]: (0, $72b24102c7d826fd$export$4b194284baed1659)
5153
5158
  };
5154
5159
  const $20fa79e30605b67d$var$SECTION_START_REGEX = /^start_of_(.+)$/;
@@ -5279,6 +5284,7 @@ const $b58c551853385714$var$DIRECTIVES_WITH_RENDERABLE_LABEL = [
5279
5284
  (0, $a41c1115e2898cb2$export$b7e6dcd848b88f43),
5280
5285
  (0, $a41c1115e2898cb2$export$634ff7795b596e62),
5281
5286
  (0, $a41c1115e2898cb2$export$8dd1111100e0e88d),
5287
+ (0, $a41c1115e2898cb2$export$4252eb8e075f7d7a),
5282
5288
  (0, $a41c1115e2898cb2$export$deca399f8cd9b7dc),
5283
5289
  (0, $a41c1115e2898cb2$export$2b9510a208875fc9)
5284
5290
  ];
@@ -6241,7 +6247,8 @@ var $4afcde69e7cb3e85$export$2e2bcd8739ae039 = $4afcde69e7cb3e85$var$Ternary;
6241
6247
  * @param {Song} song The song to be formatted
6242
6248
  * @returns {string} The ChordPro string
6243
6249
  */ format(song) {
6244
- const { lines: lines, metadata: metadata } = song;
6250
+ const { lines: lines } = song;
6251
+ const metadata = song.getMetadata(this.configuration);
6245
6252
  const { metadataLines: metadataLines, contentLines: contentLines } = this.separateMetadataFromContent(lines);
6246
6253
  const formattedMetadataLines = this.formatMetadataSection(metadataLines);
6247
6254
  const formattedContentLines = this.formatContentSection(contentLines, metadata);
@@ -6518,6 +6525,7 @@ var $7011f990fc73fda8$export$2e2bcd8739ae039 = $7011f990fc73fda8$var$Font;
6518
6525
  this.transposeKey = null;
6519
6526
  this.lineNumber = null;
6520
6527
  this.selector = null;
6528
+ this.selectorIsNegated = false;
6521
6529
  /**
6522
6530
  * The text font that applies to this line. Is derived from the directives:
6523
6531
  * `textfont`, `textsize` and `textcolour`
@@ -6766,7 +6774,7 @@ function $709af735c74ed550$var$appendValue(array, value) {
6766
6774
  * See {@link Metadata#get}
6767
6775
  */ class $709af735c74ed550$var$Metadata extends (0, $56f32ce29e8cb670$export$2e2bcd8739ae039) {
6768
6776
  constructor(metadata = {}){
6769
- super(), this.metadata = {};
6777
+ super(), this.metadata = {}, this.providers = new Map();
6770
6778
  if (metadata instanceof $709af735c74ed550$var$Metadata) this.assign(metadata.metadata);
6771
6779
  else this.assign(metadata);
6772
6780
  }
@@ -6799,6 +6807,9 @@ function $709af735c74ed550$var$appendValue(array, value) {
6799
6807
  value
6800
6808
  ];
6801
6809
  }
6810
+ setProvider(key, provider) {
6811
+ this.providers.set(key, provider);
6812
+ }
6802
6813
  set(key, value) {
6803
6814
  if (value) this.metadata[key] = value;
6804
6815
  else delete this.metadata[key];
@@ -6833,12 +6844,25 @@ function $709af735c74ed550$var$appendValue(array, value) {
6833
6844
  */ get(prop) {
6834
6845
  if (prop === (0, $a41c1115e2898cb2$export$430b1920f5feeae)) return this.calculateKeyFromCapo();
6835
6846
  if (prop in this.metadata) return this.metadata[prop];
6847
+ const provider = this.providers.get(prop);
6848
+ if (provider) return provider();
6836
6849
  return this.getArrayItem(prop);
6837
6850
  }
6838
6851
  /**
6839
- * Returns all metadata values, including generated values like `_key`.
6852
+ * Returns all metadata values, including provider values and generated values like `_key`.
6840
6853
  * @returns {Object.<string, string|string[]>} the metadata values
6841
6854
  */ all() {
6855
+ const all = {};
6856
+ this.providers.forEach((provider, providerKey)=>{
6857
+ const value = provider();
6858
+ if (value !== null) all[providerKey] = value;
6859
+ });
6860
+ Object.assign(all, this.metadata);
6861
+ const key = this.calculateKeyFromCapo();
6862
+ if (key) all[0, $a41c1115e2898cb2$export$430b1920f5feeae] = key;
6863
+ return all;
6864
+ }
6865
+ ownMetadata() {
6842
6866
  const all = {
6843
6867
  ...this.metadata
6844
6868
  };
@@ -6847,7 +6871,7 @@ function $709af735c74ed550$var$appendValue(array, value) {
6847
6871
  return all;
6848
6872
  }
6849
6873
  [Symbol.iterator]() {
6850
- return Object.entries(this.all())[Symbol.iterator]();
6874
+ return Object.entries(this.ownMetadata())[Symbol.iterator]();
6851
6875
  }
6852
6876
  /**
6853
6877
  * Returns a single metadata value. If the actual value is an array, it returns the first value. Else, it returns
@@ -6884,7 +6908,9 @@ function $709af735c74ed550$var$appendValue(array, value) {
6884
6908
  * Returns a deep clone of this Metadata object
6885
6909
  * @returns {Metadata} the cloned Metadata object
6886
6910
  */ clone() {
6887
- return new $709af735c74ed550$var$Metadata(this.metadata);
6911
+ const cloned = new $709af735c74ed550$var$Metadata(this.metadata);
6912
+ this.providers.forEach((provider, key)=>cloned.setProvider(key, provider));
6913
+ return cloned;
6888
6914
  }
6889
6915
  calculateKeyFromCapo() {
6890
6916
  const capoString = this.getSingle((0, $a41c1115e2898cb2$export$866f445d49bad88e));
@@ -6972,6 +6998,9 @@ function $ca405333ab46d462$var$getCommonValue(values, fallback) {
6972
6998
  const selectors = this.lines.map((line)=>line.selector).filter((selector)=>selector !== null);
6973
6999
  return $ca405333ab46d462$var$getCommonValue(selectors, null);
6974
7000
  }
7001
+ get selectorIsNegated() {
7002
+ return this.lines.some((line)=>line.selectorIsNegated);
7003
+ }
6975
7004
  /**
6976
7005
  * Indicates whether the paragraph contains lines with renderable items.
6977
7006
  * @see {@link Line.hasRenderableItems}
@@ -7147,6 +7176,7 @@ class $4132ae2381aed81f$var$SongBuilder {
7147
7176
  this.metadata = new (0, $709af735c74ed550$export$2e2bcd8739ae039)();
7148
7177
  this.sectionType = (0, $72b24102c7d826fd$export$c53d0f541b41b88e);
7149
7178
  this.selector = null;
7179
+ this.selectorIsNegated = false;
7150
7180
  this.transposeKey = null;
7151
7181
  this.warnings = [];
7152
7182
  this.song = song;
@@ -7164,16 +7194,17 @@ class $4132ae2381aed81f$var$SongBuilder {
7164
7194
  this.currentLine = new (0, $a449f9ee1c7acbe4$export$2e2bcd8739ae039)();
7165
7195
  this.lines.push(this.currentLine);
7166
7196
  }
7167
- this.setCurrentProperties(this.sectionType, this.selector);
7197
+ this.setCurrentProperties(this.sectionType, this.selector, this.selectorIsNegated);
7168
7198
  this.currentLine.transposeKey = this.transposeKey ?? this.currentKey;
7169
7199
  this.currentLine.key = this.currentKey || this.song.getMetadata().getSingle((0, $a41c1115e2898cb2$export$7167c830cefcb6b5));
7170
7200
  this.currentLine.lineNumber = this.lines.length - 1;
7171
7201
  return this.currentLine;
7172
7202
  }
7173
- setCurrentProperties(sectionType, selector = null) {
7203
+ setCurrentProperties(sectionType, selector = null, isNegated = false) {
7174
7204
  if (!this.currentLine) throw new Error('Expected this.currentLine to be present');
7175
7205
  this.currentLine.type = sectionType;
7176
7206
  this.currentLine.selector = selector;
7207
+ this.currentLine.selectorIsNegated = isNegated;
7177
7208
  this.currentLine.textFont = this.fontStack.textFont.clone();
7178
7209
  this.currentLine.chordFont = this.fontStack.chordFont.clone();
7179
7210
  }
@@ -7223,14 +7254,16 @@ class $4132ae2381aed81f$var$SongBuilder {
7223
7254
  startSection(sectionType, tag) {
7224
7255
  this.checkCurrentSectionType((0, $72b24102c7d826fd$export$c53d0f541b41b88e), tag);
7225
7256
  this.selector = tag.selector;
7257
+ this.selectorIsNegated = tag.isNegated;
7226
7258
  if (sectionType === (0, $72b24102c7d826fd$export$609cc0ea1637d6a0) && tag.value) this.sectionType = tag.value.split(' ')[0].toLowerCase();
7227
7259
  else this.sectionType = sectionType;
7228
- this.setCurrentProperties(sectionType, tag.selector);
7260
+ this.setCurrentProperties(sectionType, tag.selector, tag.isNegated);
7229
7261
  }
7230
7262
  endSection(sectionType, tag) {
7231
7263
  this.checkCurrentSectionType(sectionType, tag);
7232
7264
  this.sectionType = (0, $72b24102c7d826fd$export$c53d0f541b41b88e);
7233
7265
  this.selector = null;
7266
+ this.selectorIsNegated = false;
7234
7267
  }
7235
7268
  checkCurrentSectionType(sectionType, tag) {
7236
7269
  if (this.sectionType !== sectionType && !(sectionType === 'part' && tag.name === 'end_of_part')) this.addWarning(`Unexpected tag {${tag.originalName}}, current section is: ${this.sectionType}`, tag);
@@ -7754,6 +7787,33 @@ function $f5b90e5dc4871932$export$efb38dd75b8e2957({ selector: selector, isNegat
7754
7787
 
7755
7788
 
7756
7789
 
7790
+ function $05ed9bcf33bcd31b$var$formatDate(date) {
7791
+ const year = date.getFullYear();
7792
+ const month = String(date.getMonth() + 1).padStart(2, '0');
7793
+ const day = String(date.getDate()).padStart(2, '0');
7794
+ return `${year}-${month}-${day}`;
7795
+ }
7796
+ function $05ed9bcf33bcd31b$export$12c349605689fe7a() {
7797
+ const providers = new Map();
7798
+ providers.set('chordpro', ()=>'ChordPro');
7799
+ providers.set('chordpro.version', ()=>'14.0.0');
7800
+ providers.set('today', ()=>$05ed9bcf33bcd31b$var$formatDate(new Date()));
7801
+ return providers;
7802
+ }
7803
+ function $05ed9bcf33bcd31b$export$9b09a67f52000acf(configuration) {
7804
+ const providers = $05ed9bcf33bcd31b$export$12c349605689fe7a();
7805
+ const { instrument: instrument, user: user } = configuration;
7806
+ providers.set('instrument', ()=>instrument?.type ?? null);
7807
+ providers.set('instrument.type', ()=>instrument?.type ?? null);
7808
+ providers.set('instrument.description', ()=>instrument?.description ?? null);
7809
+ providers.set('tuning', ()=>instrument?.tuning ?? null);
7810
+ providers.set('user', ()=>user?.name ?? null);
7811
+ providers.set('user.name', ()=>user?.name ?? null);
7812
+ providers.set('user.fullname', ()=>user?.fullname ?? null);
7813
+ return providers;
7814
+ }
7815
+
7816
+
7757
7817
 
7758
7818
  /**
7759
7819
  * Represents a song in a chord sheet. Currently a chord sheet can only have one song.
@@ -7796,6 +7856,20 @@ function $f5b90e5dc4871932$export$efb38dd75b8e2957({ selector: selector, isNegat
7796
7856
  const expandedLines = this.lines.flatMap((line)=>(0, $3ac0d01fe66a7db4$export$2e2bcd8739ae039).expand(line, this));
7797
7857
  return this.selectRenderableItems(this.linesToParagraphs(expandedLines));
7798
7858
  }
7859
+ filterParagraphs(paragraphs, configuration) {
7860
+ const context = {
7861
+ configuration: configuration,
7862
+ metadata: this.metadata
7863
+ };
7864
+ return paragraphs.filter((paragraph)=>{
7865
+ const { selector: selector, selectorIsNegated: selectorIsNegated } = paragraph;
7866
+ if (!selector) return true;
7867
+ return (0, $f5b90e5dc4871932$export$efb38dd75b8e2957)({
7868
+ selector: selector,
7869
+ isNegated: selectorIsNegated
7870
+ }, context);
7871
+ });
7872
+ }
7799
7873
  linesToParagraphs(lines) {
7800
7874
  let currentParagraph = new (0, $ca405333ab46d462$export$2e2bcd8739ae039)();
7801
7875
  const paragraphs = [
@@ -8156,6 +8230,16 @@ Or set the song key before changing key:
8156
8230
  }
8157
8231
  getMetadata(configuration) {
8158
8232
  const metadata = new (0, $709af735c74ed550$export$2e2bcd8739ae039)();
8233
+ const providers = configuration ? (0, $05ed9bcf33bcd31b$export$9b09a67f52000acf)(configuration) : (0, $05ed9bcf33bcd31b$export$12c349605689fe7a)();
8234
+ providers.forEach((provider, key)=>metadata.setProvider(key, provider));
8235
+ const chords = ()=>this.getChords();
8236
+ metadata.setProvider('chords', ()=>{
8237
+ const c = chords();
8238
+ return c.length ? c.join(', ') : null;
8239
+ });
8240
+ metadata.setProvider('numchords', ()=>chords().length.toString());
8241
+ metadata.setProvider('key_actual', ()=>metadata.getSingle('_key') ?? metadata.getSingle('key'));
8242
+ metadata.setProvider('key_from', ()=>metadata.getSingle('key'));
8159
8243
  this.foreachItem((item)=>{
8160
8244
  if (!(item instanceof (0, $b58c551853385714$export$2e2bcd8739ae039))) return;
8161
8245
  const tag = item;
@@ -8539,7 +8623,7 @@ function $1582051153255182$export$ce8f3be11402ed10(items, chopFirstWord) {
8539
8623
  }
8540
8624
 
8541
8625
 
8542
- // Generated by peggy v. 5.0.6 (ts-pegjs plugin v. 3.1.0 )
8626
+ // Generated by peggy v. 5.1.0 (ts-pegjs plugin v. 3.1.0 )
8543
8627
  //
8544
8628
  // https://peggyjs.org/ https://github.com/metadevpro/ts-pegjs
8545
8629
  "use strict";
@@ -9121,31 +9205,35 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
9121
9205
  const peg$c151 = peg$literalExpectation("end_of_tab", false);
9122
9206
  const peg$c152 = "eot";
9123
9207
  const peg$c153 = peg$literalExpectation("eot", false);
9124
- const peg$c154 = peg$anyExpectation();
9125
- const peg$c155 = peg$otherExpectation("whitespace");
9126
- const peg$c156 = peg$otherExpectation("optional whitespace");
9127
- const peg$c157 = /^[ \t\n\r]/;
9128
- const peg$c158 = peg$classExpectation([
9208
+ const peg$c154 = "start_of_textblock";
9209
+ const peg$c155 = peg$literalExpectation("start_of_textblock", false);
9210
+ const peg$c156 = "end_of_textblock";
9211
+ const peg$c157 = peg$literalExpectation("end_of_textblock", false);
9212
+ const peg$c158 = peg$anyExpectation();
9213
+ const peg$c159 = peg$otherExpectation("whitespace");
9214
+ const peg$c160 = peg$otherExpectation("optional whitespace");
9215
+ const peg$c161 = /^[ \t\n\r]/;
9216
+ const peg$c162 = peg$classExpectation([
9129
9217
  " ",
9130
9218
  "\t",
9131
9219
  "\n",
9132
9220
  "\r"
9133
9221
  ], false, false);
9134
- const peg$c159 = peg$otherExpectation("space");
9135
- const peg$c160 = /^[ \t]/;
9136
- const peg$c161 = peg$classExpectation([
9222
+ const peg$c163 = peg$otherExpectation("space");
9223
+ const peg$c164 = /^[ \t]/;
9224
+ const peg$c165 = peg$classExpectation([
9137
9225
  " ",
9138
9226
  "\t"
9139
9227
  ], false, false);
9140
- const peg$c162 = /^[\n\r]/;
9141
- const peg$c163 = peg$classExpectation([
9228
+ const peg$c166 = /^[\n\r]/;
9229
+ const peg$c167 = peg$classExpectation([
9142
9230
  "\n",
9143
9231
  "\r"
9144
9232
  ], false, false);
9145
- const peg$c164 = "\n";
9146
- const peg$c165 = peg$literalExpectation("\n", false);
9147
- const peg$c166 = "\r";
9148
- const peg$c167 = peg$literalExpectation("\r", false);
9233
+ const peg$c168 = "\n";
9234
+ const peg$c169 = peg$literalExpectation("\n", false);
9235
+ const peg$c170 = "\r";
9236
+ const peg$c171 = peg$literalExpectation("\r", false);
9149
9237
  let peg$currPos = 0;
9150
9238
  let peg$savedPos = 0;
9151
9239
  const peg$posDetailsCache = [
@@ -11333,7 +11421,10 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
11333
11421
  s0 = peg$parseGridSection();
11334
11422
  if (s0 === peg$FAILED) {
11335
11423
  s0 = peg$parseLySection();
11336
- if (s0 === peg$FAILED) s0 = peg$parseTabSection();
11424
+ if (s0 === peg$FAILED) {
11425
+ s0 = peg$parseTabSection();
11426
+ if (s0 === peg$FAILED) s0 = peg$parseTextblockSection();
11427
+ }
11337
11428
  }
11338
11429
  }
11339
11430
  return s0;
@@ -12262,6 +12353,228 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
12262
12353
  }
12263
12354
  return s0;
12264
12355
  }
12356
+ function peg$parseTextblockSection() {
12357
+ let s0, s1, s2, s3, s4, s5, s6, s7;
12358
+ s0 = peg$currPos;
12359
+ s1 = peg$parseTextblockStartTag();
12360
+ if (s1 !== peg$FAILED) {
12361
+ s2 = peg$parseNewLine();
12362
+ if (s2 !== peg$FAILED) {
12363
+ s3 = peg$currPos;
12364
+ s4 = [];
12365
+ s5 = peg$currPos;
12366
+ s6 = peg$currPos;
12367
+ peg$silentFails++;
12368
+ s7 = peg$parseTextblockEndTag();
12369
+ peg$silentFails--;
12370
+ if (s7 === peg$FAILED) s6 = undefined;
12371
+ else {
12372
+ peg$currPos = s6;
12373
+ s6 = peg$FAILED;
12374
+ }
12375
+ if (s6 !== peg$FAILED) {
12376
+ s7 = peg$parseSectionCharacter();
12377
+ if (s7 !== peg$FAILED) {
12378
+ s6 = [
12379
+ s6,
12380
+ s7
12381
+ ];
12382
+ s5 = s6;
12383
+ } else {
12384
+ peg$currPos = s5;
12385
+ s5 = peg$FAILED;
12386
+ }
12387
+ } else {
12388
+ peg$currPos = s5;
12389
+ s5 = peg$FAILED;
12390
+ }
12391
+ while(s5 !== peg$FAILED){
12392
+ s4.push(s5);
12393
+ s5 = peg$currPos;
12394
+ s6 = peg$currPos;
12395
+ peg$silentFails++;
12396
+ s7 = peg$parseTextblockEndTag();
12397
+ peg$silentFails--;
12398
+ if (s7 === peg$FAILED) s6 = undefined;
12399
+ else {
12400
+ peg$currPos = s6;
12401
+ s6 = peg$FAILED;
12402
+ }
12403
+ if (s6 !== peg$FAILED) {
12404
+ s7 = peg$parseSectionCharacter();
12405
+ if (s7 !== peg$FAILED) {
12406
+ s6 = [
12407
+ s6,
12408
+ s7
12409
+ ];
12410
+ s5 = s6;
12411
+ } else {
12412
+ peg$currPos = s5;
12413
+ s5 = peg$FAILED;
12414
+ }
12415
+ } else {
12416
+ peg$currPos = s5;
12417
+ s5 = peg$FAILED;
12418
+ }
12419
+ }
12420
+ if (s4 !== peg$FAILED) s3 = input.substring(s3, peg$currPos);
12421
+ else s3 = s4;
12422
+ if (s3 !== peg$FAILED) {
12423
+ s4 = peg$parseTextblockEndTag();
12424
+ if (s4 !== peg$FAILED) {
12425
+ peg$savedPos = s0;
12426
+ s1 = peg$c128(s1, s3, s4);
12427
+ s0 = s1;
12428
+ } else {
12429
+ peg$currPos = s0;
12430
+ s0 = peg$FAILED;
12431
+ }
12432
+ } else {
12433
+ peg$currPos = s0;
12434
+ s0 = peg$FAILED;
12435
+ }
12436
+ } else {
12437
+ peg$currPos = s0;
12438
+ s0 = peg$FAILED;
12439
+ }
12440
+ } else {
12441
+ peg$currPos = s0;
12442
+ s0 = peg$FAILED;
12443
+ }
12444
+ return s0;
12445
+ }
12446
+ function peg$parseTextblockStartTag() {
12447
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8;
12448
+ s0 = peg$currPos;
12449
+ if (input.charCodeAt(peg$currPos) === 123) {
12450
+ s1 = peg$c43;
12451
+ peg$currPos++;
12452
+ } else {
12453
+ s1 = peg$FAILED;
12454
+ if (peg$silentFails === 0) peg$fail(peg$c44);
12455
+ }
12456
+ if (s1 !== peg$FAILED) {
12457
+ s2 = peg$parse_();
12458
+ if (s2 !== peg$FAILED) {
12459
+ if (input.substr(peg$currPos, 18) === peg$c154) {
12460
+ s3 = peg$c154;
12461
+ peg$currPos += 18;
12462
+ } else {
12463
+ s3 = peg$FAILED;
12464
+ if (peg$silentFails === 0) peg$fail(peg$c155);
12465
+ }
12466
+ if (s3 !== peg$FAILED) {
12467
+ s4 = peg$parseTagSelector();
12468
+ if (s4 === peg$FAILED) s4 = null;
12469
+ if (s4 !== peg$FAILED) {
12470
+ s5 = peg$parse_();
12471
+ if (s5 !== peg$FAILED) {
12472
+ s6 = peg$parseTagColonWithValue();
12473
+ if (s6 === peg$FAILED) s6 = null;
12474
+ if (s6 !== peg$FAILED) {
12475
+ s7 = peg$parse_();
12476
+ if (s7 !== peg$FAILED) {
12477
+ if (input.charCodeAt(peg$currPos) === 125) {
12478
+ s8 = peg$c29;
12479
+ peg$currPos++;
12480
+ } else {
12481
+ s8 = peg$FAILED;
12482
+ if (peg$silentFails === 0) peg$fail(peg$c30);
12483
+ }
12484
+ if (s8 !== peg$FAILED) {
12485
+ peg$savedPos = s0;
12486
+ s1 = peg$c65(s3, s4, s6);
12487
+ s0 = s1;
12488
+ } else {
12489
+ peg$currPos = s0;
12490
+ s0 = peg$FAILED;
12491
+ }
12492
+ } else {
12493
+ peg$currPos = s0;
12494
+ s0 = peg$FAILED;
12495
+ }
12496
+ } else {
12497
+ peg$currPos = s0;
12498
+ s0 = peg$FAILED;
12499
+ }
12500
+ } else {
12501
+ peg$currPos = s0;
12502
+ s0 = peg$FAILED;
12503
+ }
12504
+ } else {
12505
+ peg$currPos = s0;
12506
+ s0 = peg$FAILED;
12507
+ }
12508
+ } else {
12509
+ peg$currPos = s0;
12510
+ s0 = peg$FAILED;
12511
+ }
12512
+ } else {
12513
+ peg$currPos = s0;
12514
+ s0 = peg$FAILED;
12515
+ }
12516
+ } else {
12517
+ peg$currPos = s0;
12518
+ s0 = peg$FAILED;
12519
+ }
12520
+ return s0;
12521
+ }
12522
+ function peg$parseTextblockEndTag() {
12523
+ let s0, s1, s2, s3, s4, s5;
12524
+ s0 = peg$currPos;
12525
+ if (input.charCodeAt(peg$currPos) === 123) {
12526
+ s1 = peg$c43;
12527
+ peg$currPos++;
12528
+ } else {
12529
+ s1 = peg$FAILED;
12530
+ if (peg$silentFails === 0) peg$fail(peg$c44);
12531
+ }
12532
+ if (s1 !== peg$FAILED) {
12533
+ s2 = peg$parse_();
12534
+ if (s2 !== peg$FAILED) {
12535
+ if (input.substr(peg$currPos, 16) === peg$c156) {
12536
+ s3 = peg$c156;
12537
+ peg$currPos += 16;
12538
+ } else {
12539
+ s3 = peg$FAILED;
12540
+ if (peg$silentFails === 0) peg$fail(peg$c157);
12541
+ }
12542
+ if (s3 !== peg$FAILED) {
12543
+ s4 = peg$parse_();
12544
+ if (s4 !== peg$FAILED) {
12545
+ if (input.charCodeAt(peg$currPos) === 125) {
12546
+ s5 = peg$c29;
12547
+ peg$currPos++;
12548
+ } else {
12549
+ s5 = peg$FAILED;
12550
+ if (peg$silentFails === 0) peg$fail(peg$c30);
12551
+ }
12552
+ if (s5 !== peg$FAILED) {
12553
+ peg$savedPos = s0;
12554
+ s1 = peg$c133(s3);
12555
+ s0 = s1;
12556
+ } else {
12557
+ peg$currPos = s0;
12558
+ s0 = peg$FAILED;
12559
+ }
12560
+ } else {
12561
+ peg$currPos = s0;
12562
+ s0 = peg$FAILED;
12563
+ }
12564
+ } else {
12565
+ peg$currPos = s0;
12566
+ s0 = peg$FAILED;
12567
+ }
12568
+ } else {
12569
+ peg$currPos = s0;
12570
+ s0 = peg$FAILED;
12571
+ }
12572
+ } else {
12573
+ peg$currPos = s0;
12574
+ s0 = peg$FAILED;
12575
+ }
12576
+ return s0;
12577
+ }
12265
12578
  function peg$parseSectionCharacter() {
12266
12579
  let s0;
12267
12580
  if (input.length > peg$currPos) {
@@ -12269,7 +12582,7 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
12269
12582
  peg$currPos++;
12270
12583
  } else {
12271
12584
  s0 = peg$FAILED;
12272
- if (peg$silentFails === 0) peg$fail(peg$c154);
12585
+ if (peg$silentFails === 0) peg$fail(peg$c158);
12273
12586
  }
12274
12587
  return s0;
12275
12588
  }
@@ -12286,7 +12599,7 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
12286
12599
  peg$silentFails--;
12287
12600
  if (s0 === peg$FAILED) {
12288
12601
  s1 = peg$FAILED;
12289
- if (peg$silentFails === 0) peg$fail(peg$c155);
12602
+ if (peg$silentFails === 0) peg$fail(peg$c159);
12290
12603
  }
12291
12604
  return s0;
12292
12605
  }
@@ -12302,18 +12615,18 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
12302
12615
  peg$silentFails--;
12303
12616
  if (s0 === peg$FAILED) {
12304
12617
  s1 = peg$FAILED;
12305
- if (peg$silentFails === 0) peg$fail(peg$c156);
12618
+ if (peg$silentFails === 0) peg$fail(peg$c160);
12306
12619
  }
12307
12620
  return s0;
12308
12621
  }
12309
12622
  function peg$parseWhitespaceCharacter() {
12310
12623
  let s0;
12311
- if (peg$c157.test(input.charAt(peg$currPos))) {
12624
+ if (peg$c161.test(input.charAt(peg$currPos))) {
12312
12625
  s0 = input.charAt(peg$currPos);
12313
12626
  peg$currPos++;
12314
12627
  } else {
12315
12628
  s0 = peg$FAILED;
12316
- if (peg$silentFails === 0) peg$fail(peg$c158);
12629
+ if (peg$silentFails === 0) peg$fail(peg$c162);
12317
12630
  }
12318
12631
  return s0;
12319
12632
  }
@@ -12322,21 +12635,21 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
12322
12635
  peg$silentFails++;
12323
12636
  s0 = peg$currPos;
12324
12637
  s1 = [];
12325
- if (peg$c160.test(input.charAt(peg$currPos))) {
12638
+ if (peg$c164.test(input.charAt(peg$currPos))) {
12326
12639
  s2 = input.charAt(peg$currPos);
12327
12640
  peg$currPos++;
12328
12641
  } else {
12329
12642
  s2 = peg$FAILED;
12330
- if (peg$silentFails === 0) peg$fail(peg$c161);
12643
+ if (peg$silentFails === 0) peg$fail(peg$c165);
12331
12644
  }
12332
12645
  if (s2 !== peg$FAILED) while(s2 !== peg$FAILED){
12333
12646
  s1.push(s2);
12334
- if (peg$c160.test(input.charAt(peg$currPos))) {
12647
+ if (peg$c164.test(input.charAt(peg$currPos))) {
12335
12648
  s2 = input.charAt(peg$currPos);
12336
12649
  peg$currPos++;
12337
12650
  } else {
12338
12651
  s2 = peg$FAILED;
12339
- if (peg$silentFails === 0) peg$fail(peg$c161);
12652
+ if (peg$silentFails === 0) peg$fail(peg$c165);
12340
12653
  }
12341
12654
  }
12342
12655
  else s1 = peg$FAILED;
@@ -12345,18 +12658,18 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
12345
12658
  peg$silentFails--;
12346
12659
  if (s0 === peg$FAILED) {
12347
12660
  s1 = peg$FAILED;
12348
- if (peg$silentFails === 0) peg$fail(peg$c159);
12661
+ if (peg$silentFails === 0) peg$fail(peg$c163);
12349
12662
  }
12350
12663
  return s0;
12351
12664
  }
12352
12665
  function peg$parseNewLine() {
12353
12666
  let s0;
12354
- if (peg$c162.test(input.charAt(peg$currPos))) {
12667
+ if (peg$c166.test(input.charAt(peg$currPos))) {
12355
12668
  s0 = input.charAt(peg$currPos);
12356
12669
  peg$currPos++;
12357
12670
  } else {
12358
12671
  s0 = peg$FAILED;
12359
- if (peg$silentFails === 0) peg$fail(peg$c163);
12672
+ if (peg$silentFails === 0) peg$fail(peg$c167);
12360
12673
  }
12361
12674
  if (s0 === peg$FAILED) s0 = peg$parseCarriageReturnLineFeed();
12362
12675
  return s0;
@@ -12386,22 +12699,22 @@ function $d19fa9f128cdbd26$var$peg$parse(input, options) {
12386
12699
  function peg$parseLineFeed() {
12387
12700
  let s0;
12388
12701
  if (input.charCodeAt(peg$currPos) === 10) {
12389
- s0 = peg$c164;
12702
+ s0 = peg$c168;
12390
12703
  peg$currPos++;
12391
12704
  } else {
12392
12705
  s0 = peg$FAILED;
12393
- if (peg$silentFails === 0) peg$fail(peg$c165);
12706
+ if (peg$silentFails === 0) peg$fail(peg$c169);
12394
12707
  }
12395
12708
  return s0;
12396
12709
  }
12397
12710
  function peg$parseCarriageReturn() {
12398
12711
  let s0;
12399
12712
  if (input.charCodeAt(peg$currPos) === 13) {
12400
- s0 = peg$c166;
12713
+ s0 = peg$c170;
12401
12714
  peg$currPos++;
12402
12715
  } else {
12403
12716
  s0 = peg$FAILED;
12404
- if (peg$silentFails === 0) peg$fail(peg$c167);
12717
+ if (peg$silentFails === 0) peg$fail(peg$c171);
12405
12718
  }
12406
12719
  return s0;
12407
12720
  }
@@ -12856,7 +13169,8 @@ var $dfcb12f4c26c139d$export$2e2bcd8739ae039 = {
12856
13169
  }
12857
13170
  formatHeader() {
12858
13171
  // Process metadata according to configuration
12859
- const orderedMetadata = (0, $dfcb12f4c26c139d$export$5c964b66c4a8abfb)(this.song.metadata.all(), this.configuration.metadata);
13172
+ const songMetadata = this.song.getMetadata(this.configuration);
13173
+ const orderedMetadata = (0, $dfcb12f4c26c139d$export$5c964b66c4a8abfb)(songMetadata.ownMetadata(), this.configuration.metadata);
12860
13174
  const metadata = orderedMetadata.map(([key, value])=>{
12861
13175
  if (Array.isArray(value)) return `${key}: ${value.join(',')}`;
12862
13176
  if (typeof value === 'undefined' || value === null || value === '') return `${key}:`;
@@ -12865,8 +13179,10 @@ var $dfcb12f4c26c139d$export$2e2bcd8739ae039 = {
12865
13179
  return metadata ? `${metadata}\n\n` : '';
12866
13180
  }
12867
13181
  formatParagraphs() {
12868
- const { bodyParagraphs: bodyParagraphs, bodyParagraphs: { length: count }, metadata: metadata } = this.song;
12869
- const formattedParagraphs = bodyParagraphs.map((paragraph)=>this.formatParagraph(paragraph, metadata));
13182
+ const metadata = this.song.getMetadata(this.configuration);
13183
+ const paragraphs = this.song.filterParagraphs(this.song.bodyParagraphs, this.configuration);
13184
+ const count = paragraphs.length;
13185
+ const formattedParagraphs = paragraphs.map((paragraph)=>this.formatParagraph(paragraph, metadata));
12870
13186
  const combined = formattedParagraphs.join('\n\n');
12871
13187
  if (formattedParagraphs[count - 1].length === 0) return combined.substring(0, combined.length - 1);
12872
13188
  return combined;
@@ -13145,7 +13461,7 @@ function $698d1b7df9bab6b4$export$f0dcc8f253e2c535(newLine, lines, trailingLine,
13145
13461
  }
13146
13462
 
13147
13463
 
13148
- // Generated by peggy v. 5.0.6 (ts-pegjs plugin v. 3.1.0 )
13464
+ // Generated by peggy v. 5.1.0 (ts-pegjs plugin v. 3.1.0 )
13149
13465
  //
13150
13466
  // https://peggyjs.org/ https://github.com/metadevpro/ts-pegjs
13151
13467
  "use strict";
@@ -25282,7 +25598,7 @@ var $b58bece5a707e8d1$export$2e2bcd8739ae039 = $b58bece5a707e8d1$var$ChordsOverW
25282
25598
 
25283
25599
 
25284
25600
 
25285
- var $ee682089fac609da$export$2e2bcd8739ae039 = ({ configuration: configuration, configuration: { key: key, cssClasses: c }, song: song, renderBlankLines: renderBlankLines = false, song: { title: title, subtitle: subtitle, metadata: metadata }, bodyParagraphs: bodyParagraphs })=>(0, $dfcb12f4c26c139d$export$6ea1b0eb82ead3f)(`
25601
+ var $ee682089fac609da$export$2e2bcd8739ae039 = ({ configuration: configuration, configuration: { key: key, cssClasses: c }, song: song, metadata: metadata, renderBlankLines: renderBlankLines = false, song: { title: title, subtitle: subtitle }, bodyParagraphs: bodyParagraphs })=>(0, $dfcb12f4c26c139d$export$6ea1b0eb82ead3f)(`
25286
25602
  ${(0, $dfcb12f4c26c139d$export$a55877ca9db47377)(title, ()=>`<h1 class="${c.title}">${title}</h1>`)}
25287
25603
  ${(0, $dfcb12f4c26c139d$export$a55877ca9db47377)(subtitle, ()=>`<h2 class="${c.subtitle}">${subtitle}</h2>`)}
25288
25604
 
@@ -25383,10 +25699,12 @@ const $24ff40cf6e6a7e2f$export$2969e7e19d88b575 = {
25383
25699
  * @returns {string} The HTML string
25384
25700
  */ format(song) {
25385
25701
  const { bodyParagraphs: bodyParagraphs, expandedBodyParagraphs: expandedBodyParagraphs } = song;
25702
+ const paragraphs = this.configuration.expandChorusDirective ? expandedBodyParagraphs : bodyParagraphs;
25386
25703
  return this.template({
25387
25704
  song: song,
25705
+ metadata: song.getMetadata(this.configuration),
25388
25706
  configuration: this.configuration,
25389
- bodyParagraphs: this.configuration.expandChorusDirective ? expandedBodyParagraphs : bodyParagraphs
25707
+ bodyParagraphs: song.filterParagraphs(paragraphs, this.configuration)
25390
25708
  });
25391
25709
  }
25392
25710
  /**
@@ -25457,7 +25775,7 @@ var $79e99f27b77a3c71$export$2e2bcd8739ae039 = $79e99f27b77a3c71$var$HtmlDivForm
25457
25775
 
25458
25776
 
25459
25777
 
25460
- var $9c5f7d5454a05db6$export$2e2bcd8739ae039 = ({ configuration: configuration, configuration: { key: key, cssClasses: c }, song: song, renderBlankLines: renderBlankLines = false, song: { title: title, subtitle: subtitle, bodyLines: bodyLines, metadata: metadata }, bodyParagraphs: bodyParagraphs })=>(0, $dfcb12f4c26c139d$export$6ea1b0eb82ead3f)(`
25778
+ var $9c5f7d5454a05db6$export$2e2bcd8739ae039 = ({ configuration: configuration, configuration: { key: key, cssClasses: c }, song: song, metadata: metadata, renderBlankLines: renderBlankLines = false, song: { title: title, subtitle: subtitle, bodyLines: bodyLines }, bodyParagraphs: bodyParagraphs })=>(0, $dfcb12f4c26c139d$export$6ea1b0eb82ead3f)(`
25461
25779
  ${(0, $dfcb12f4c26c139d$export$a55877ca9db47377)(title, ()=>`<h1 class="${c.title}">${title}</h1>`)}
25462
25780
  ${(0, $dfcb12f4c26c139d$export$a55877ca9db47377)(subtitle, ()=>`<h2 class="${c.subtitle}">${subtitle}</h2>`)}
25463
25781
 
@@ -26346,7 +26664,7 @@ var $fb708a54a5f79aab$export$2e2bcd8739ae039 = $fb708a54a5f79aab$var$Condition;
26346
26664
  * @returns {string} the chord sheet
26347
26665
  */ format(song, metadata) {
26348
26666
  this.song = song;
26349
- this.metadata = metadata || song.metadata;
26667
+ this.metadata = metadata || song.getMetadata(this.configuration);
26350
26668
  return [
26351
26669
  this.formatHeader(),
26352
26670
  this.formatParagraphs()
@@ -26364,7 +26682,8 @@ var $fb708a54a5f79aab$export$2e2bcd8739ae039 = $fb708a54a5f79aab$var$Condition;
26364
26682
  formatParagraphs() {
26365
26683
  const { bodyParagraphs: bodyParagraphs, expandedBodyParagraphs: expandedBodyParagraphs } = this.song;
26366
26684
  const { expandChorusDirective: expandChorusDirective } = this.configuration;
26367
- return (expandChorusDirective ? expandedBodyParagraphs : bodyParagraphs).map((paragraph)=>this.formatParagraph(paragraph, this.metadata)).join('\n\n');
26685
+ const paragraphs = expandChorusDirective ? expandedBodyParagraphs : bodyParagraphs;
26686
+ return this.song.filterParagraphs(paragraphs, this.configuration).map((paragraph)=>this.formatParagraph(paragraph, this.metadata)).join('\n\n');
26368
26687
  }
26369
26688
  formatParagraph(paragraph, metadata) {
26370
26689
  if (paragraph.isLiteral()) return [
@@ -26461,10 +26780,10 @@ class $6be14f9184cf598f$export$f1e5feaa438be04f {
26461
26780
  * Determines if a content item should be rendered based on conditions
26462
26781
  */ shouldRenderContent(contentItem) {
26463
26782
  if (!contentItem.condition) return true;
26464
- const metadata = {
26465
- ...this.context.metadata.all(),
26466
- ...this.context.extraMetadata
26467
- };
26783
+ const { metadata: songMetadata, extraMetadata: extraMetadata } = this.context;
26784
+ const metadata = new Proxy({}, {
26785
+ get: (_, prop)=>extraMetadata?.[prop] ?? songMetadata.get(prop)
26786
+ });
26468
26787
  return new (0, $fb708a54a5f79aab$export$2e2bcd8739ae039)(contentItem.condition, metadata).evaluate();
26469
26788
  }
26470
26789
  /**
@@ -26541,7 +26860,9 @@ class $6be14f9184cf598f$export$f1e5feaa438be04f {
26541
26860
  const parsed = new (0, $6ba1c85836253a53$export$2e2bcd8739ae039)().parse(template);
26542
26861
  return new (0, $e2dfad8e72d5aab0$export$2e2bcd8739ae039)().format(parsed, metadata);
26543
26862
  } catch (e) {
26544
- throw new Error(`Error evaluating template\n\n${template}\n\n: ${e.message}`);
26863
+ throw new Error(`Error evaluating template\n\n${template}\n\n: ${e.message}`, {
26864
+ cause: e
26865
+ });
26545
26866
  }
26546
26867
  }
26547
26868
  /**
@@ -27593,8 +27914,7 @@ class $106cb69a2606bfa2$export$e6ce86b8bc39728b {
27593
27914
  /**
27594
27915
  * Removes hyphens from lyrics for lyrics-only mode
27595
27916
  */ removeHyphens(lyrics) {
27596
- let cleanedLyrics = lyrics;
27597
- cleanedLyrics = lyrics.replace(/\b(\w+)\s*-\s*(\w+)\b/g, '$1$2');
27917
+ let cleanedLyrics = lyrics.replace(/\b(\w+)\s*-\s*(\w+)\b/g, '$1$2');
27598
27918
  cleanedLyrics = cleanedLyrics.replace(/(?:\b(\w+)\s*-\s*$)|(?:-\s*$)|(?:\s+-\s+$)/g, '$1');
27599
27919
  if (/^\s*-\s*$/.test(cleanedLyrics)) return '';
27600
27920
  return cleanedLyrics;
@@ -36382,15 +36702,25 @@ var $6a0e1e68c51ef6cd$export$2e2bcd8739ae039 = $6a0e1e68c51ef6cd$var$PdfFormatte
36382
36702
 
36383
36703
 
36384
36704
  const $ecd3f348894bfbde$var$VERSE_LINE_REGEX = /^\[(Verse.*)]/i;
36385
- const $ecd3f348894bfbde$var$CHORUS_LINE_REGEX = /^\[(Chorus)]/i;
36705
+ const $ecd3f348894bfbde$var$CHORUS_LINE_REGEX = /^\[(Chorus.*)]/i;
36706
+ const $ecd3f348894bfbde$var$BRIDGE_LINE_REGEX = /^\[(Bridge.*)]/i;
36707
+ const $ecd3f348894bfbde$var$PART_LINE_REGEX = /^\[(Intro|Outro|Instrumental|Interlude|Solo|Pre-Chorus)( \d+)?]/i;
36708
+ const $ecd3f348894bfbde$var$UG_METADATA_REGEX = /^(\w+):\s*(.+)$/;
36386
36709
  const $ecd3f348894bfbde$var$OTHER_METADATA_LINE_REGEX = /^\[([^\]]+)]/;
36710
+ const $ecd3f348894bfbde$var$REPEAT_NOTATION_REGEX = /\s+(x\d+)\s*$/i;
36711
+ // eslint-disable-next-line max-len
36712
+ const $ecd3f348894bfbde$var$CHORD_LINE_REGEX = /^\s*((([A-G|Do|Re|Mi|Fa|Sol|La|Si])(#|b)?([^/\s]*)(\/([A-G|Do|Re|Mi|Fa|Sol|La|Si])(#|b)?)?)(\s|$)+)+(\s|$)+/;
36387
36713
  const $ecd3f348894bfbde$var$startSectionTags = {
36388
36714
  [(0, $72b24102c7d826fd$export$4b194284baed1659)]: (0, $a41c1115e2898cb2$export$deca399f8cd9b7dc),
36389
- [(0, $72b24102c7d826fd$export$8db6c706fc9142b2)]: (0, $a41c1115e2898cb2$export$4f5168acae064e01)
36715
+ [(0, $72b24102c7d826fd$export$8db6c706fc9142b2)]: (0, $a41c1115e2898cb2$export$4f5168acae064e01),
36716
+ [(0, $72b24102c7d826fd$export$78d8c50e853acd10)]: (0, $a41c1115e2898cb2$export$3550cc87694d54e0),
36717
+ [(0, $72b24102c7d826fd$export$609cc0ea1637d6a0)]: (0, $a41c1115e2898cb2$export$2b9510a208875fc9)
36390
36718
  };
36391
36719
  const $ecd3f348894bfbde$var$endSectionTags = {
36392
36720
  [(0, $72b24102c7d826fd$export$4b194284baed1659)]: (0, $a41c1115e2898cb2$export$640d294ab83f9040),
36393
- [(0, $72b24102c7d826fd$export$8db6c706fc9142b2)]: (0, $a41c1115e2898cb2$export$473c1a4819e5180b)
36721
+ [(0, $72b24102c7d826fd$export$8db6c706fc9142b2)]: (0, $a41c1115e2898cb2$export$473c1a4819e5180b),
36722
+ [(0, $72b24102c7d826fd$export$78d8c50e853acd10)]: (0, $a41c1115e2898cb2$export$1c874e9780385ecd),
36723
+ [(0, $72b24102c7d826fd$export$609cc0ea1637d6a0)]: (0, $a41c1115e2898cb2$export$189f12065cceb96a)
36394
36724
  };
36395
36725
  /**
36396
36726
  * Parses an Ultimate Guitar chord sheet with metadata
@@ -36403,11 +36733,111 @@ const $ecd3f348894bfbde$var$endSectionTags = {
36403
36733
  */ constructor({ preserveWhitespace: preserveWhitespace = true } = {}){
36404
36734
  super({
36405
36735
  preserveWhitespace: preserveWhitespace
36406
- }, false), this.currentSectionType = null;
36736
+ }, false), this.currentSectionType = null, this.pendingRepeatNotation = null;
36407
36737
  }
36408
36738
  parseLine(line) {
36409
36739
  if (this.isSectionEnd()) this.endSection();
36410
- if (!(this.parseVerseDirective(line) || this.parseChorusDirective(line) || this.parseMetadata(line))) super.parseLine(line);
36740
+ const { cleanLine: cleanLine, repeatNotation: repeatNotation } = this.extractRepeatNotation(line);
36741
+ this.pendingRepeatNotation = repeatNotation;
36742
+ if (!(this.parseVerseDirective(cleanLine) || this.parseChorusDirective(cleanLine) || this.parseBridgeDirective(cleanLine) || this.parsePartDirective(cleanLine) || this.parseUGMetadata(cleanLine) || this.parseMetadata(cleanLine))) this.parseRegularLine(cleanLine);
36743
+ }
36744
+ parseRegularLine(line) {
36745
+ this.songLine = this.songBuilder.addLine();
36746
+ if (line.trim().length === 0) this.chordLyricsPair = null;
36747
+ else this.parseNonEmptyLine(line);
36748
+ }
36749
+ parseNonEmptyLine(line) {
36750
+ if (!this.songLine) throw new Error('Expected this.songLine to be present');
36751
+ this.chordLyricsPair = this.songLine.addChordLyricsPair();
36752
+ const isChordLine = $ecd3f348894bfbde$var$CHORD_LINE_REGEX.test(line);
36753
+ if (isChordLine && this.hasNextLine()) this.parseChordLineWithNextLine(line);
36754
+ else if (isChordLine) this.parseChordsOnly(line);
36755
+ else this.chordLyricsPair.lyrics = `${line}`;
36756
+ }
36757
+ parseChordLineWithNextLine(chordsLine) {
36758
+ const nextLine = this.readLine();
36759
+ if (this.isNonLyricsLine(nextLine)) {
36760
+ this.parseChordsOnly(chordsLine);
36761
+ this.unreadLine();
36762
+ } else this.parseLyricsWithChords(chordsLine, nextLine);
36763
+ }
36764
+ unreadLine() {
36765
+ this.currentLine -= 1;
36766
+ }
36767
+ isNonLyricsLine(line) {
36768
+ return $ecd3f348894bfbde$var$VERSE_LINE_REGEX.test(line) || $ecd3f348894bfbde$var$CHORUS_LINE_REGEX.test(line) || $ecd3f348894bfbde$var$BRIDGE_LINE_REGEX.test(line) || $ecd3f348894bfbde$var$PART_LINE_REGEX.test(line) || $ecd3f348894bfbde$var$OTHER_METADATA_LINE_REGEX.test(line) || $ecd3f348894bfbde$var$CHORD_LINE_REGEX.test(line) || line.trim().length === 0;
36769
+ }
36770
+ parseChordsOnly(chordsLine) {
36771
+ this.parseLyricsWithChords(chordsLine, '');
36772
+ this.applyRepeatNotation();
36773
+ }
36774
+ parseLyricsWithChords(chordsLine, lyricsLine) {
36775
+ this.processCharacters(chordsLine, lyricsLine);
36776
+ if (!this.chordLyricsPair) throw new Error('Expected this.chordLyricsPair to be present');
36777
+ this.chordLyricsPair.lyrics += lyricsLine.substring(chordsLine.length);
36778
+ this.chordLyricsPair.chords = this.chordLyricsPair.chords.trim();
36779
+ if (this.chordLyricsPair.lyrics) this.chordLyricsPair.lyrics = this.chordLyricsPair.lyrics.trim();
36780
+ this.applyRepeatNotation();
36781
+ }
36782
+ processCharacters(chordsLine, lyricsLine) {
36783
+ for(let c = 0, charCount = chordsLine.length; c < charCount; c += 1){
36784
+ const chr = chordsLine[c];
36785
+ const nextChar = chordsLine[c + 1];
36786
+ const isWhiteSpace = /\s/.test(chr);
36787
+ this.addCharacter(chr, nextChar);
36788
+ if (!this.chordLyricsPair) throw new Error('Expected this.chordLyricsPair to be present');
36789
+ this.chordLyricsPair.lyrics += lyricsLine[c] || '';
36790
+ this.processingText = !isWhiteSpace;
36791
+ }
36792
+ }
36793
+ addCharacter(chr, nextChar) {
36794
+ const isWhiteSpace = /\s/.test(chr);
36795
+ if (!isWhiteSpace) this.ensureChordLyricsPairInitialized();
36796
+ if (!isWhiteSpace || this.shouldAddCharacterToChords(nextChar)) {
36797
+ if (!this.chordLyricsPair) throw new Error('Expected this.chordLyricsPair to be present');
36798
+ this.chordLyricsPair.chords += chr;
36799
+ }
36800
+ }
36801
+ shouldAddCharacterToChords(nextChar) {
36802
+ return !!(nextChar && /\s/.test(nextChar) && this.preserveWhitespace);
36803
+ }
36804
+ ensureChordLyricsPairInitialized() {
36805
+ if (!this.processingText) {
36806
+ if (!this.songLine) throw new Error('Expected this.songLine to be present');
36807
+ this.chordLyricsPair = this.songLine.addChordLyricsPair();
36808
+ this.processingText = true;
36809
+ }
36810
+ }
36811
+ extractRepeatNotation(line) {
36812
+ const match = line.match($ecd3f348894bfbde$var$REPEAT_NOTATION_REGEX);
36813
+ if (match) return {
36814
+ cleanLine: line.replace($ecd3f348894bfbde$var$REPEAT_NOTATION_REGEX, ''),
36815
+ repeatNotation: match[1]
36816
+ };
36817
+ return {
36818
+ cleanLine: line,
36819
+ repeatNotation: null
36820
+ };
36821
+ }
36822
+ applyRepeatNotation() {
36823
+ if (!this.pendingRepeatNotation || !this.songLine) return;
36824
+ const lastItem = this.songLine.items[this.songLine.items.length - 1];
36825
+ if (lastItem && 'lyrics' in lastItem) lastItem.lyrics = (lastItem.lyrics || '') + this.pendingRepeatNotation;
36826
+ this.pendingRepeatNotation = null;
36827
+ }
36828
+ parseUGMetadata(line) {
36829
+ const match = line.match($ecd3f348894bfbde$var$UG_METADATA_REGEX);
36830
+ if (!match) return false;
36831
+ const tagName = match[1].toLowerCase();
36832
+ if (!(0, $b58c551853385714$export$57ecf0dc09effb3).includes(tagName)) return false;
36833
+ const value = tagName === (0, $a41c1115e2898cb2$export$866f445d49bad88e) ? this.extractCapoValue(match[2]) : match[2].trim();
36834
+ this.startNewLine();
36835
+ this.songBuilder.addTag(new (0, $b58c551853385714$export$2e2bcd8739ae039)(tagName, value));
36836
+ return true;
36837
+ }
36838
+ extractCapoValue(rawValue) {
36839
+ const [, capoNumber] = rawValue.match(/^(\d+)/) || [];
36840
+ return capoNumber || rawValue.trim();
36411
36841
  }
36412
36842
  parseVerseDirective(line) {
36413
36843
  const match = line.match($ecd3f348894bfbde$var$VERSE_LINE_REGEX);
@@ -36425,6 +36855,22 @@ const $ecd3f348894bfbde$var$endSectionTags = {
36425
36855
  this.startSection((0, $72b24102c7d826fd$export$8db6c706fc9142b2), label);
36426
36856
  return true;
36427
36857
  }
36858
+ parseBridgeDirective(line) {
36859
+ const match = line.match($ecd3f348894bfbde$var$BRIDGE_LINE_REGEX);
36860
+ if (!match) return false;
36861
+ this.startNewLine();
36862
+ const label = match[1];
36863
+ this.startSection((0, $72b24102c7d826fd$export$78d8c50e853acd10), label);
36864
+ return true;
36865
+ }
36866
+ parsePartDirective(line) {
36867
+ const match = line.match($ecd3f348894bfbde$var$PART_LINE_REGEX);
36868
+ if (!match) return false;
36869
+ this.startNewLine();
36870
+ const label = match[1] + (match[2] || '');
36871
+ this.startSection((0, $72b24102c7d826fd$export$609cc0ea1637d6a0), label);
36872
+ return true;
36873
+ }
36428
36874
  parseMetadata(line) {
36429
36875
  const match = line.match($ecd3f348894bfbde$var$OTHER_METADATA_LINE_REGEX);
36430
36876
  if (!match) return false;
@@ -36452,7 +36898,11 @@ const $ecd3f348894bfbde$var$endSectionTags = {
36452
36898
  }
36453
36899
  endSection({ addNewLine: addNewLine = true } = {}) {
36454
36900
  if (this.currentSectionType !== null && this.currentSectionType in $ecd3f348894bfbde$var$endSectionTags) {
36455
- this.songBuilder.addTag(new (0, $b58c551853385714$export$2e2bcd8739ae039)($ecd3f348894bfbde$var$endSectionTags[this.currentSectionType]));
36901
+ if (this.songLine && this.songLine.isEmpty()) this.songLine.addTag(new (0, $b58c551853385714$export$2e2bcd8739ae039)($ecd3f348894bfbde$var$endSectionTags[this.currentSectionType]));
36902
+ else {
36903
+ const endTagLine = this.songBuilder.addLine();
36904
+ endTagLine.addTag(new (0, $b58c551853385714$export$2e2bcd8739ae039)($ecd3f348894bfbde$var$endSectionTags[this.currentSectionType]));
36905
+ }
36456
36906
  if (addNewLine) this.startNewLine();
36457
36907
  }
36458
36908
  this.songBuilder.setCurrentProperties((0, $72b24102c7d826fd$export$c53d0f541b41b88e));
@@ -36465,7 +36915,7 @@ const $ecd3f348894bfbde$var$endSectionTags = {
36465
36915
  var $ecd3f348894bfbde$export$2e2bcd8739ae039 = $ecd3f348894bfbde$var$UltimateGuitarParser;
36466
36916
 
36467
36917
 
36468
- var $a91afe1497b28cb4$export$2e2bcd8739ae039 = '13.2.2';
36918
+ var $a91afe1497b28cb4$export$2e2bcd8739ae039 = '14.1.0';
36469
36919
 
36470
36920
 
36471
36921
 
@@ -36507,6 +36957,7 @@ var $c0b60add41284d2e$export$2e2bcd8739ae039 = {
36507
36957
  SoftLineBreak: $4c3a42e9543eea65$export$2e2bcd8739ae039,
36508
36958
  Song: $962eb86a322c5cfb$export$2e2bcd8739ae039,
36509
36959
  TAB: $72b24102c7d826fd$export$f1c9dd0f5207dd5e,
36960
+ TEXTBLOCK: $72b24102c7d826fd$export$5a2cf64ea612936a,
36510
36961
  Tag: $b58c551853385714$export$2e2bcd8739ae039,
36511
36962
  Ternary: $4afcde69e7cb3e85$export$2e2bcd8739ae039,
36512
36963
  TextFormatter: $e2dfad8e72d5aab0$export$2e2bcd8739ae039,
@@ -36538,5 +36989,5 @@ var $c0b60add41284d2e$export$2e2bcd8739ae039 = {
36538
36989
  };
36539
36990
 
36540
36991
 
36541
- export {$c0b60add41284d2e$export$2e2bcd8739ae039 as default, $f0449e2486cb2372$export$2e2bcd8739ae039 as Chord, $7494e305d9bdc641$export$2e2bcd8739ae039 as ChordDefinition, $0d04ced54ebef610$export$2e2bcd8739ae039 as ChordLyricsPair, $fe0c6f4316da78b0$export$2e2bcd8739ae039 as ChordProFormatter, $6a0e1e68c51ef6cd$export$2e2bcd8739ae039 as PdfFormatter, $cd5e49c3ccca2d1a$export$2e2bcd8739ae039 as MeasuredHtmlFormatter, $6ba1c85836253a53$export$2e2bcd8739ae039 as ChordProParser, $f46090a0372cd33a$export$2e2bcd8739ae039 as ChordSheetParser, $6f86ed99ed3b8cb9$export$2e2bcd8739ae039 as ChordSheetSerializer, $07208092bd922ab3$export$2e2bcd8739ae039 as ChordsOverWordsFormatter, $b58bece5a707e8d1$export$2e2bcd8739ae039 as ChordsOverWordsParser, $acbb1127ce68c11a$export$2e2bcd8739ae039 as Comment, $6191763894f0be63$export$2e2bcd8739ae039 as Composite, $750c574c15888689$export$2e2bcd8739ae039 as Formatter, $79e99f27b77a3c71$export$2e2bcd8739ae039 as HtmlDivFormatter, $24ff40cf6e6a7e2f$export$2e2bcd8739ae039 as HtmlFormatter, $caa8cd86020c188e$export$2e2bcd8739ae039 as HtmlTableFormatter, $4d72f408c2526a1c$export$2e2bcd8739ae039 as Key, $a449f9ee1c7acbe4$export$2e2bcd8739ae039 as Line, $34ab5875df061287$export$2e2bcd8739ae039 as Literal, $709af735c74ed550$export$2e2bcd8739ae039 as Metadata, $ca405333ab46d462$export$2e2bcd8739ae039 as Paragraph, $4c3a42e9543eea65$export$2e2bcd8739ae039 as SoftLineBreak, $962eb86a322c5cfb$export$2e2bcd8739ae039 as Song, $b58c551853385714$export$2e2bcd8739ae039 as Tag, $4afcde69e7cb3e85$export$2e2bcd8739ae039 as Ternary, $e2dfad8e72d5aab0$export$2e2bcd8739ae039 as TextFormatter, $ecd3f348894bfbde$export$2e2bcd8739ae039 as UltimateGuitarParser, $dfcb12f4c26c139d$export$2e2bcd8739ae039 as templateHelpers, $a91afe1497b28cb4$export$2e2bcd8739ae039 as version, $5eb183c94ebd1c6b$export$2027fef7414ae7df as BaseMeasurer, $fba2e39502aaf78d$export$341872369d2a416a as JsPdfMeasurer, $609cd478b8492b62$export$74d213ae39da8aef as DomMeasurer, $ebfdf39b2dab7f15$export$6d4390fed2af4771 as CanvasMeasurer, $a780d3a38b9ddb96$export$12b762d1038ddc6b as LayoutEngine, $72b24102c7d826fd$export$92249c36c213e508 as ABC, $72b24102c7d826fd$export$8db6c706fc9142b2 as CHORUS, $72b24102c7d826fd$export$c5a6fe907430212e as INDETERMINATE, $72b24102c7d826fd$export$6a5a2eab72b6e3d as LILYPOND, $72b24102c7d826fd$export$c53d0f541b41b88e as NONE, $72b24102c7d826fd$export$4d318981b5a83836 as NUMERIC, $72b24102c7d826fd$export$539a6499f4711c57 as SOLFEGE, $72b24102c7d826fd$export$27c95a7104c1f7aa as SYMBOL, $72b24102c7d826fd$export$f1c9dd0f5207dd5e as TAB, $72b24102c7d826fd$export$4b194284baed1659 as VERSE, $72b24102c7d826fd$export$609cc0ea1637d6a0 as PART, $72b24102c7d826fd$export$1321df9b16c30c6a as NUMERAL};
36992
+ export {$c0b60add41284d2e$export$2e2bcd8739ae039 as default, $f0449e2486cb2372$export$2e2bcd8739ae039 as Chord, $7494e305d9bdc641$export$2e2bcd8739ae039 as ChordDefinition, $0d04ced54ebef610$export$2e2bcd8739ae039 as ChordLyricsPair, $fe0c6f4316da78b0$export$2e2bcd8739ae039 as ChordProFormatter, $6a0e1e68c51ef6cd$export$2e2bcd8739ae039 as PdfFormatter, $cd5e49c3ccca2d1a$export$2e2bcd8739ae039 as MeasuredHtmlFormatter, $6ba1c85836253a53$export$2e2bcd8739ae039 as ChordProParser, $f46090a0372cd33a$export$2e2bcd8739ae039 as ChordSheetParser, $6f86ed99ed3b8cb9$export$2e2bcd8739ae039 as ChordSheetSerializer, $07208092bd922ab3$export$2e2bcd8739ae039 as ChordsOverWordsFormatter, $b58bece5a707e8d1$export$2e2bcd8739ae039 as ChordsOverWordsParser, $acbb1127ce68c11a$export$2e2bcd8739ae039 as Comment, $6191763894f0be63$export$2e2bcd8739ae039 as Composite, $750c574c15888689$export$2e2bcd8739ae039 as Formatter, $79e99f27b77a3c71$export$2e2bcd8739ae039 as HtmlDivFormatter, $24ff40cf6e6a7e2f$export$2e2bcd8739ae039 as HtmlFormatter, $caa8cd86020c188e$export$2e2bcd8739ae039 as HtmlTableFormatter, $4d72f408c2526a1c$export$2e2bcd8739ae039 as Key, $a449f9ee1c7acbe4$export$2e2bcd8739ae039 as Line, $34ab5875df061287$export$2e2bcd8739ae039 as Literal, $709af735c74ed550$export$2e2bcd8739ae039 as Metadata, $ca405333ab46d462$export$2e2bcd8739ae039 as Paragraph, $4c3a42e9543eea65$export$2e2bcd8739ae039 as SoftLineBreak, $962eb86a322c5cfb$export$2e2bcd8739ae039 as Song, $b58c551853385714$export$2e2bcd8739ae039 as Tag, $4afcde69e7cb3e85$export$2e2bcd8739ae039 as Ternary, $e2dfad8e72d5aab0$export$2e2bcd8739ae039 as TextFormatter, $ecd3f348894bfbde$export$2e2bcd8739ae039 as UltimateGuitarParser, $dfcb12f4c26c139d$export$2e2bcd8739ae039 as templateHelpers, $a91afe1497b28cb4$export$2e2bcd8739ae039 as version, $5eb183c94ebd1c6b$export$2027fef7414ae7df as BaseMeasurer, $fba2e39502aaf78d$export$341872369d2a416a as JsPdfMeasurer, $609cd478b8492b62$export$74d213ae39da8aef as DomMeasurer, $ebfdf39b2dab7f15$export$6d4390fed2af4771 as CanvasMeasurer, $a780d3a38b9ddb96$export$12b762d1038ddc6b as LayoutEngine, $72b24102c7d826fd$export$92249c36c213e508 as ABC, $72b24102c7d826fd$export$8db6c706fc9142b2 as CHORUS, $72b24102c7d826fd$export$c5a6fe907430212e as INDETERMINATE, $72b24102c7d826fd$export$6a5a2eab72b6e3d as LILYPOND, $72b24102c7d826fd$export$c53d0f541b41b88e as NONE, $72b24102c7d826fd$export$4d318981b5a83836 as NUMERIC, $72b24102c7d826fd$export$539a6499f4711c57 as SOLFEGE, $72b24102c7d826fd$export$27c95a7104c1f7aa as SYMBOL, $72b24102c7d826fd$export$f1c9dd0f5207dd5e as TAB, $72b24102c7d826fd$export$5a2cf64ea612936a as TEXTBLOCK, $72b24102c7d826fd$export$4b194284baed1659 as VERSE, $72b24102c7d826fd$export$609cc0ea1637d6a0 as PART, $72b24102c7d826fd$export$1321df9b16c30c6a as NUMERAL};
36542
36993
  //# sourceMappingURL=module.js.map