1.1.5 • Published 9 months ago

openlyrics-parser v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

GitHub - release

OpenLyrics-parser

OpenLyrics is an open XML file format for storing song and lyric information about songs.

This project will parse and extract data from OpenLyrics XML files written in OpenLyrics version 0.8 and 0.9, and it can create OpenLyrics 0.9 formatted documents.

This project is used by my LyricConverter project which can convert your song lyric files between many common formats. If you need to convert some songs to another existing format I encourage you to check this project out first.

Installation

npm install openlyrics-parser --save

Parsing OpenLyrics XML Files

Simply import OpenLyricsParser, then pass the contents of an OpenLyrics XML file as a string to it.

Documentation & Examples: Reading/Parsing Files

For TypeScript projects

import { readFile } from 'fs';
import { OpenLyricsParser, IParserRoot } from 'openlyrics-parser';

readFile('example.xml', (contents): void => {
  const song: IParserRoot = OpenLyricsParser(contents.toString());
  console.log(song);
});

For JavaScript projects

const { readFile } = require('fs');
const { OpenLyricsParser } = require('openlyrics-parser');

readFile('example.xml', (contents) => {
  const song = OpenLyricsParser(contents.toString());
  console.log(song);
});

Building OpenLyrics XML Files

Simply import OpenLyricsBuilder, then pass the song data to it, and it will return a string of XML data which you can then do what you need to with it.

Documentation & Examples: Building/Creating Files

For TypeScript projects

import { OpenLyricsBuilder, IBuilderOptions } from 'openlyrics-parser';

const opts: IBuilderOptions = {
  properties: { titles: 'Amazing Grace' },
  verses: [
    {
      name: 'v1',
      lines: ['Amazing grace how sweet the sound', 'that saved a wretch like me'],
    },
  ],
};
const xmlDoc: string = OpenLyricsBuilder(opts);
console.log(xmlDoc);

For JavaScript projects

const { OpenLyricsBuilder } = require('openlyrics-parser');

const opts = {
  properties: { titles: 'Amazing Grace' },
  verses: [
    {
      name: 'v1',
      lines: ['Amazing grace how sweet the sound', 'that saved a wretch like me'],
    },
  ],
};
const xmlDoc = OpenLyricsBuilder(opts);
console.log(xmlDoc);
1.1.5

9 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.0

11 months ago