API Docs for: 1.4.4
Show:

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.

Methods

_domParse

(
  • text
)
SongNodeArray private

Explodes passed in text block into an array of songNodes ready for further parsing.

Parameters:

  • text String

Returns:

SongNodeArray:

_echo

(
  • song
)
Void private

Debugging tool for Firebug. Echos the song's structure.

Parameters:

  • song SongNodeArray

Returns:

Void:

_export

(
  • song
)
Strings private

Convert passed in song to HTML block

Parameters:

  • song SongNodeArray

Returns:

Strings:

_getBlockType

(
  • line
)
_blockTypeEnum private

Retuns the block type (_blockTypeEnum) of passed in line.

Parameters:

  • line SongNode

Returns:

_blockTypeEnum:

_getInfo

(
  • song
  • type
)
Array private

Searches the songNodes for the specified block type, retunrs all matching node line (text) values.

Parameters:

  • song SongNodeArray
  • type _blockTypeEnum

Returns:

Array:

_markChordLines

(
  • song
)
SongNodeArray private

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:

SongNodeArray:

_parseInstr

(
  • song
)
SongNodeArray private

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:

SongNodeArray:

_parseSimpleInstr

(
  • song
)
SongNodeArray private

A "Simple Instruction" is one that accepts no arguments. Presently this only handles Column Breaks.

Parameters:

  • song SongNodeArray

Returns:

SongNodeArray:

_stripHtml

(
  • text
)
String private

Removes HTML "pre" tags and comments.

Parameters:

  • text String

Returns:

String:

init

() Void

Again this is a constructor replacement. Just here for consistency. Does nothing.

Returns:

Void:

parse

(
  • text
)
SongObject

Accepts CPM text, returning HTML marked-up text

Parameters:

  • text String

    string RAW song

Returns:

SongObject:

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