chordsheetjs 7.10.0 → 7.11.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
@@ -1,4 +1,4 @@
1
- # ChordSheetJS [![Code Climate](https://codeclimate.com/github/martijnversluis/ChordSheetJS/badges/gpa.svg)](https://codeclimate.com/github/martijnversluis/ChordSheetJS)
1
+ # ChordSheetJS [![Code Climate](https://codeclimate.com/github/martijnversluis/ChordSheetJS/badges/gpa.svg)](https://codeclimate.com/github/martijnversluis/ChordSheetJS) [![CI](https://github.com/martijnversluis/ChordSheetJS/actions/workflows/ci.yml/badge.svg)](https://github.com/martijnversluis/ChordSheetJS/actions/workflows/ci.yml?query=branch%3Amaster) [![Release](https://github.com/martijnversluis/ChordSheetJS/actions/workflows/release.yml/badge.svg)](https://github.com/martijnversluis/ChordSheetJS/actions/workflows/release.yml)
2
2
 
3
3
  A JavaScript library for parsing and formatting chord sheets
4
4
 
@@ -262,6 +262,9 @@ chordSymbol.toString(); // -> "F#m/A"
262
262
 
263
263
  ## Supported ChordPro directives
264
264
 
265
+ All directives are parsed and are added to `Song.metadata`. The list below indicates whether formatters actually
266
+ use those to change the generated output.
267
+
265
268
  :heavy_check_mark: = supported
266
269
 
267
270
  :clock2: = will be supported in a future version
@@ -305,8 +308,8 @@ chordSymbol.toString(); // -> "F#m/A"
305
308
  | end_of_chorus (short: eoc) | :heavy_check_mark: |
306
309
  | start_of_verse | :heavy_check_mark: |
307
310
  | end_of_verse | :heavy_check_mark: |
308
- | start_of_tab (short: sot) | :heavy_multiplication_x: |
309
- | end_of_tab (short: eot) | :heavy_multiplication_x: |
311
+ | start_of_tab (short: sot) | :heavy_check_mark: |
312
+ | end_of_tab (short: eot) | :heavy_check_mark: |
310
313
  | start_of_grid | :heavy_multiplication_x: |
311
314
  | end_of_grid | :heavy_multiplication_x: |
312
315
 
@@ -321,12 +324,12 @@ chordSymbol.toString(); // -> "F#m/A"
321
324
 
322
325
  | Directive | Support |
323
326
  |:----------- |:------------------------:|
324
- | textfont | :clock2: |
325
- | textsize | :clock2: |
326
- | textcolour | :clock2: |
327
- | chordfont | :clock2: |
328
- | chordsize | :clock2: |
329
- | chordcolour | :clock2: |
327
+ | textfont | :heavy_check_mark: |
328
+ | textsize | :heavy_check_mark: |
329
+ | textcolour | :heavy_check_mark: |
330
+ | chordfont | :heavy_check_mark: |
331
+ | chordsize | :heavy_check_mark: |
332
+ | chordcolour | :heavy_check_mark: |
330
333
  | tabfont | :heavy_multiplication_x: |
331
334
  | tabsize | :heavy_multiplication_x: |
332
335
  | tabcolour | :heavy_multiplication_x: |
@@ -361,6 +364,8 @@ subject to breaking changes between major versions.
361
364
  <dd><p>Represents a chord with the corresponding (partial) lyrics</p></dd>
362
365
  <dt><a href="#Comment">Comment</a></dt>
363
366
  <dd><p>Represents a comment. See https://www.chordpro.org/chordpro/chordpro-file-format-specification/#overview</p></dd>
367
+ <dt><a href="#Line">Line</a> : <code><a href="#Font">Font</a></code></dt>
368
+ <dd><p>Represents a line in a chord sheet, consisting of items of type ChordLyricsPair or Tag</p></dd>
364
369
  <dt><a href="#Metadata">Metadata</a></dt>
