chordsheetjs 6.0.0 → 6.0.2
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/.husky/pre-commit +5 -0
- package/README.md +49 -3
- package/package.json +8 -3
- package/d7b54993c4ea66c07a35bd36690482ab620f836e.patch +0 -105
package/README.md
CHANGED
|
@@ -466,6 +466,9 @@ Inherits from <a href="#ChordSheetParser">ChordSheetParser</a></p>
|
|
|
466
466
|
<dt><a href="#TITLE">TITLE</a> : <code>string</code></dt>
|
|
467
467
|
<dd><p>Title meta directive. See <a href="https://www.chordpro.org/chordpro/directives-title/">https://www.chordpro.org/chordpro/directives-title/</a></p>
|
|
468
468
|
</dd>
|
|
469
|
+
<dt><a href="#TRANSPOSE">TRANSPOSE</a> : <code>string</code></dt>
|
|
470
|
+
<dd><p>Transpose meta directive. See: <a href="https://www.chordpro.org/chordpro/directives-transpose/">https://www.chordpro.org/chordpro/directives-transpose/</a></p>
|
|
471
|
+
</dd>
|
|
469
472
|
<dt><a href="#YEAR">YEAR</a> : <code>string</code></dt>
|
|
470
473
|
<dd><p>Year meta directive. See <a href="https://www.chordpro.org/chordpro/directives-year/">https://www.chordpro.org/chordpro/directives-year/</a></p>
|
|
471
474
|
</dd>
|
|
@@ -1176,8 +1179,11 @@ Represents a Chord, consisting of a root, suffix (quality) and bass
|
|
|
1176
1179
|
* [.toChordSymbolString(key)](#Chord+toChordSymbolString) ⇒ <code>string</code>
|
|
1177
1180
|
* [.isChordSymbol()](#Chord+isChordSymbol) ⇒ <code>boolean</code>
|
|
1178
1181
|
* [.toNumeric(key)](#Chord+toNumeric) ⇒ [<code>Chord</code>](#Chord)
|
|
1182
|
+
* [.toNumeral(key)](#Chord+toNumeral) ⇒ [<code>Chord</code>](#Chord)
|
|
1183
|
+
* [.toNumeralString(key)](#Chord+toNumeralString) ⇒ <code>string</code>
|
|
1179
1184
|
* [.isNumeric()](#Chord+isNumeric) ⇒ <code>boolean</code>
|
|
1180
1185
|
* [.toNumericString(key)](#Chord+toNumericString) ⇒ <code>string</code>
|
|
1186
|
+
* [.isNumeral()](#Chord+isNumeral) ⇒ <code>boolean</code>
|
|
1181
1187
|
* [.toString()](#Chord+toString) ⇒ <code>string</code>
|
|
1182
1188
|
* [.normalize()](#Chord+normalize) ⇒ [<code>Chord</code>](#Chord)
|
|
1183
1189
|
* [.useModifier(newModifier)](#Chord+useModifier) ⇒ [<code>Chord</code>](#Chord)
|
|
@@ -1231,7 +1237,7 @@ Determines whether the chord is a chord symbol
|
|
|
1231
1237
|
<a name="Chord+toNumeric"></a>
|
|
1232
1238
|
|
|
1233
1239
|
### chord.toNumeric(key) ⇒ [<code>Chord</code>](#Chord)
|
|
1234
|
-
Converts the chord to a numeric chord, using the supplied
|
|
1240
|
+
Converts the chord to a numeric chord, using the supplied key as a reference.
|
|
1235
1241
|
For example, a chord symbol A# with reference key E will return the numeric chord #4.
|
|
1236
1242
|
|
|
1237
1243
|
**Kind**: instance method of [<code>Chord</code>](#Chord)
|
|
@@ -1241,6 +1247,33 @@ For example, a chord symbol A# with reference key E will return the numeric chor
|
|
|
1241
1247
|
| --- | --- | --- |
|
|
1242
1248
|
| key | <code>Key</code> \| <code>string</code> | the reference key |
|
|
1243
1249
|
|
|
1250
|
+
<a name="Chord+toNumeral"></a>
|
|
1251
|
+
|
|
1252
|
+
### chord.toNumeral(key) ⇒ [<code>Chord</code>](#Chord)
|
|
1253
|
+
Converts the chord to a numeral chord, using the supplied key as a reference.
|
|
1254
|
+
For example, a chord symbol A# with reference key E will return the numeral chord #IV.
|
|
1255
|
+
|
|
1256
|
+
**Kind**: instance method of [<code>Chord</code>](#Chord)
|
|
1257
|
+
**Returns**: [<code>Chord</code>](#Chord) - the numeral chord
|
|
1258
|
+
|
|
1259
|
+
| Param | Type | Default | Description |
|
|
1260
|
+
| --- | --- | --- | --- |
|
|
1261
|
+
| key | <code>Key</code> \| <code>string</code> \| <code>null</code> | <code></code> | the reference key. The key is required when converting a chord symbol |
|
|
1262
|
+
|
|
1263
|
+
<a name="Chord+toNumeralString"></a>
|
|
1264
|
+
|
|
1265
|
+
### chord.toNumeralString(key) ⇒ <code>string</code>
|
|
1266
|
+
Converts the chord to a numeral chord string, using the supplied kye as a reference.
|
|
1267
|
+
For example, a chord symbol A# with reference key E will return the numeral chord #4.
|
|
1268
|
+
|
|
1269
|
+
**Kind**: instance method of [<code>Chord</code>](#Chord)
|
|
1270
|
+
**Returns**: <code>string</code> - the numeral chord string
|
|
1271
|
+
**See**: {toNumeral}
|
|
1272
|
+
|
|
1273
|
+
| Param | Type | Description |
|
|
1274
|
+
| --- | --- | --- |
|
|
1275
|
+
| key | <code>Key</code> \| <code>string</code> | the reference key |
|
|
1276
|
+
|
|
1244
1277
|
<a name="Chord+isNumeric"></a>
|
|
1245
1278
|
|
|
1246
1279
|
### chord.isNumeric() ⇒ <code>boolean</code>
|
|
@@ -1261,6 +1294,12 @@ For example, a chord symbol A# with reference key E will return the numeric chor
|
|
|
1261
1294
|
| --- | --- | --- |
|
|
1262
1295
|
| key | <code>Key</code> \| <code>string</code> | the reference key |
|
|
1263
1296
|
|
|
1297
|
+
<a name="Chord+isNumeral"></a>
|
|
1298
|
+
|
|
1299
|
+
### chord.isNumeral() ⇒ <code>boolean</code>
|
|
1300
|
+
Determines whether the chord is a numeral
|
|
1301
|
+
|
|
1302
|
+
**Kind**: instance method of [<code>Chord</code>](#Chord)
|
|
1264
1303
|
<a name="Chord+toString"></a>
|
|
1265
1304
|
|
|
1266
1305
|
### chord.toString() ⇒ <code>string</code>
|
|
@@ -1271,7 +1310,7 @@ Converts the chord to a string, eg `Esus4/G#` or `1sus4/#3`
|
|
|
1271
1310
|
<a name="Chord+normalize"></a>
|
|
1272
1311
|
|
|
1273
1312
|
### chord.normalize() ⇒ [<code>Chord</code>](#Chord)
|
|
1274
|
-
Normalizes the chord:
|
|
1313
|
+
Normalizes the chord root and bass notes:
|
|
1275
1314
|
- Fb becomes E
|
|
1276
1315
|
- Cb becomes B
|
|
1277
1316
|
- B# becomes C
|
|
@@ -1281,7 +1320,8 @@ Normalizes the chord:
|
|
|
1281
1320
|
- 7# becomes 1
|
|
1282
1321
|
- 3# becomes 4
|
|
1283
1322
|
|
|
1284
|
-
|
|
1323
|
+
Besides that it normalizes the suffix. For example, `sus2` becomes `2`, `sus4` becomes `sus`.
|
|
1324
|
+
All suffix normalizations can be found in `src/normalize_mappings/suffix-mapping.txt`.
|
|
1285
1325
|
|
|
1286
1326
|
**Kind**: instance method of [<code>Chord</code>](#Chord)
|
|
1287
1327
|
**Returns**: [<code>Chord</code>](#Chord) - the normalized chord
|
|
@@ -1484,6 +1524,12 @@ Time meta directive. See https://www.chordpro.org/chordpro/directives-time/
|
|
|
1484
1524
|
## TITLE : <code>string</code>
|
|
1485
1525
|
Title meta directive. See https://www.chordpro.org/chordpro/directives-title/
|
|
1486
1526
|
|
|
1527
|
+
**Kind**: global constant
|
|
1528
|
+
<a name="TRANSPOSE"></a>
|
|
1529
|
+
|
|
1530
|
+
## TRANSPOSE : <code>string</code>
|
|
1531
|
+
Transpose meta directive. See: https://www.chordpro.org/chordpro/directives-transpose/
|
|
1532
|
+
|
|
1487
1533
|
**Kind**: global constant
|
|
1488
1534
|
<a name="YEAR"></a>
|
|
1489
1535
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chordsheetjs",
|
|
3
3
|
"author": "Martijn Versluis",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.2",
|
|
5
5
|
"description": "A JavaScript library for parsing and formatting chord sheets",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"license": "GPL-2.0-only",
|
|
@@ -23,9 +23,11 @@
|
|
|
23
23
|
"eslint": "^8.3.0",
|
|
24
24
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
25
25
|
"eslint-plugin-import": "^2.21.2",
|
|
26
|
+
"husky": "^7.0.0",
|
|
26
27
|
"jest": "^27.0.1",
|
|
27
28
|
"jsdoc-to-markdown": "^7.1.0",
|
|
28
29
|
"pegjs": "^0.10.0",
|
|
30
|
+
"pinst": "^2.1.6",
|
|
29
31
|
"print": "^1.2.0"
|
|
30
32
|
},
|
|
31
33
|
"scripts": {
|
|
@@ -41,8 +43,11 @@
|
|
|
41
43
|
"lint": "yarn build:code-generate && node_modules/.bin/eslint --ext .js .",
|
|
42
44
|
"lint:fix": "node_modules/.bin/eslint --fix --ext .js .",
|
|
43
45
|
"readme": "jsdoc2md -f src/**/*.js -f src/*.js --template doc/README.hbs > README.md",
|
|
44
|
-
"prepublishOnly": "yarn install && yarn test && yarn build",
|
|
45
|
-
"
|
|
46
|
+
"prepublishOnly": "pinst --disable && yarn install && yarn test && yarn build",
|
|
47
|
+
"postpublish": "pinst --enable",
|
|
48
|
+
"pretest": "yarn build:code-generate",
|
|
49
|
+
"prepare": "husky install",
|
|
50
|
+
"_postinstall": "husky install"
|
|
46
51
|
},
|
|
47
52
|
"dependencies": {
|
|
48
53
|
"handlebars": "^4.7.6"
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
commit d7b54993c4ea66c07a35bd36690482ab620f836e
|
|
2
|
-
Author: Martijn Versluis <martijnversluis@users.noreply.github.com>
|
|
3
|
-
Date: Sun Jan 30 16:35:24 2022 +0100
|
|
4
|
-
|
|
5
|
-
Do not rely on contructor name
|
|
6
|
-
|
|
7
|
-
Due to build tools scrambling constructor names, we can not rely on those
|
|
8
|
-
for type checking. Thus we have to use `instanceof`. This change removes
|
|
9
|
-
usages of `constructor.name` and solves the cyclic dependency by moving around
|
|
10
|
-
some functions.
|
|
11
|
-
|
|
12
|
-
Resolves #421
|
|
13
|
-
|
|
14
|
-
diff --git a/src/formatter/html_div_formatter.js b/src/formatter/html_div_formatter.js
|
|
15
|
-
index f92f532..b1de230 100644
|
|
16
|
-
--- a/src/formatter/html_div_formatter.js
|
|
17
|
-
+++ b/src/formatter/html_div_formatter.js
|
|
18
|
-
@@ -1,6 +1,6 @@
|
|
19
|
-
import Handlebars from 'handlebars';
|
|
20
|
-
|
|
21
|
-
-import '../handlebars_helpers';
|
|
22
|
-
+import '../template_helpers';
|
|
23
|
-
import HtmlFormatter from './html_formatter';
|
|
24
|
-
import './templates/html_div_formatter';
|
|
25
|
-
import { scopeCss } from '../utilities';
|
|
26
|
-
diff --git a/src/formatter/html_table_formatter.js b/src/formatter/html_table_formatter.js
|
|
27
|
-
index 4883fef..7d7e8ea 100644
|
|
28
|
-
--- a/src/formatter/html_table_formatter.js
|
|
29
|
-
+++ b/src/formatter/html_table_formatter.js
|
|
30
|
-
@@ -1,6 +1,6 @@
|
|
31
|
-
import Handlebars from 'handlebars';
|
|
32
|
-
|
|
33
|
-
-import '../handlebars_helpers';
|
|
34
|
-
+import '../template_helpers';
|
|
35
|
-
import HtmlFormatter from './html_formatter';
|
|
36
|
-
import './templates/html_table_formatter';
|
|
37
|
-
import { scopeCss } from '../utilities';
|
|
38
|
-
diff --git a/src/formatter/text_formatter.js b/src/formatter/text_formatter.js
|
|
39
|
-
index 61385f1..81fe226 100644
|
|
40
|
-
--- a/src/formatter/text_formatter.js
|
|
41
|
-
+++ b/src/formatter/text_formatter.js
|
|
42
|
-
@@ -1,10 +1,10 @@
|
|
43
|
-
import ChordLyricsPair from '../chord_sheet/chord_lyrics_pair';
|
|
44
|
-
import Tag from '../chord_sheet/tag';
|
|
45
|
-
import { renderChord } from '../helpers';
|
|
46
|
-
+import { hasTextContents } from '../template_helpers';
|
|
47
|
-
|
|
48
|
-
import {
|
|
49
|
-
hasChordContents,
|
|
50
|
-
- hasTextContents,
|
|
51
|
-
padLeft,
|
|
52
|
-
} from '../utilities';
|
|
53
|
-
|
|
54
|
-
diff --git a/src/handlebars_helpers.js b/src/template_helpers.js
|
|
55
|
-
similarity index 87%
|
|
56
|
-
rename from src/handlebars_helpers.js
|
|
57
|
-
rename to src/template_helpers.js
|
|
58
|
-
index 0e5ff98..b330f87 100644
|
|
59
|
-
--- a/src/handlebars_helpers.js
|
|
60
|
-
+++ b/src/template_helpers.js
|
|
61
|
-
@@ -7,12 +7,20 @@ import { renderChord } from './helpers';
|
|
62
|
-
|
|
63
|
-
import {
|
|
64
|
-
hasChordContents,
|
|
65
|
-
- hasTextContents,
|
|
66
|
-
isEvaluatable,
|
|
67
|
-
} from './utilities';
|
|
68
|
-
|
|
69
|
-
const lineHasContents = (line) => line.items.some((item) => item.isRenderable());
|
|
70
|
-
|
|
71
|
-
+/* eslint import/prefer-default-export: 0 */
|
|
72
|
-
+export const hasTextContents = (line) => (
|
|
73
|
-
+ line.items.some((item) => (
|
|
74
|
-
+ (item instanceof ChordLyricsPair && item.lyrics)
|
|
75
|
-
+ || (item instanceof Tag && item.isRenderable())
|
|
76
|
-
+ || isEvaluatable(item)
|
|
77
|
-
+ ))
|
|
78
|
-
+);
|
|
79
|
-
+
|
|
80
|
-
HandleBars.registerHelper('isChordLyricsPair', (item) => item instanceof ChordLyricsPair);
|
|
81
|
-
|
|
82
|
-
HandleBars.registerHelper('isTag', (item) => item instanceof Tag);
|
|
83
|
-
diff --git a/src/utilities.js b/src/utilities.js
|
|
84
|
-
index 03c69cc..503c811 100644
|
|
85
|
-
--- a/src/utilities.js
|
|
86
|
-
+++ b/src/utilities.js
|
|
87
|
-
@@ -8,18 +8,6 @@ export const hasChordContents = (line) => line.items.some((item) => !!item.chord
|
|
88
|
-
|
|
89
|
-
export const isEvaluatable = (item) => typeof item.evaluate === 'function';
|
|
90
|
-
|
|
91
|
-
-function isInstanceOf(object, constructorName) {
|
|
92
|
-
- return object?.constructor?.name === constructorName;
|
|
93
|
-
-}
|
|
94
|
-
-
|
|
95
|
-
-export const hasTextContents = (line) => (
|
|
96
|
-
- line.items.some((item) => (
|
|
97
|
-
- (isInstanceOf(item, 'ChordLyricsPair') && item.lyrics)
|
|
98
|
-
- || (isInstanceOf(item, 'Tag') && item.isRenderable())
|
|
99
|
-
- || isEvaluatable(item)
|
|
100
|
-
- ))
|
|
101
|
-
-);
|
|
102
|
-
-
|
|
103
|
-
export const padLeft = (str, length) => {
|
|
104
|
-
let paddedString = str;
|
|
105
|
-
for (let l = str.length; l < length; l += 1, paddedString += ' ');
|