text-guitar-chart 0.0.3 → 0.0.4

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.
@@ -411,8 +411,8 @@ export default function stringToFingering(fingeringStr, options = {}) {
411
411
  else if (char === UNICODE_OPEN || char === ASCII_OPEN) {
412
412
  fingers.push([stringNum, fretNumber, { text: "", color: blackColor }]);
413
413
  }
414
- // Check for finger number (digit)
415
- else if (/[0-9]/.test(char)) {
414
+ // Check for finger label (digit or any other character)
415
+ else if (/\S/.test(char)) {
416
416
  fingers.push([stringNum, fretNumber, { text: char, color: blackColor }]);
417
417
  }
418
418
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "text-guitar-chart",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "A JavaScript library to write text based guitar chord charts and convert them to SVG.",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -440,6 +440,69 @@ describe("stringToFingering", () => {
440
440
  );
441
441
  assert.deepEqual(result?.barres, [], "Barres should be empty");
442
442
  });
443
+
444
+ test("parses E dom 7 chord with finger characters", () => {
445
+ const fingeringStr = ` E dom 7
446
+ #######
447
+ x x
448
+ ------
449
+ |||#||
450
+ |BE|||
451
+ ||||D|`;
452
+
453
+ const result = stringToFingering(fingeringStr);
454
+ assert.equal(
455
+ fingersContains(result, [
456
+ [
457
+ 5,
458
+ 2,
459
+ {
460
+ text: "B",
461
+ color: "#000000",
462
+ },
463
+ ],
464
+ [
465
+ 4,
466
+ 2,
467
+ {
468
+ text: "E",
469
+ color: "#000000",
470
+ },
471
+ ],
472
+ [
473
+ 3,
474
+ 1,
475
+ {
476
+ text: "#",
477
+ color: "#000000",
478
+ },
479
+ ],
480
+ [
481
+ 2,
482
+ 3,
483
+ {
484
+ text: "D",
485
+ color: "#000000",
486
+ },
487
+ ],
488
+ [6, "x", {text: "", color: "#000000"}],
489
+ [1, "x", {text: "", color: "#000000"}],
490
+ ]),
491
+ true,
492
+ "Fingering does not match expected E dom 7 chord with finger numbers"
493
+ );
494
+ assert.equal(
495
+ result?.title,
496
+ "E dom 7",
497
+ "Title does not match expected E dom 7"
498
+ );
499
+ assert.equal(
500
+ result?.position,
501
+ undefined,
502
+ "Position does not match expected undefined"
503
+ );
504
+ assert.deepEqual(result?.barres, [], "Barres should be empty");
505
+ });
443
506
  });
444
507
 
445
508
  describe("Unicode format parsing", () => {
@@ -857,8 +920,76 @@ describe("stringToFingering", () => {
857
920
  );
858
921
  assert.deepEqual(result?.barres, [], "Barres should be empty");
859
922
  });
923
+
924
+ test("parses E dom 7 with finger characters (Unicode format)", () => {
925
+ const fingeringStr = ` E dom 7
926
+ ‾‾‾‾‾‾‾‾‾‾‾
927
+ × ×
928
+ ┌─┬─┬─┬─┬─┐
929
+ │ │ │ # │ │
930
+ ├─┼─┼─┼─┼─┤
931
+ │ B E │ │ │
932
+ ├─┼─┼─┼─┼─┤
933
+ │ │ │ │ D │
934
+ └─┴─┴─┴─┴─┘`;
935
+
936
+ const result = stringToFingering(fingeringStr);
937
+ assert.equal(
938
+ fingersContains(result, [
939
+ [
940
+ 5,
941
+ 2,
942
+ {
943
+ text: "B",
944
+ color: "#000000",
945
+ },
946
+ ],
947
+ [
948
+ 4,
949
+ 2,
950
+ {
951
+ text: "E",
952
+ color: "#000000",
953
+ },
954
+ ],
955
+ [
956
+ 3,
957
+ 1,
958
+ {
959
+ text: "#",
960
+ color: "#000000",
961
+ },
962
+ ],
963
+ [
964
+ 2,
965
+ 3,
966
+ {
967
+ text: "D",
968
+ color: "#000000",
969
+ },
970
+ ],
971
+ [6, "x", {text: "", color: "#000000"}],
972
+ [1, "x", {text: "", color: "#000000"}],
973
+ ]),
974
+ true,
975
+ "Fingering does not match expected E dom 7 chord with finger numbers"
976
+ );
977
+ assert.equal(
978
+ result?.title,
979
+ "E dom 7",
980
+ "Title does not match expected E dom 7"
981
+ );
982
+ assert.equal(
983
+ result?.position,
984
+ undefined,
985
+ "Position does not match expected undefined"
986
+ );
987
+ assert.deepEqual(result?.barres, [], "Barres should be empty");
988
+ });
989
+
860
990
  });
861
991
 
992
+
862
993
  describe("Edge cases and variations", () => {
863
994
  test("handles empty fingering string", () => {
864
995
  const result = stringToFingering("");