365
370
  <dd><p>Stores song metadata. Properties can be accessed using the get() method:</p>
366
371
  <p>const metadata = new Metadata({ author: 'John' });
@@ -444,6 +449,10 @@ Inherits from [ChordSheetParser](#ChordSheetParser)</p></dd>
444
449
  ## Members
445
450
 
446
451
  <dl>
452
+ <dt><a href="#Font">Font</a> : <code>string</code> | <code>null</code></dt>
453
+ <dd><p>The font color</p></dd>
454
+ <dt><a href="#FontSize">FontSize</a> : <code>number</code></dt>
455
+ <dd><p>The font size</p></dd>
447
456
  <dt><a href="#ALBUM">ALBUM</a> : <code>string</code></dt>
448
457
  <dd><p>Artist meta directive. See https://www.chordpro.org/chordpro/directives-artist/</p></dd>
449
458
  <dt><a href="#ARTIST">ARTIST</a> : <code>string</code></dt>
@@ -493,6 +502,24 @@ See https://www.chordpro.org/chordpro/directives-key/</p></dd>
493
502
  <dd><p>New Key meta directive. See: https://github.com/PraiseCharts/ChordChartJS/issues/53</p></dd>
494
503
  <dt><a href="#NEW_KEY">NEW_KEY</a> : <code>string</code></dt>
495
504
  <dd><p>Year meta directive. See https://www.chordpro.org/chordpro/directives-year/</p></dd>
505
+ <dt><a href="#YEAR">YEAR</a> : <code>string</code></dt>
506
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_chord_legacy/</p></dd>
507
+ <dt><a href="#CHORDFONT">CHORDFONT</a> : <code>string</code></dt>
508
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_chord_legacy/</p></dd>
509
+ <dt><a href="#CHORDSIZE">CHORDSIZE</a> : <code>string</code></dt>
510
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_chord_legacy/</p></dd>
511
+ <dt><a href="#CHORDCOLOUR">CHORDCOLOUR</a> : <code>string</code></dt>
512
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_text_legacy/</p></dd>
513
+ <dt><a href="#TEXTFONT">TEXTFONT</a> : <code>string</code></dt>
514
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_text_legacy/</p></dd>
515
+ <dt><a href="#TEXTSIZE">TEXTSIZE</a> : <code>string</code></dt>
516
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_text_legacy/</p></dd>
517
+ <dt><a href="#TEXTCOLOUR">TEXTCOLOUR</a> : <code>string</code></dt>
518
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_title_legacy/</p></dd>
519
+ <dt><a href="#TITLEFONT">TITLEFONT</a> : <code>string</code></dt>
520
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_title_legacy/</p></dd>
521
+ <dt><a href="#TITLESIZE">TITLESIZE</a> : <code>string</code></dt>
522
+ <dd><p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_title_legacy/</p></dd>
496
523
  <dt><a href="#defaultCss">defaultCss</a> ⇒ <code>string</code></dt>
497
524
  <dd><p>Generates basic CSS, scoped within the provided selector, to use with output generated by [HtmlTableFormatter](#HtmlTableFormatter)</p></dd>
498
525
  <dt><a href="#defaultCss">defaultCss</a> ⇒ <code>string</code></dt>
@@ -600,6 +627,79 @@ For a CSS string see [scopedCss](scopedCss)</p></dd>
600
627
  <p>Returns a deep copy of the Comment, useful when programmatically transforming a song</p>
601
628
 
602
629
  **Kind**: instance method of [<code>Comment</code>](#Comment)
630
+ <a name="Line"></a>
631
+
632
+ ## Line : [<code>Font</code>](#Font)
633
+ <p>Represents a line in a chord sheet, consisting of items of type ChordLyricsPair or Tag</p>
634
+
635
+ **Kind**: global class
636
+
637
+ * [Line](#Line) : [<code>Font</code>](#Font)
638
+ * [new Line()](#new_Line_new)
639
+ * [.isEmpty()](#Line+isEmpty) ⇒ <code>boolean</code>
640
+ * [.addItem(item)](#Line+addItem)
641
+ * [.hasRenderableItems()](#Line+hasRenderableItems) ⇒ <code>boolean</code>
642
+ * [.clone()](#Line+clone) ⇒ [<code>Line</code>](#Line)
643
+ * [.isVerse()](#Line+isVerse) ⇒ <code>boolean</code>
644
+ * [.isChorus()](#Line+isChorus) ⇒ <code>boolean</code>
645
+ * ~~[.hasContent()](#Line+hasContent) ⇒ <code>boolean</code>~~
646
+
647
+ <a name="new_Line_new"></a>
648
+
649
+ ### new Line()
650
+ <p>The chord font that applies to this line. Is derived from the directives:
651
+ <code>chordfont</code>, <code>chordsize</code> and <code>chordcolour</code>
652
+ See: https://www.chordpro.org/chordpro/directives-props_chord_legacy/</p>
653
+
654
+ <a name="Line+isEmpty"></a>
655
+
656
+ ### line.isEmpty() ⇒ <code>boolean</code>
657
+ <p>Indicates whether the line contains any items</p>
658
+
659
+ **Kind**: instance method of [<code>Line</code>](#Line)
660
+ <a name="Line+addItem"></a>
661
+
662
+ ### line.addItem(item)
663
+ <p>Adds an item ([ChordLyricsPair](#ChordLyricsPair) or [Tag](#Tag)) to the line</p>
664
+
665
+ **Kind**: instance method of [<code>Line</code>](#Line)
666
+
667
+ | Param | Type | Description |
668
+ | --- | --- | --- |
669
+ | item | [<code>ChordLyricsPair</code>](#ChordLyricsPair) \| [<code>Tag</code>](#Tag) | <p>The item to be added</p> |
670
+
671
+ <a name="Line+hasRenderableItems"></a>
672
+
673
+ ### line.hasRenderableItems() ⇒ <code>boolean</code>
674
+ <p>Indicates whether the line contains items that are renderable</p>
675
+
676
+ **Kind**: instance method of [<code>Line</code>](#Line)
677
+ <a name="Line+clone"></a>
678
+
679
+ ### line.clone() ⇒ [<code>Line</code>](#Line)
680
+ <p>Returns a deep copy of the line and all of its items</p>
681
+
682
+ **Kind**: instance method of [<code>Line</code>](#Line)
683
+ <a name="Line+isVerse"></a>
684
+
685
+ ### line.isVerse() ⇒ <code>boolean</code>
686
+ <p>Indicates whether the line type is [VERSE](#VERSE)</p>
687
+
688
+ **Kind**: instance method of [<code>Line</code>](#Line)
689
+ <a name="Line+isChorus"></a>
690
+
691
+ ### line.isChorus() ⇒ <code>boolean</code>
692
+ <p>Indicates whether the line type is [CHORUS](#CHORUS)</p>
693
+
694
+ **Kind**: instance method of [<code>Line</code>](#Line)
695
+ <a name="Line+hasContent"></a>
696
+
697
+ ### ~~line.hasContent() ⇒ <code>boolean</code>~~
698
+ ***Deprecated***
699
+
700
+ <p>Indicates whether the line contains items that are renderable. Please use [hasRenderableItems](hasRenderableItems)</p>
701
+
702
+ **Kind**: instance method of [<code>Line</code>](#Line)
603
703
  <a name="Metadata"></a>
604
704
 
605
705
  ## Metadata
@@ -679,7 +779,7 @@ If not, it returns [INDETERMINATE](#INDETERMINATE)</p>
679
779
 
680
780
  * [Song](#Song)
681
781
  * [new Song(metadata)](#new_Song_new)
682
- * [.bodyLines](#Song+bodyLines) ⇒ <code>Array.&lt;Line&gt;</code>
782
+ * [.bodyLines](#Song+bodyLines) ⇒ [<code>Array.&lt;Line&gt;</code>](#Line)
683
783
  * [.bodyParagraphs](#Song+bodyParagraphs) ⇒ [<code>Array.&lt;Paragraph&gt;</code>](#Paragraph)
684
784
  * [.paragraphs](#Song+paragraphs) : [<code>Array.&lt;Paragraph&gt;</code>](#Paragraph)
685
785
  * ~~[.metaData](#Song+metaData) ⇒~~
@@ -706,12 +806,12 @@ If not, it returns [INDETERMINATE](#INDETERMINATE)</p>
706
806
 
707
807
  <a name="Song+bodyLines"></a>
708
808
 
709
- ### song.bodyLines ⇒ <code>Array.&lt;Line&gt;</code>
809
+ ### song.bodyLines ⇒ [<code>Array.&lt;Line&gt;</code>](#Line)
710
810
  <p>Returns the song lines, skipping the leading empty lines (empty as in not rendering any content). This is useful
711
811
  if you want to skip the &quot;header lines&quot;: the lines that only contain meta data.</p>
712
812
 
713
813
  **Kind**: instance property of [<code>Song</code>](#Song)
714
- **Returns**: <code>Array.&lt;Line&gt;</code> - <p>The song body lines</p>
814
+ **Returns**: [<code>Array.&lt;Line&gt;</code>](#Line) - <p>The song body lines</p>
715
815
  <a name="Song+bodyParagraphs"></a>
716
816
 
717
817
  ### song.bodyParagraphs ⇒ [<code>Array.&lt;Paragraph&gt;</code>](#Paragraph)
@@ -889,7 +989,7 @@ song.mapItems((item) => {
889
989
  <a name="Song+mapLines"></a>
890
990
 
891
991
  ### song.mapLines(func) ⇒ [<code>Song</code>](#Song)
892
- <p>Change the song contents inline. Return a new [Line](Line) to replace it. Return <code>null</code> to remove it.</p>
992
+ <p>Change the song contents inline. Return a new [Line](#Line) to replace it. Return <code>null</code> to remove it.</p>
893
993
 
894
994
  **Kind**: instance method of [<code>Song</code>](#Song)
895
995
  **Returns**: [<code>Song</code>](#Song) - <p>the changed song</p>
@@ -1533,6 +1633,64 @@ Can be deserialized using [deserialize](deserialize)</p>
1533
1633
  | oneKey | [<code>Key</code>](#Key) \| <code>string</code> | <p>the key</p> |
1534
1634
  | otherKey | [<code>Key</code>](#Key) \| <code>string</code> | <p>the other key</p> |
1535
1635
 
1636
+ <a name="Font"></a>
1637
+
1638
+ ## Font : <code>string</code> \| <code>null</code>
1639
+ <p>The font color</p>
1640
+
1641
+ **Kind**: global variable
1642
+ <a name="Font+toCssString"></a>
1643
+
1644
+ ### font.toCssString() ⇒ <code>string</code>
1645
+ <p>Converts the font, size and color to a CSS string.
1646
+ If possible, font and size are combined to the <code>font</code> shorthand.
1647
+ If <code>font</code> contains double quotes (<code>&quot;</code>) those will be converted to single quotes (<code>'</code>).</p>
1648
+
1649
+ **Kind**: instance method of [<code>Font</code>](#Font)
1650
+ **Returns**: <code>string</code> - <p>The CSS string</p>
1651
+ **Example**
1652
+ ```js
1653
+ // Returns "font-family: 'Times New Roman'"
1654
+ new Font({ font: '"Times New Roman"' }).toCssString()
1655
+ ```
1656
+ **Example**
1657
+ ```js
1658
+ // Returns "color: red; font-family: Verdana"
1659
+ new Font({ font: 'Verdana', colour: 'red' }).toCssString()
1660
+ ```
1661
+ **Example**
1662
+ ```js
1663
+ // Returns "font: 30px Verdana"
1664
+ new Font({ font: 'Verdana', size: '30' }).toCssString()
1665
+ ```
1666
+ **Example**
1667
+ ```js
1668
+ // Returns "color: blue; font: 30% Verdana"
1669
+ new Font({ font: 'Verdana', size: '30%', colour: 'blue' }).toCssString()
1670
+ ```
1671
+ <a name="FontSize"></a>
1672
+
1673
+ ## FontSize : <code>number</code>
1674
+ <p>The font size</p>
1675
+
1676
+ **Kind**: global variable
1677
+ <a name="FontSize+toString"></a>
1678
+
1679
+ ### fontSize.toString() ⇒ <code>string</code>
1680
+ <p>Stringifies the font size by concatenating size and unit</p>
1681
+
1682
+ **Kind**: instance method of [<code>FontSize</code>](#FontSize)
1683
+ **Returns**: <code>string</code> - <p>The font size</p>
1684
+ **Example**
1685
+ ```js
1686
+ // Returns "30px"
1687
+ new FontSize(30, 'px').toString()
1688
+ ```
1689
+ **Example**
1690
+ ```js
1691
+ // Returns "120%"
1692
+ new FontSize(120, '%').toString()
1693
+ ```
1536
1694
  <a name="ALBUM"></a>
1537
1695
 
1538
1696
  ## ALBUM : <code>string</code>
@@ -1677,6 +1835,60 @@ See https://www.chordpro.org/chordpro/directives-key/</p>
1677
1835
  ## NEW\_KEY : <code>string</code>
1678
1836
  <p>Year meta directive. See https://www.chordpro.org/chordpro/directives-year/</p>
1679
1837
 
1838
+ **Kind**: global variable
1839
+ <a name="YEAR"></a>
1840
+
1841
+ ## YEAR : <code>string</code>
1842
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_chord_legacy/</p>
1843
+
1844
+ **Kind**: global variable
1845
+ <a name="CHORDFONT"></a>
1846
+
1847
+ ## CHORDFONT : <code>string</code>
1848
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_chord_legacy/</p>
1849
+
1850
+ **Kind**: global variable
1851
+ <a name="CHORDSIZE"></a>
1852
+
1853
+ ## CHORDSIZE : <code>string</code>
1854
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_chord_legacy/</p>
1855
+
1856
+ **Kind**: global variable
1857
+ <a name="CHORDCOLOUR"></a>
1858
+
1859
+ ## CHORDCOLOUR : <code>string</code>
1860
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_text_legacy/</p>
1861
+
1862
+ **Kind**: global variable
1863
+ <a name="TEXTFONT"></a>
1864
+
1865
+ ## TEXTFONT : <code>string</code>
1866
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_text_legacy/</p>
1867
+
1868
+ **Kind**: global variable
1869
+ <a name="TEXTSIZE"></a>
1870
+
1871
+ ## TEXTSIZE : <code>string</code>
1872
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_text_legacy/</p>
1873
+
1874
+ **Kind**: global variable
1875
+ <a name="TEXTCOLOUR"></a>
1876
+
1877
+ ## TEXTCOLOUR : <code>string</code>
1878
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_title_legacy/</p>
1879
+
1880
+ **Kind**: global variable
1881
+ <a name="TITLEFONT"></a>
1882
+
1883
+ ## TITLEFONT : <code>string</code>
1884
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_title_legacy/</p>
1885
+
1886
+ **Kind**: global variable
1887
+ <a name="TITLESIZE"></a>
1888
+
1889
+ ## TITLESIZE : <code>string</code>
1890
+ <p>Chordfont directive. See https://www.chordpro.org/chordpro/directives-props_title_legacy/</p>
1891
+
1680
1892
  **Kind**: global variable
1681
1893
  <a name="defaultCss"></a>
1682
1894