chordsheetjs 6.1.0 → 6.3.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 +481 -572
- package/lib/bundle.js +15393 -0
- package/lib/index.js +6290 -216
- package/lib/index.js.map +1 -0
- package/lib/main.d.ts +1095 -0
- package/lib/main.d.ts.map +1 -0
- package/package.json +43 -21
- package/.husky/pre-commit +0 -5
- package/lib/chord.js +0 -496
- package/lib/chord_sheet/chord_lyrics_pair.js +0 -80
- package/lib/chord_sheet/chord_pro/composite.js +0 -54
- package/lib/chord_sheet/chord_pro/evaluation_error.js +0 -58
- package/lib/chord_sheet/chord_pro/literal.js +0 -42
- package/lib/chord_sheet/chord_pro/ternary.js +0 -126
- package/lib/chord_sheet/comment.js +0 -55
- package/lib/chord_sheet/line.js +0 -207
- package/lib/chord_sheet/metadata.js +0 -216
- package/lib/chord_sheet/paragraph.js +0 -88
- package/lib/chord_sheet/song.js +0 -531
- package/lib/chord_sheet/tag.js +0 -359
- package/lib/chord_sheet_serializer.js +0 -278
- package/lib/constants.js +0 -54
- package/lib/formatter/chord_pro_formatter.js +0 -184
- package/lib/formatter/html_div_formatter.js +0 -130
- package/lib/formatter/html_formatter.js +0 -44
- package/lib/formatter/html_table_formatter.js +0 -154
- package/lib/formatter/templates/html_div_formatter.js +0 -544
- package/lib/formatter/templates/html_table_formatter.js +0 -731
- package/lib/formatter/text_formatter.js +0 -184
- package/lib/helpers.js +0 -56
- package/lib/key.js +0 -386
- package/lib/normalize_mappings/enharmonic-normalize.js +0 -124
- package/lib/normalize_mappings/generate-suffix-normalize-mapping.js +0 -36
- package/lib/normalize_mappings/suffix-normalize-mapping.js +0 -914
- package/lib/note.js +0 -264
- package/lib/parser/chord_pro_parser.js +0 -64
- package/lib/parser/chord_pro_peg_parser.js +0 -2069
- package/lib/parser/chord_sheet_parser.js +0 -175
- package/lib/parser/parser_warning.js +0 -62
- package/lib/parser/ultimate_guitar_parser.js +0 -154
- package/lib/template_helpers.js +0 -98
- package/lib/utilities.js +0 -110
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _tag = _interopRequireDefault(require("../chord_sheet/tag"));
|
|
9
|
-
|
|
10
|
-
var _chord_lyrics_pair = _interopRequireDefault(require("../chord_sheet/chord_lyrics_pair"));
|
|
11
|
-
|
|
12
|
-
var _ternary = _interopRequireDefault(require("../chord_sheet/chord_pro/ternary"));
|
|
13
|
-
|
|
14
|
-
var _literal = _interopRequireDefault(require("../chord_sheet/chord_pro/literal"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
-
|
|
20
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
21
|
-
|
|
22
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
23
|
-
|
|
24
|
-
var NEW_LINE = '\n';
|
|
25
|
-
/**
|
|
26
|
-
* Formats a song into a ChordPro chord sheet
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
var ChordProFormatter = /*#__PURE__*/function () {
|
|
30
|
-
/**
|
|
31
|
-
* Instantiate
|
|
32
|
-
* @param {Object} options options
|
|
33
|
-
* @param {boolean} options.evaluate Whether or not to evaluate meta expressions. For more info about meta
|
|
34
|
-
* expression, see: https://bit.ly/2SC9c2u
|
|
35
|
-
*/
|
|
36
|
-
function ChordProFormatter() {
|
|
37
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
38
|
-
_ref$evaluate = _ref.evaluate,
|
|
39
|
-
evaluate = _ref$evaluate === void 0 ? false : _ref$evaluate;
|
|
40
|
-
|
|
41
|
-
_classCallCheck(this, ChordProFormatter);
|
|
42
|
-
|
|
43
|
-
this.evaluate = evaluate === true;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Formats a song into a ChordPro chord sheet.
|
|
47
|
-
* @param {Song} song The song to be formatted
|
|
48
|
-
* @returns {string} The ChordPro string
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
_createClass(ChordProFormatter, [{
|
|
53
|
-
key: "format",
|
|
54
|
-
value: function format(song) {
|
|
55
|
-
var _this = this;
|
|
56
|
-
|
|
57
|
-
var lines = song.lines,
|
|
58
|
-
metadata = song.metadata;
|
|
59
|
-
return lines.map(function (line) {
|
|
60
|
-
return _this.formatLine(line, metadata);
|
|
61
|
-
}).join(NEW_LINE);
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "formatLine",
|
|
65
|
-
value: function formatLine(line, metadata) {
|
|
66
|
-
var _this2 = this;
|
|
67
|
-
|
|
68
|
-
return line.items.map(function (item) {
|
|
69
|
-
return _this2.formatItem(item, metadata);
|
|
70
|
-
}).join('');
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
|
-
key: "formatItem",
|
|
74
|
-
value: function formatItem(item, metadata) {
|
|
75
|
-
if (item instanceof _tag["default"]) {
|
|
76
|
-
return this.formatTag(item);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (item instanceof _chord_lyrics_pair["default"]) {
|
|
80
|
-
return this.formatChordLyricsPair(item);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (typeof item.evaluate === 'function') {
|
|
84
|
-
return this.formatOrEvaluateItem(item, metadata);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
throw new Error("Don't know how to format a ".concat(item.constructor.name));
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
key: "formatOrEvaluateItem",
|
|
91
|
-
value: function formatOrEvaluateItem(item, metadata) {
|
|
92
|
-
if (this.evaluate) {
|
|
93
|
-
return item.evaluate(metadata);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (item instanceof _ternary["default"]) {
|
|
97
|
-
return this.formatTernary(item);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (item instanceof _literal["default"]) {
|
|
101
|
-
return item.evaluate();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
throw new Error("Don't know how to format a ".concat(item.constructor.name));
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "formatTernary",
|
|
108
|
-
value: function formatTernary(ternary) {
|
|
109
|
-
var variable = ternary.variable,
|
|
110
|
-
valueTest = ternary.valueTest,
|
|
111
|
-
trueExpression = ternary.trueExpression,
|
|
112
|
-
falseExpression = ternary.falseExpression;
|
|
113
|
-
return ['%{', variable || '', this.formatValueTest(valueTest), this.formatExpressionRange(trueExpression), this.formatExpressionRange(falseExpression), '}'].join('');
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "formatValueTest",
|
|
117
|
-
value: function formatValueTest(valueTest) {
|
|
118
|
-
if (!valueTest) {
|
|
119
|
-
return '';
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return "=".concat(valueTest);
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "formatExpressionRange",
|
|
126
|
-
value: function formatExpressionRange(expressionRange) {
|
|
127
|
-
var _this3 = this;
|
|
128
|
-
|
|
129
|
-
if (!expressionRange) {
|
|
130
|
-
return '';
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return "|".concat(expressionRange.map(function (expression) {
|
|
134
|
-
return _this3.formatExpression(expression);
|
|
135
|
-
}).join(''));
|
|
136
|
-
}
|
|
137
|
-
}, {
|
|
138
|
-
key: "formatExpression",
|
|
139
|
-
value: function formatExpression(expression) {
|
|
140
|
-
if (expression instanceof _ternary["default"]) {
|
|
141
|
-
return this.formatTernary(expression);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (expression instanceof _literal["default"]) {
|
|
145
|
-
return expression.string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return '';
|
|
149
|
-
}
|
|
150
|
-
}, {
|
|
151
|
-
key: "formatTag",
|
|
152
|
-
value: function formatTag(tag) {
|
|
153
|
-
if (tag.hasValue()) {
|
|
154
|
-
return "{".concat(tag.originalName, ": ").concat(tag.value, "}");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return "{".concat(tag.originalName, "}");
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "formatChordLyricsPair",
|
|
161
|
-
value: function formatChordLyricsPair(chordLyricsPair) {
|
|
162
|
-
return [this.formatChordLyricsPairChords(chordLyricsPair), this.formatChordLyricsPairLyrics(chordLyricsPair)].join('');
|
|
163
|
-
}
|
|
164
|
-
}, {
|
|
165
|
-
key: "formatChordLyricsPairChords",
|
|
166
|
-
value: function formatChordLyricsPairChords(chordLyricsPair) {
|
|
167
|
-
if (chordLyricsPair.chords) {
|
|
168
|
-
return "[".concat(chordLyricsPair.chords, "]");
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return '';
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "formatChordLyricsPairLyrics",
|
|
175
|
-
value: function formatChordLyricsPairLyrics(chordLyricsPair) {
|
|
176
|
-
return chordLyricsPair.lyrics || '';
|
|
177
|
-
}
|
|
178
|
-
}]);
|
|
179
|
-
|
|
180
|
-
return ChordProFormatter;
|
|
181
|
-
}();
|
|
182
|
-
|
|
183
|
-
var _default = ChordProFormatter;
|
|
184
|
-
exports["default"] = _default;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _handlebars = _interopRequireDefault(require("handlebars"));
|
|
11
|
-
|
|
12
|
-
require("../template_helpers");
|
|
13
|
-
|
|
14
|
-
var _html_formatter = _interopRequireDefault(require("./html_formatter"));
|
|
15
|
-
|
|
16
|
-
require("./templates/html_div_formatter");
|
|
17
|
-
|
|
18
|
-
var _utilities = require("../utilities");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
24
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
25
|
-
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
|
-
|
|
28
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
|
-
|
|
30
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
-
|
|
32
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
-
|
|
34
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
|
-
|
|
36
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
-
|
|
38
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
-
|
|
40
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
-
|
|
42
|
-
var template = _handlebars["default"].templates.html_div_formatter;
|
|
43
|
-
var defaultCss = {
|
|
44
|
-
'.chord:not(:last-child)': {
|
|
45
|
-
paddingRight: '10px'
|
|
46
|
-
},
|
|
47
|
-
'.paragraph': {
|
|
48
|
-
marginBottom: '1em'
|
|
49
|
-
},
|
|
50
|
-
'.row': {
|
|
51
|
-
display: 'flex'
|
|
52
|
-
},
|
|
53
|
-
'.chord:after': {
|
|
54
|
-
content: '\'\\200b\''
|
|
55
|
-
},
|
|
56
|
-
'.lyrics:after': {
|
|
57
|
-
content: '\'\\200b\''
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Formats a song into HTML. It uses DIVs to align lyrics with chords, which makes it useful for responsive web pages.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
var HtmlDivFormatter = /*#__PURE__*/function (_HtmlFormatter) {
|
|
65
|
-
_inherits(HtmlDivFormatter, _HtmlFormatter);
|
|
66
|
-
|
|
67
|
-
var _super = _createSuper(HtmlDivFormatter);
|
|
68
|
-
|
|
69
|
-
function HtmlDivFormatter() {
|
|
70
|
-
_classCallCheck(this, HtmlDivFormatter);
|
|
71
|
-
|
|
72
|
-
return _super.apply(this, arguments);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
_createClass(HtmlDivFormatter, [{
|
|
76
|
-
key: "format",
|
|
77
|
-
value:
|
|
78
|
-
/**
|
|
79
|
-
* Formats a song into HTML.
|
|
80
|
-
* @param {Song} song The song to be formatted
|
|
81
|
-
* @returns {string} The HTML string
|
|
82
|
-
*/
|
|
83
|
-
function format(song) {
|
|
84
|
-
return this.formatWithTemplate(song, template);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Generates basic CSS, optionally scoped within the provided selector, to use with output generated by
|
|
88
|
-
* {@link HtmlDivFormatter}
|
|
89
|
-
*
|
|
90
|
-
* For example, execute cssString('.chordSheetViewer') will result in CSS like:
|
|
91
|
-
*
|
|
92
|
-
* .chordSheetViewer .paragraph {
|
|
93
|
-
* margin-bottom: 1em;
|
|
94
|
-
* }
|
|
95
|
-
*
|
|
96
|
-
* @param scope the CSS scope to use, for example `.chordSheetViewer`
|
|
97
|
-
* @returns {string} the CSS string
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
}], [{
|
|
101
|
-
key: "cssString",
|
|
102
|
-
value: function cssString() {
|
|
103
|
-
var scope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
104
|
-
return (0, _utilities.scopeCss)(defaultCss, scope);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Basic CSS, in object style à la useStyles, to use with output generated by {@link HtmlDivFormatter}
|
|
108
|
-
*
|
|
109
|
-
* Example:
|
|
110
|
-
*
|
|
111
|
-
* '.paragraph': {
|
|
112
|
-
* marginBottom: '1em'
|
|
113
|
-
* }
|
|
114
|
-
*
|
|
115
|
-
* For a CSS string see {@link cssString}
|
|
116
|
-
* @return {Object.<string, Object.<string, string>>} the CSS object
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
}, {
|
|
120
|
-
key: "cssObject",
|
|
121
|
-
value: function cssObject() {
|
|
122
|
-
return defaultCss;
|
|
123
|
-
}
|
|
124
|
-
}]);
|
|
125
|
-
|
|
126
|
-
return HtmlDivFormatter;
|
|
127
|
-
}(_html_formatter["default"]);
|
|
128
|
-
|
|
129
|
-
var _default = HtmlDivFormatter;
|
|
130
|
-
exports["default"] = _default;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Acts as a base class for HTML formatters, taking care of whitelisting prototype property access.
|
|
16
|
-
*/
|
|
17
|
-
var HtmlFormatter = /*#__PURE__*/function () {
|
|
18
|
-
function HtmlFormatter() {
|
|
19
|
-
_classCallCheck(this, HtmlFormatter);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_createClass(HtmlFormatter, [{
|
|
23
|
-
key: "formatWithTemplate",
|
|
24
|
-
value: function formatWithTemplate(song, template) {
|
|
25
|
-
return template({
|
|
26
|
-
song: song
|
|
27
|
-
}, {
|
|
28
|
-
allowedProtoProperties: {
|
|
29
|
-
bodyLines: true,
|
|
30
|
-
bodyParagraphs: true,
|
|
31
|
-
subtitle: true,
|
|
32
|
-
title: true,
|
|
33
|
-
value: true,
|
|
34
|
-
key: true
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}]);
|
|
39
|
-
|
|
40
|
-
return HtmlFormatter;
|
|
41
|
-
}();
|
|
42
|
-
|
|
43
|
-
var _default = HtmlFormatter;
|
|
44
|
-
exports["default"] = _default;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.defaultCss = exports["default"] = void 0;
|
|
9
|
-
exports.scopedCss = scopedCss;
|
|
10
|
-
|
|
11
|
-
var _handlebars = _interopRequireDefault(require("handlebars"));
|
|
12
|
-
|
|
13
|
-
require("../template_helpers");
|
|
14
|
-
|
|
15
|
-
var _html_formatter = _interopRequireDefault(require("./html_formatter"));
|
|
16
|
-
|
|
17
|
-
require("./templates/html_table_formatter");
|
|
18
|
-
|
|
19
|
-
var _utilities = require("../utilities");
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
|
-
|
|
23
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
24
|
-
|
|
25
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
26
|
-
|
|
27
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
28
|
-
|
|
29
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
30
|
-
|
|
31
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
32
|
-
|
|
33
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
34
|
-
|
|
35
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
36
|
-
|
|
37
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
38
|
-
|
|
39
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
40
|
-
|
|
41
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
42
|
-
|
|
43
|
-
var template = _handlebars["default"].templates.html_table_formatter;
|
|
44
|
-
/**
|
|
45
|
-
* Basic CSS, in object style à la useStyles, to use with output generated by {@link }HtmlTableFormatter}
|
|
46
|
-
* For a CSS string see {@link scopedCss}
|
|
47
|
-
* @type {Object.<string, Object.<string, string>>}
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
var defaultCss = {
|
|
51
|
-
h1: {
|
|
52
|
-
fontSize: '1.5em'
|
|
53
|
-
},
|
|
54
|
-
h2: {
|
|
55
|
-
fontSize: '1.1em'
|
|
56
|
-
},
|
|
57
|
-
table: {
|
|
58
|
-
borderSpacing: '0',
|
|
59
|
-
color: 'inherit'
|
|
60
|
-
},
|
|
61
|
-
td: {
|
|
62
|
-
padding: '3px 0'
|
|
63
|
-
},
|
|
64
|
-
'.chord:not(:last-child)': {
|
|
65
|
-
paddingRight: '10px'
|
|
66
|
-
},
|
|
67
|
-
'.paragraph': {
|
|
68
|
-
marginBottom: '1em'
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Generates basic CSS, scoped within the provided selector, to use with output generated by {@link HtmlTableFormatter}
|
|
73
|
-
* @param scope the CSS scope to use, for example `.chordSheetViewer`
|
|
74
|
-
* @returns {string} the CSS string
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
exports.defaultCss = defaultCss;
|
|
78
|
-
|
|
79
|
-
function scopedCss(scope) {
|
|
80
|
-
return (0, _utilities.scopeCss)(defaultCss, scope);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Formats a song into HTML. It uses TABLEs to align lyrics with chords, which makes the HTML for things like
|
|
84
|
-
* PDF conversion.
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var HtmlTableFormatter = /*#__PURE__*/function (_HtmlFormatter) {
|
|
89
|
-
_inherits(HtmlTableFormatter, _HtmlFormatter);
|
|
90
|
-
|
|
91
|
-
var _super = _createSuper(HtmlTableFormatter);
|
|
92
|
-
|
|
93
|
-
function HtmlTableFormatter() {
|
|
94
|
-
_classCallCheck(this, HtmlTableFormatter);
|
|
95
|
-
|
|
96
|
-
return _super.apply(this, arguments);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
_createClass(HtmlTableFormatter, [{
|
|
100
|
-
key: "format",
|
|
101
|
-
value:
|
|
102
|
-
/**
|
|
103
|
-
* Formats a song into HTML.
|
|
104
|
-
* @param {Song} song The song to be formatted
|
|
105
|
-
* @returns {string} The HTML string
|
|
106
|
-
*/
|
|
107
|
-
function format(song) {
|
|
108
|
-
return this.formatWithTemplate(song, template);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Generates basic CSS, optionally scoped within the provided selector, to use with output generated by
|
|
112
|
-
* {@link HtmlTableFormatter}
|
|
113
|
-
*
|
|
114
|
-
* For example, execute cssString('.chordSheetViewer') will result in CSS like:
|
|
115
|
-
*
|
|
116
|
-
* .chordSheetViewer .paragraph {
|
|
117
|
-
* margin-bottom: 1em;
|
|
118
|
-
* }
|
|
119
|
-
*
|
|
120
|
-
* @param scope the CSS scope to use, for example `.chordSheetViewer`
|
|
121
|
-
* @returns {string} the CSS string
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
}], [{
|
|
125
|
-
key: "cssString",
|
|
126
|
-
value: function cssString() {
|
|
127
|
-
var scope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
128
|
-
return (0, _utilities.scopeCss)(defaultCss, scope);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Basic CSS, in object style à la useStyles, to use with output generated by {@link HtmlTableFormatter}
|
|
132
|
-
* For a CSS string see {@link cssString}
|
|
133
|
-
*
|
|
134
|
-
* Example:
|
|
135
|
-
*
|
|
136
|
-
* '.paragraph': {
|
|
137
|
-
* marginBottom: '1em'
|
|
138
|
-
* }
|
|
139
|
-
*
|
|
140
|
-
* @return {Object.<string, Object.<string, string>>} the CSS object
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
}, {
|
|
144
|
-
key: "cssObject",
|
|
145
|
-
value: function cssObject() {
|
|
146
|
-
return defaultCss;
|
|
147
|
-
}
|
|
148
|
-
}]);
|
|
149
|
-
|
|
150
|
-
return HtmlTableFormatter;
|
|
151
|
-
}(_html_formatter["default"]);
|
|
152
|
-
|
|
153
|
-
var _default = HtmlTableFormatter;
|
|
154
|
-
exports["default"] = _default;
|