ukeGeeks.cpmParser Class
Reads a text block and returns an object containing whatever ChordPro elements it recognizes.
A cleaned, HTML version of song is included.
Item Index
Methods
Methods
_domParse
-
text
Explodes passed in text block into an array of songNodes ready for further parsing.
Parameters:
-
text
String
Returns:
_echo
-
song
Debugging tool for Firebug. Echos the song's structure.
Parameters:
-
song
SongNodeArray
Returns:
_export
-
song
Convert passed in song to HTML block
Parameters:
-
song
SongNodeArray
Returns:
_getBlockType
-
line
Retuns the block type (_blockTypeEnum) of passed in line.
Parameters:
-
line
SongNode
Returns:
_getInfo
-
song
-
type
Searches the songNodes for the specified block type, retunrs all matching node line (text) values.
Parameters:
-
song
SongNodeArray -
type
_blockTypeEnum
Returns:
_markChordLines
-
song
Runs through songNodes and if the line contains at least one chord it's type is et to ChordText, otherwise it's marked as "PlainText", meaning straight lyrics
Parameters:
-
song
SongNodeArray
Returns:
_parseInstr
-
song
Goes through songNodes, those nodes that are "instructions" are exploded and a "the resulting "songDomElement" built, this songDomElement then replaces the original line.
The regular expression look for instructions with this format: {commandVerb: commandArguments}
Parameters:
-
song
SongNodeArray
Returns:
_parseSimpleInstr
-
song
A "Simple Instruction" is one that accepts no arguments. Presently this only handles Column Breaks.
Parameters:
-
song
SongNodeArray
Returns:
_stripHtml
-
text
Removes HTML "pre" tags and comments.
Parameters:
-
text
String
Returns:
init
()
Void
Again this is a constructor replacement. Just here for consistency. Does nothing.
Returns:
parse
-
text
Accepts CPM text, returning HTML marked-up text
Parameters:
-
text
Stringstring RAW song
Returns:
Properties
_blockTypeEnum
JSON-enum
private
Enumeration defining the types of nodes used within this class to parse CPM
_classNames
JSON
private
All of the CSS classnames used by UkeGeeks JavaScript
_columnCount
Int
private
Number of columns defined
_firstChord
String
private
Song's key. May be set via command tag {key: C} otherwise use the first chord found (if available)
_hasChords
Bool
private
Under development, bool indicating whether any chords were found within the lyrics. Helpful for tablature-only arrangements. TODO: do not rely on this!!!
_public
Object
attach public members to this object