How to use the chordsheetjs.ChordSheetParser function in chordsheetjs

To help you get started, we’ve selected a few chordsheetjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github artutra / OpenChord / app / containers / SongEdit.tsx View on Github external
function saveSong() {
    if (title.trim() == '') return setError('Invalid Title')
    if (artist.trim() == '') return setError('Invalid Artist')
    if (content.trim() == '') return setError('Invalid content')
    let artistName = artist.trim()
    let songTitle = title.trim()
    let header =
      `{title: ${songTitle}}\n` +
      `{artist: ${artistName}}\n`
    let chordPro: string
    if (mode == 'CHORD_PRO') {
      chordPro = header + content
    } else {
      const formatter = new ChordSheetJS.ChordProFormatter();
      let chordSheetSong = new ChordSheetJS.ChordSheetParser({ preserveWhitespace: true }).parse(content)
      chordPro = header + formatter.format(chordSheetSong)
    }
    let songId = props.navigation.getParam('id')
    let artistDb: Artist | undefined = Artist.getByName(artistName)
    if (artistDb == null) {
      artistDb = Artist.create(artistName)
    }
    if (songId) {
      Song.update(songId, artistDb, songTitle, chordPro)
    } else {
      let song = Song.create(artistDb, songTitle, chordPro)
      songId = song.id
    }
    props.navigation.replace(ROUTES.SongView, { id: songId, title: songTitle })
  }
github martijnversluis / ChordFiddle / js / chord_pro_editor.js View on Github external
importChordSheet(chordSheet) {
    const song = new ChordSheetJS.ChordSheetParser().parse(chordSheet);
    this.editor.value = new ChordSheetJS.ChordProFormatter().format(song);
    this.onEditorChange();
  }
github artutra / OpenChord / app / components / SongTransformer.tsx View on Github external
const SongTransformer: FunctionComponent = (props) => {
  let { showTabs = true, transposeDelta = 0, chordProSong, fontSize = 14 } = props
  let htmlSong = ''
  let song: Song
  if (chordProSong != null) {
    if (!showTabs) {
      chordProSong = chordProSong.replace(/{sot}(.|\n|\r)*?{eot}\r?\n?/g, '')
    }
    song = new ChordSheetJS.ChordProParser().parse(chordProSong);
  } else {
    song = new ChordSheetJS.ChordSheetParser({ preserveWhitespace: true }).parse(props.chordSheetSong!);
  }
  let transposedSong = song
  if (transposeDelta != 0) {
    transposedSong = transposeSong(song, transposeDelta);
  }
  let allChords = getChords(transposedSong)
  htmlSong = new CustomHtmlDivFormatter().format(transposedSong, fontSize)

  return props.children({ chords: allChords, htmlSong })
}
export default SongTransformer
github martijnversluis / ChordFiddle / src / utils / chord_sheet_transformations.js View on Github external
export const convertChordSheetToChordPro = (chordSheet) => {
  const parser = new ChordSheetJS.ChordSheetParser({ preserveWhitespace: false });
  const formatter = new ChordSheetJS.ChordProFormatter();
  const song = parser.parse(chordSheet);
  return formatter.format(song);
};

chordsheetjs

A JavaScript library for parsing and formatting chord sheets

GPL-2.0
Latest version published 1 day ago

Package Health Score

78 / 100
Full package analysis

Similar packages