PmSyntax-ChordPro


Suggestion for CustomSyntax configuration for Cookbook:ChordPro:
SDVA($CustomSyntax, array(
  'CHORDPRO,00'   => '<ws0    =directive>comment>*meta_nobg>=meta_nobg>punct
    /(\|\|:)([\s\S]*?)(:\|\|)/g
    /^ *#.*$/gm
    /\{[a-z_]+:?\}/gi
    /(\{[a-z_]+:)(.+?)(\})/gi
    /\[[A-G][b#]?m?[769]?\]/g
  '));

I'm not sure if the "#comment" can only appear alone on a line (currently defined), or after other text on the same line.

This is fantastic thanks, I hadn't progressed in my understanding enough to appreciate the power of this. # comment apply to an entire line
simon

The above is enabled on this page, test samples below. Note: only the $CustomSyntax configuration is enabled here, not the full ChordPro recipe, hence (:markup class=norender:).

!!Long markup
||:{debug:on}
{version}
{Title: Title test example}
{Subtitle: Subtitle}
{Album: Album}
{Key:F#m}
:||

!!Long markup
||:{debug:on}
{Capo: 3}
Chords [Bb]and [C#]Lyrics
[A]An example [D]of [G7]lyrics and tablature
An example with no chords
    [G][F][E][Chords][Only]
    And another example with no chords, followed by an empty line

{Comment: a comment}
{Comment_italic: an italic comment}
{Comment_box: a comment box}
# comment line

{start_of_chorus}
[B]text of chorus

more chorus text[Cm7]
{end_of_chorus}
{start_of_tab}
             D     D                D     D                D
-------------2-----2----------------2-----2----------------2-
-------------3-----3----------------3-----3----------------3-
----------o--2-----2-------------o--2-----2-------------o--2-
----2--4--------o----------2--4--------o----------2--4-------
-o----------------------o----------------------o-------------
-------------------------------------------------------------
{end_of_tab}
:||


!!short markup

||:{d:on}{v}
{T: Title test example}
{St: Subtitle}
{A: Album}
:||


!!short markup

||:{d:on}{v}
[A]An example [D]of [G]lyrics and tablature
{C: a comment}
{Ci: italic comment}
{Cb: comment box}
# comment line

{soc}
[B]chorus
{eoc}

{sot}
Csus4 (x33011)     Fmaj7 (132211)
{eot}
:||

!!test cases

||:
{TITLE: First title}
{SUBTITLE: First subtitle}
Blank line follows[G]

Blank line precedes[A] and follows

{ci:Chorus} {soc}
Two directives on one line
{eoc}

{c:two}comments{ci:on one line}
 # indented comment
 embedded directive {Title: Embedded title directive}
 {subtitle: Indented lowercase subtitle directive}
{define: <chord_name> <position> <String6> .. <String1>}
['|]

{unknown: directive}
:||


!!pathological markup

||::||
----
||: :||
----
||:
:||
----
||:test:||
----
||:test
:||
----
:||:
:test:||

!!Test if ChordPro CustomSyntax impacts normal PmWiki markup

# not a comment
{comment: not a comment}
{ChordPro: not a chordpro directive}
Just normal [B]rackets



 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.21 00.20 MarkupToHTML begin
 3: 00.24 00.23 MarkupToHTML end
 4: 00.24 00.23 MarkupToHTML begin
 5: 00.25 00.24 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
 6: 00.25 00.24 ReadApprovedUrls SiteAdmin.ApprovedUrls end
 7: 00.26 00.25 MarkupToHTML end
 8: 00.26 00.25 MarkupToHTML begin
 9: 00.26 00.25 MarkupToHTML end
10: 00.26 00.25 now
Peak memory: 3,882,096 bytes