chordsheetjs 7.15.0 → 7.17.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/README.md CHANGED
@@ -1127,6 +1127,8 @@ https://chordpro.org/chordpro/directives-env_bridge/, https://chordpro.org/chord
1127
1127
  | [configuration.metadata.separator] | <code>string</code> | <code>&quot;\&quot;, \&quot;&quot;</code> | <p>The separator to be used when rendering a metadata value that has multiple values. See: https://bit.ly/2SC9c2u</p> |
1128
1128
  | [configuration.key] | [<code>Key</code>](#Key) \| <code>string</code> | <code></code> | <p>The key to use for rendering. The chord sheet will be transposed from the song's original key (as indicated by the <code>{key}</code> directive) to the specified key. Note that transposing will only work if the original song key is set.</p> |
1129
1129
  | [configuration.expandChorusDirective] | <code>boolean</code> | <code>false</code> | <p>Whether or not to expand <code>{chorus}</code> directives by rendering the last defined chorus inline after the directive.</p> |
1130
+ | [configuration.useUnicodeModifiers] | <code>boolean</code> | <code>false</code> | <p>Whether or not to use unicode flat and sharp symbols.</p> |
1131
+ | [configuration.normalizeChords] | <code>boolean</code> | <code>true</code> | <p>Whether or not to automatically normalize chords</p> |
1130
1132
 
1131
1133
  <a name="HtmlDivFormatter"></a>
1132
1134
 
@@ -1393,7 +1395,7 @@ Inherits from [ChordSheetParser](#ChordSheetParser)</p>
1393
1395
  * [.isNumeric()](#Chord+isNumeric) ⇒ <code>boolean</code>
1394
1396
  * [.toNumericString([referenceKey])](#Chord+toNumericString) ⇒ <code>string</code>
1395
1397
  * [.isNumeral()](#Chord+isNumeral) ⇒ <code>boolean</code>
1396
- * [.toString()](#Chord+toString) ⇒ <code>string</code>
1398
+ * [.toString([configuration])](#Chord+toString) ⇒ <code>string</code>
1397
1399
  * [.normalize([key], [options])](#Chord+normalize) ⇒ [<code>Chord</code>](#Chord)
1398
1400
  * [.useModifier(newModifier)](#Chord+useModifier) ⇒ [<code>Chord</code>](#Chord)
1399
1401
  * [.transposeUp()](#Chord+transposeUp) ⇒ [<code>Chord</code>](#Chord)
@@ -1511,11 +1513,17 @@ For example, a chord symbol A# with reference key E will return the numeric chor
1511
1513
  **Kind**: instance method of [<code>Chord</code>](#Chord)
1512
1514
  <a name="Chord+toString"></a>
1513
1515
 
1514
- ### chord.toString() ⇒ <code>string</code>
1516
+ ### chord.toString([configuration]) ⇒ <code>string</code>
1515
1517
  <p>Converts the chord to a string, eg <code>Esus4/G#</code> or <code>1sus4/#3</code></p>
1516
1518
 
1517
1519
  **Kind**: instance method of [<code>Chord</code>](#Chord)
1518
1520
  **Returns**: <code>string</code> - <p>the chord string</p>
1521
+
1522
+ | Param | Type | Default | Description |
1523
+ | --- | --- | --- | --- |
1524
+ | [configuration] | <code>Object</code> | <code>{}</code> | <p>options</p> |
1525
+ | [configuration.useUnicodeModifier] | <code>boolean</code> | <code>false</code> | <p>Whether or not to use unicode modifiers. This will make <code>#</code> (sharp) look like <code>♯</code> and <code>b</code> (flat) look like <code>♭</code></p> |
1526
+
1519
1527
  <a name="Chord+normalize"></a>
1520
1528
 
1521
1529
  ### chord.normalize([key], [options]) ⇒ [<code>Chord</code>](#Chord)
package/lib/bundle.js CHANGED
@@ -1214,6 +1214,16 @@ function $bff5407e03fdc8ee$var$modifierTransposition(modifier) {
1214
1214
  * The only function considered public API is `Key.distance`
1215
1215
  */ class $bff5407e03fdc8ee$var$Key {
1216
1216
  modifier = null;
1217
+ get unicodeModifier() {
1218
+ switch(this.modifier){
1219
+ case $bff5407e03fdc8ee$var$FLAT:
1220
+ return "♭";
1221
+ case $bff5407e03fdc8ee$var$SHARP:
1222
+ return "♯";
1223
+ default:
1224
+ return null;
1225
+ }
1226
+ }
1217
1227
  minor = false;
1218
1228
  static parse(keyString) {
1219
1229
  if (!keyString || (0, $21a34a464e7bc609$export$78d1711480f95c3e)(keyString)) return null;
@@ -1323,10 +1333,10 @@ function $bff5407e03fdc8ee$var$modifierTransposition(modifier) {
1323
1333
  toNumeralString(key = null) {
1324
1334
  return this.toNumeral(key).toString();
1325
1335
  }
1326
- toString({ showMinor: showMinor = true } = {}) {
1336
+ toString({ showMinor: showMinor = true , useUnicodeModifier: useUnicodeModifier = false } = {}) {
1327
1337
  switch(this.note.type){
1328
1338
  case 0, $af8d31735c159a26$export$27c95a7104c1f7aa:
1329
- return this.formatChordSymbolString(showMinor);
1339
+ return this.formatChordSymbolString(showMinor, useUnicodeModifier);
1330
1340
  case 0, $af8d31735c159a26$export$4d318981b5a83836:
1331
1341
  return this.formatNumericString(showMinor);
1332
1342
  case 0, $af8d31735c159a26$export$1321df9b16c30c6a:
@@ -1335,8 +1345,9 @@ function $bff5407e03fdc8ee$var$modifierTransposition(modifier) {
1335
1345
  throw new Error(`Unexpected note type ${this.note.type}`);
1336
1346
  }
1337
1347
  }
1338
- formatChordSymbolString(showMinor) {
1339
- return `${this.note}${this.modifier || ""}${this.minor && showMinor ? "m" : ""}`;
1348
+ formatChordSymbolString(showMinor, unicodeModifier) {
1349
+ const modifier = unicodeModifier ? this.unicodeModifier : this.modifier;
1350
+ return `${this.note}${modifier || ""}${this.minor && showMinor ? "m" : ""}`;
1340
1351
  }
1341
1352
  formatNumericString(showMinor) {
1342
1353
  return `${this.modifier || ""}${this.note}${this.minor && showMinor ? "m" : ""}`;
@@ -2486,12 +2497,18 @@ function $26f57998457eb2d4$var$normalizeChordSuffix(suffix) {
2486
2497
  }
2487
2498
  /**
2488
2499
  * Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
2500
+ * @param {Object} [configuration={}] options
2501
+ * @param {boolean} [configuration.useUnicodeModifier=false] Whether or not to use unicode modifiers.
2502
+ * This will make `#` (sharp) look like `♯` and `b` (flat) look like `♭`
2489
2503
  * @returns {string} the chord string
2490
- */ toString() {
2504
+ */ toString({ useUnicodeModifier: useUnicodeModifier = false } = {}) {
2491
2505
  const chordString = this.root.toString({
2492
- showMinor: false
2506
+ showMinor: false,
2507
+ useUnicodeModifier: useUnicodeModifier
2493
2508
  }) + (this.suffix || "");
2494
- if (this.bass) return `${chordString}/${this.bass.toString()}`;
2509
+ if (this.bass) return `${chordString}/${this.bass.toString({
2510
+ useUnicodeModifier: useUnicodeModifier
2511
+ })}`;
2495
2512
  return chordString;
2496
2513
  }
2497
2514
  /**
@@ -2685,7 +2702,9 @@ const $bbcfd2c49e8e9957$export$78c0028a34264234 = {
2685
2702
  separator: ","
2686
2703
  },
2687
2704
  key: null,
2688
- expandChorusDirective: false
2705
+ expandChorusDirective: false,
2706
+ useUnicodeModifiers: false,
2707
+ normalizeChords: true
2689
2708
  };
2690
2709
  class $bbcfd2c49e8e9957$var$Configuration {
2691
2710
  constructor(configuration = $bbcfd2c49e8e9957$export$78c0028a34264234){
@@ -2695,6 +2714,8 @@ class $bbcfd2c49e8e9957$var$Configuration {
2695
2714
  };
2696
2715
  this.evaluate = !!mergedConfig.evaluate;
2697
2716
  this.expandChorusDirective = !!mergedConfig.expandChorusDirective;
2717
+ this.useUnicodeModifiers = !!mergedConfig.useUnicodeModifiers;
2718
+ this.normalizeChords = !!mergedConfig.normalizeChords;
2698
2719
  this.metadata = new (0, $71c330be198ce421$export$2e2bcd8739ae039)(configuration.metadata);
2699
2720
  this.key = configuration.key ? (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(configuration.key) : null;
2700
2721
  this.configuration = configuration;
@@ -2712,17 +2733,19 @@ var $bbcfd2c49e8e9957$export$2e2bcd8739ae039 = $bbcfd2c49e8e9957$var$Configurati
2712
2733
  /**
2713
2734
  * Instantiate
2714
2735
  * @param {Object} [configuration={}] options
2715
- * @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions. For more info about
2716
- * meta expressions, see: https://bit.ly/2SC9c2u
2736
+ * @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions.
2737
+ * For more info about meta expressions, see: https://bit.ly/2SC9c2u
2717
2738
  * @param {object} [configuration.metadata={}]
2718
- * @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a metadata value
2719
- * that has multiple values. See: https://bit.ly/2SC9c2u
2720
- * @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be transposed
2721
- * from the song's original key (as indicated by the `{key}` directive) to the specified key.
2722
- * Note that transposing will only work
2723
- * if the original song key is set.
2739
+ * @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a
2740
+ * metadata value that has multiple values. See: https://bit.ly/2SC9c2u
2741
+ * @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be
2742
+ * transposed from the song's original key (as indicated by the `{key}` directive) to the specified key.
2743
+ * Note that transposing will only work if the original song key is set.
2724
2744
  * @param {boolean} [configuration.expandChorusDirective=false] Whether or not to expand `{chorus}` directives
2725
2745
  * by rendering the last defined chorus inline after the directive.
2746
+ * @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
2747
+ * symbols.
2748
+ * @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
2726
2749
  */ constructor(configuration = null){
2727
2750
  this.configuration = new (0, $bbcfd2c49e8e9957$export$2e2bcd8739ae039)(configuration || {});
2728
2751
  }
@@ -8214,14 +8237,18 @@ function $dfecd32049fa58e9$var$chordTransposeDistance(capo, transposeKey, songKe
8214
8237
  }
8215
8238
  return transpose;
8216
8239
  }
8217
- function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, renderKey = null) {
8240
+ function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null , useUnicodeModifier: useUnicodeModifier = false , normalizeChords: normalizeChords = true } = {}) {
8218
8241
  const chord = (0, $26f57998457eb2d4$export$2e2bcd8739ae039).parse(chordString);
8219
8242
  const songKey = song.key;
8220
8243
  const capo = parseInt(song.metadata.getSingle((0, $5e9ede69210ec54a$export$866f445d49bad88e)), 10);
8221
8244
  if (!chord) return chordString;
8222
8245
  const effectiveTransposeDistance = $dfecd32049fa58e9$var$chordTransposeDistance(capo, line.transposeKey, songKey, renderKey);
8223
8246
  const effectiveKey = renderKey || (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(line.key || song.key)?.transpose(effectiveTransposeDistance) || null;
8224
- return chord.transpose(effectiveTransposeDistance).normalize(effectiveKey).toString();
8247
+ const transposedChord = chord.transpose(effectiveTransposeDistance);
8248
+ const normalizedChord = normalizeChords ? transposedChord.normalize(effectiveKey) : transposedChord;
8249
+ return normalizedChord.toString({
8250
+ useUnicodeModifier: useUnicodeModifier
8251
+ });
8225
8252
  }
8226
8253
  function $dfecd32049fa58e9$export$b07b16221c14aaa(key) {
8227
8254
  return (0, $427b789bcf346e61$export$1ba61c6fa2f892a9)[(0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).toString(key)];
@@ -8292,7 +8319,11 @@ var $93f055b77b2d269f$export$2e2bcd8739ae039 = ({ configuration: configuration ,
8292
8319
  ${(0, $376e205ced98486b$export$79b2f7037acddd43)(line.items, (item)=>`
8293
8320
  ${(0, $376e205ced98486b$export$a55877ca9db47377)((0, $376e205ced98486b$export$17c9e635b932873b)(item), ()=>`
8294
8321
  <div class="column">
8295
- <div class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, key)}</div>
8322
+ <div class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
8323
+ renderKey: key,
8324
+ useUnicodeModifier: configuration.useUnicodeModifiers,
8325
+ normalizeChords: configuration.normalizeChords
8326
+ })}</div>
8296
8327
  <div class="lyrics"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.textFont)}>${item.lyrics}</div>
8297
8328
  </div>
8298
8329
  `)}
@@ -8376,7 +8407,11 @@ var $5381a6b1b90601c7$export$2e2bcd8739ae039 = ({ configuration: configuration ,
8376
8407
  <tr>
8377
8408
  ${(0, $376e205ced98486b$export$79b2f7037acddd43)(line.items, (item)=>`
8378
8409
  ${(0, $376e205ced98486b$export$a55877ca9db47377)((0, $376e205ced98486b$export$17c9e635b932873b)(item), ()=>`
8379
- <td class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, key)}</td>
8410
+ <td class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
8411
+ renderKey: key,
8412
+ useUnicodeModifier: configuration.useUnicodeModifiers,
8413
+ normalizeChords: configuration.normalizeChords
8414
+ })}</td>
8380
8415
  `)}
8381
8416
  `)}
8382
8417
  </tr>
@@ -8520,17 +8555,25 @@ var $5b02ea769c63fd56$export$2e2bcd8739ae039 = $5b02ea769c63fd56$var$HtmlTableFo
8520
8555
  return null;
8521
8556
  }
8522
8557
  chordLyricsPairLength(chordLyricsPair, line) {
8523
- const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(chordLyricsPair.chords, line, this.song, this.configuration.key);
8558
+ const chords = this.renderChords(chordLyricsPair, line);
8524
8559
  const { lyrics: lyrics } = chordLyricsPair;
8525
8560
  const chordsLength = (chords || "").length;
8526
8561
  const lyricsLength = (lyrics || "").length;
8527
8562
  if (chordsLength >= lyricsLength) return chordsLength + 1;
8528
8563
  return Math.max(chordsLength, lyricsLength);
8529
8564
  }
8565
+ renderChords(chordLyricsPair, line) {
8566
+ const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(chordLyricsPair.chords, line, this.song, {
8567
+ renderKey: this.configuration.key,
8568
+ useUnicodeModifier: this.configuration.useUnicodeModifiers,
8569
+ normalizeChords: this.configuration.normalizeChords
8570
+ });
8571
+ return chords;
8572
+ }
8530
8573
  formatItemTop(item, _metadata, line) {
8531
8574
  if (item instanceof (0, $5e9ede69210ec54a$export$2e2bcd8739ae039) && item.isRenderable()) return item.value || "";
8532
8575
  if (item instanceof (0, $d454f4215ba01af2$export$2e2bcd8739ae039)) {
8533
- const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, this.song, this.configuration.key);
8576
+ const chords = this.renderChords(item, line);
8534
8577
  return (0, $21a34a464e7bc609$export$bc3bea8325045070)(chords, this.chordLyricsPairLength(item, line));
8535
8578
  }
8536
8579
  return "";
package/lib/index.js CHANGED
@@ -1213,6 +1213,16 @@ function $bff5407e03fdc8ee$var$modifierTransposition(modifier) {
1213
1213
  * The only function considered public API is `Key.distance`
1214
1214
  */ class $bff5407e03fdc8ee$var$Key {
1215
1215
  modifier = null;
1216
+ get unicodeModifier() {
1217
+ switch(this.modifier){
1218
+ case $bff5407e03fdc8ee$var$FLAT:
1219
+ return "♭";
1220
+ case $bff5407e03fdc8ee$var$SHARP:
1221
+ return "♯";
1222
+ default:
1223
+ return null;
1224
+ }
1225
+ }
1216
1226
  minor = false;
1217
1227
  static parse(keyString) {
1218
1228
  if (!keyString || (0, $21a34a464e7bc609$export$78d1711480f95c3e)(keyString)) return null;
@@ -1322,10 +1332,10 @@ function $bff5407e03fdc8ee$var$modifierTransposition(modifier) {
1322
1332
  toNumeralString(key = null) {
1323
1333
  return this.toNumeral(key).toString();
1324
1334
  }
1325
- toString({ showMinor: showMinor = true } = {}) {
1335
+ toString({ showMinor: showMinor = true , useUnicodeModifier: useUnicodeModifier = false } = {}) {
1326
1336
  switch(this.note.type){
1327
1337
  case 0, $af8d31735c159a26$export$27c95a7104c1f7aa:
1328
- return this.formatChordSymbolString(showMinor);
1338
+ return this.formatChordSymbolString(showMinor, useUnicodeModifier);
1329
1339
  case 0, $af8d31735c159a26$export$4d318981b5a83836:
1330
1340
  return this.formatNumericString(showMinor);
1331
1341
  case 0, $af8d31735c159a26$export$1321df9b16c30c6a:
@@ -1334,8 +1344,9 @@ function $bff5407e03fdc8ee$var$modifierTransposition(modifier) {
1334
1344
  throw new Error(`Unexpected note type ${this.note.type}`);
1335
1345
  }
1336
1346
  }
1337
- formatChordSymbolString(showMinor) {
1338
- return `${this.note}${this.modifier || ""}${this.minor && showMinor ? "m" : ""}`;
1347
+ formatChordSymbolString(showMinor, unicodeModifier) {
1348
+ const modifier = unicodeModifier ? this.unicodeModifier : this.modifier;
1349
+ return `${this.note}${modifier || ""}${this.minor && showMinor ? "m" : ""}`;
1339
1350
  }
1340
1351
  formatNumericString(showMinor) {
1341
1352
  return `${this.modifier || ""}${this.note}${this.minor && showMinor ? "m" : ""}`;
@@ -2485,12 +2496,18 @@ function $26f57998457eb2d4$var$normalizeChordSuffix(suffix) {
2485
2496
  }
2486
2497
  /**
2487
2498
  * Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
2499
+ * @param {Object} [configuration={}] options
2500
+ * @param {boolean} [configuration.useUnicodeModifier=false] Whether or not to use unicode modifiers.
2501
+ * This will make `#` (sharp) look like `♯` and `b` (flat) look like `♭`
2488
2502
  * @returns {string} the chord string
2489
- */ toString() {
2503
+ */ toString({ useUnicodeModifier: useUnicodeModifier = false } = {}) {
2490
2504
  const chordString = this.root.toString({
2491
- showMinor: false
2505
+ showMinor: false,
2506
+ useUnicodeModifier: useUnicodeModifier
2492
2507
  }) + (this.suffix || "");
2493
- if (this.bass) return `${chordString}/${this.bass.toString()}`;
2508
+ if (this.bass) return `${chordString}/${this.bass.toString({
2509
+ useUnicodeModifier: useUnicodeModifier
2510
+ })}`;
2494
2511
  return chordString;
2495
2512
  }
2496
2513
  /**
@@ -2684,7 +2701,9 @@ const $bbcfd2c49e8e9957$export$78c0028a34264234 = {
2684
2701
  separator: ","
2685
2702
  },
2686
2703
  key: null,
2687
- expandChorusDirective: false
2704
+ expandChorusDirective: false,
2705
+ useUnicodeModifiers: false,
2706
+ normalizeChords: true
2688
2707
  };
2689
2708
  class $bbcfd2c49e8e9957$var$Configuration {
2690
2709
  constructor(configuration = $bbcfd2c49e8e9957$export$78c0028a34264234){
@@ -2694,6 +2713,8 @@ class $bbcfd2c49e8e9957$var$Configuration {
2694
2713
  };
2695
2714
  this.evaluate = !!mergedConfig.evaluate;
2696
2715
  this.expandChorusDirective = !!mergedConfig.expandChorusDirective;
2716
+ this.useUnicodeModifiers = !!mergedConfig.useUnicodeModifiers;
2717
+ this.normalizeChords = !!mergedConfig.normalizeChords;
2697
2718
  this.metadata = new (0, $71c330be198ce421$export$2e2bcd8739ae039)(configuration.metadata);
2698
2719
  this.key = configuration.key ? (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(configuration.key) : null;
2699
2720
  this.configuration = configuration;
@@ -2711,17 +2732,19 @@ var $bbcfd2c49e8e9957$export$2e2bcd8739ae039 = $bbcfd2c49e8e9957$var$Configurati
2711
2732
  /**
2712
2733
  * Instantiate
2713
2734
  * @param {Object} [configuration={}] options
2714
- * @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions. For more info about
2715
- * meta expressions, see: https://bit.ly/2SC9c2u
2735
+ * @param {boolean} [configuration.evaluate=false] Whether or not to evaluate meta expressions.
2736
+ * For more info about meta expressions, see: https://bit.ly/2SC9c2u
2716
2737
  * @param {object} [configuration.metadata={}]
2717
- * @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a metadata value
2718
- * that has multiple values. See: https://bit.ly/2SC9c2u
2719
- * @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be transposed
2720
- * from the song's original key (as indicated by the `{key}` directive) to the specified key.
2721
- * Note that transposing will only work
2722
- * if the original song key is set.
2738
+ * @param {string} [configuration.metadata.separator=", "] The separator to be used when rendering a
2739
+ * metadata value that has multiple values. See: https://bit.ly/2SC9c2u
2740
+ * @param {Key|string} [configuration.key=null] The key to use for rendering. The chord sheet will be
2741
+ * transposed from the song's original key (as indicated by the `{key}` directive) to the specified key.
2742
+ * Note that transposing will only work if the original song key is set.
2723
2743
  * @param {boolean} [configuration.expandChorusDirective=false] Whether or not to expand `{chorus}` directives
2724
2744
  * by rendering the last defined chorus inline after the directive.
2745
+ * @param {boolean} [configuration.useUnicodeModifiers=false] Whether or not to use unicode flat and sharp
2746
+ * symbols.
2747
+ * @param {boolean} [configuration.normalizeChords=true] Whether or not to automatically normalize chords
2725
2748
  */ constructor(configuration = null){
2726
2749
  this.configuration = new (0, $bbcfd2c49e8e9957$export$2e2bcd8739ae039)(configuration || {});
2727
2750
  }
@@ -8213,14 +8236,18 @@ function $dfecd32049fa58e9$var$chordTransposeDistance(capo, transposeKey, songKe
8213
8236
  }
8214
8237
  return transpose;
8215
8238
  }
8216
- function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, renderKey = null) {
8239
+ function $dfecd32049fa58e9$export$596ec52955da9472(chordString, line, song, { renderKey: renderKey = null , useUnicodeModifier: useUnicodeModifier = false , normalizeChords: normalizeChords = true } = {}) {
8217
8240
  const chord = (0, $26f57998457eb2d4$export$2e2bcd8739ae039).parse(chordString);
8218
8241
  const songKey = song.key;
8219
8242
  const capo = parseInt(song.metadata.getSingle((0, $5e9ede69210ec54a$export$866f445d49bad88e)), 10);
8220
8243
  if (!chord) return chordString;
8221
8244
  const effectiveTransposeDistance = $dfecd32049fa58e9$var$chordTransposeDistance(capo, line.transposeKey, songKey, renderKey);
8222
8245
  const effectiveKey = renderKey || (0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).wrap(line.key || song.key)?.transpose(effectiveTransposeDistance) || null;
8223
- return chord.transpose(effectiveTransposeDistance).normalize(effectiveKey).toString();
8246
+ const transposedChord = chord.transpose(effectiveTransposeDistance);
8247
+ const normalizedChord = normalizeChords ? transposedChord.normalize(effectiveKey) : transposedChord;
8248
+ return normalizedChord.toString({
8249
+ useUnicodeModifier: useUnicodeModifier
8250
+ });
8224
8251
  }
8225
8252
  function $dfecd32049fa58e9$export$b07b16221c14aaa(key) {
8226
8253
  return (0, $427b789bcf346e61$export$1ba61c6fa2f892a9)[(0, $bff5407e03fdc8ee$export$2e2bcd8739ae039).toString(key)];
@@ -8291,7 +8318,11 @@ var $93f055b77b2d269f$export$2e2bcd8739ae039 = ({ configuration: configuration ,
8291
8318
  ${(0, $376e205ced98486b$export$79b2f7037acddd43)(line.items, (item)=>`
8292
8319
  ${(0, $376e205ced98486b$export$a55877ca9db47377)((0, $376e205ced98486b$export$17c9e635b932873b)(item), ()=>`
8293
8320
  <div class="column">
8294
- <div class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, key)}</div>
8321
+ <div class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
8322
+ renderKey: key,
8323
+ useUnicodeModifier: configuration.useUnicodeModifiers,
8324
+ normalizeChords: configuration.normalizeChords
8325
+ })}</div>
8295
8326
  <div class="lyrics"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.textFont)}>${item.lyrics}</div>
8296
8327
  </div>
8297
8328
  `)}
@@ -8375,7 +8406,11 @@ var $5381a6b1b90601c7$export$2e2bcd8739ae039 = ({ configuration: configuration ,
8375
8406
  <tr>
8376
8407
  ${(0, $376e205ced98486b$export$79b2f7037acddd43)(line.items, (item)=>`
8377
8408
  ${(0, $376e205ced98486b$export$a55877ca9db47377)((0, $376e205ced98486b$export$17c9e635b932873b)(item), ()=>`
8378
- <td class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, key)}</td>
8409
+ <td class="chord"${(0, $376e205ced98486b$export$ca030c9435779e4b)(line.chordFont)}>${(0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, song, {
8410
+ renderKey: key,
8411
+ useUnicodeModifier: configuration.useUnicodeModifiers,
8412
+ normalizeChords: configuration.normalizeChords
8413
+ })}</td>
8379
8414
  `)}
8380
8415
  `)}
8381
8416
  </tr>
@@ -8519,17 +8554,25 @@ var $5b02ea769c63fd56$export$2e2bcd8739ae039 = $5b02ea769c63fd56$var$HtmlTableFo
8519
8554
  return null;
8520
8555
  }
8521
8556
  chordLyricsPairLength(chordLyricsPair, line) {
8522
- const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(chordLyricsPair.chords, line, this.song, this.configuration.key);
8557
+ const chords = this.renderChords(chordLyricsPair, line);
8523
8558
  const { lyrics: lyrics } = chordLyricsPair;
8524
8559
  const chordsLength = (chords || "").length;
8525
8560
  const lyricsLength = (lyrics || "").length;
8526
8561
  if (chordsLength >= lyricsLength) return chordsLength + 1;
8527
8562
  return Math.max(chordsLength, lyricsLength);
8528
8563
  }
8564
+ renderChords(chordLyricsPair, line) {
8565
+ const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(chordLyricsPair.chords, line, this.song, {
8566
+ renderKey: this.configuration.key,
8567
+ useUnicodeModifier: this.configuration.useUnicodeModifiers,
8568
+ normalizeChords: this.configuration.normalizeChords
8569
+ });
8570
+ return chords;
8571
+ }
8529
8572
  formatItemTop(item, _metadata, line) {
8530
8573
  if (item instanceof (0, $5e9ede69210ec54a$export$2e2bcd8739ae039) && item.isRenderable()) return item.value || "";
8531
8574
  if (item instanceof (0, $d454f4215ba01af2$export$2e2bcd8739ae039)) {
8532
- const chords = (0, $dfecd32049fa58e9$export$596ec52955da9472)(item.chords, line, this.song, this.configuration.key);
8575
+ const chords = this.renderChords(item, line);
8533
8576
  return (0, $21a34a464e7bc609$export$bc3bea8325045070)(chords, this.chordLyricsPairLength(item, line));
8534
8577
  }
8535
8578
  return "";