@dsebastien/music-notation 0.16.0 → 0.18.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.
@@ -431,6 +431,8 @@ var SIGN = "(##|bb|#|b|♯|♭)?";
431
431
  var syllableLetter = (syllable) => SYLLABLE_LETTER[plain2(syllable)];
432
432
  var AFTER_ROOT = /^(?:$|[0-9/(+°øΔ^-]|m|M|a(?:dd|ug|lt)|sus|dim)/;
433
433
  var QUALITY_WORD = /^(?:[0-9(+°øΔ^]|m|M|a(?:dd|ug|lt)|sus|dim)/;
434
+ var WORD_QUALITY = /^(?:major|minor)$/i;
435
+ var joinsAsQuality = (word) => QUALITY_WORD.test(word) && !WORD_QUALITY.test(word);
434
436
  var reads = (letters) => midiOf(letters) !== null || /^[A-G]/.test(letters) && parseChord(letters) !== null;
435
437
  function rootToken(token, naming, h, solfegeLine = false) {
436
438
  const b = naming === "german" ? /^B(?![#♯b♭x])(.*)$/.exec(token) : null;
@@ -501,7 +503,7 @@ function read(text, naming, options, changes) {
501
503
  let out = text.normalize("NFC").replace(new RegExp(`(^|[\\s,/|])${SYLLABLE}\\s+(dièse|diese|bémol|bemol)(?=$|[\\s,|])`, "g"), (_, before, syllable, sign) => `${before}${syllable}${/^d/.test(sign) ? "#" : "b"}`);
502
504
  if (options.chord) {
503
505
  const joined = new RegExp(`^\\s*${SYLLABLE}${SIGN}\\s+(\\S+)\\s*$`).exec(out);
504
- if (joined && QUALITY_WORD.test(joined[3])) {
506
+ if (joined && joinsAsQuality(joined[3])) {
505
507
  const word = `${joined[1]}${joined[2] ?? ""}${joined[3]}`;
506
508
  const letters = rootToken(word, naming, h) ?? letterPiece(word, naming, h);
507
509
  if (letters !== word) {
@@ -514,7 +516,7 @@ function read(text, naming, options, changes) {
514
516
  for (let i = 0;i + 2 < words.length; i += 2) {
515
517
  const head = words[i];
516
518
  const next = words[i + 2];
517
- if (!syllableOnly(head) || !QUALITY_WORD.test(next))
519
+ if (!syllableOnly(head) || !joinsAsQuality(next))
518
520
  continue;
519
521
  if (naming !== "solfege" && reads(head))
520
522
  continue;
@@ -2170,5 +2172,5 @@ export {
2170
2172
  voicingCount
2171
2173
  };
2172
2174
 
2173
- //# debugId=35CF2EE7E1A5854D64756E2164756E21
2175
+ //# debugId=92E85F892552F21C64756E2164756E21
2174
2176
  //# sourceMappingURL=index.js.map