chord-md-parser
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "chord-md-parser", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "guitar chords parser from markdown files", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test-run-once": "tape tests/**/*.js | tap-spec", | ||
"test": "chokidar 'tests/**/*.js' 'src/**/*.js' --initial -c '(tape tests/**/*.js | tap-spec) && (tape tests/**/*.js | tap-min)'" | ||
"test": "tape tests/**/*.js | tap-spec", | ||
"watch": "chokidar 'tests/**/*.js' 'src/**/*.js' --initial -c '(tape tests/**/*.js | tap-spec) && (tape tests/**/*.js | tap-min)'" | ||
}, | ||
@@ -10,0 +10,0 @@ "repository": { |
136
README.md
chord markdown parser | ||
--------------------- | ||
## running tests: | ||
[![Build Status](https://travis-ci.org/saitodisse/chord-md-parser.svg)](https://travis-ci.org/saitodisse/chord-md-parser) | ||
# MarkDown Extractor | ||
Extracts `chords` and `lirics` from markdown python code | ||
```js | ||
import { Extractor } from 'chord-md-parser'; | ||
let extractor = new Extractor({ | ||
md: { | ||
filepath: null, | ||
content: 'CONTENT' | ||
} | ||
}) | ||
let song = extractor.getSong() | ||
song // -> array with only song lirics and tablatures/chords | ||
``` | ||
------------- | ||
# ChordParser | ||
Split roots and override roots from a `chord string`. | ||
```js | ||
import { ChordParser } from 'chord-md-parser'; | ||
let parser = new ChordParser() | ||
let chord = parser.parse('Bb7(9)/Cb'); | ||
// ----------------------- | ||
chord === { root: 'Bb', | ||
flavors: '7(9)', | ||
rootOverride: 'Cb' } | ||
``` | ||
----------------- | ||
# ChordPrint | ||
Print `chord string` from `chord object`. | ||
```js | ||
import { ChordPrint } from 'chord-md-parser'; | ||
let printed = ChordPrint.print({ | ||
root: 'C', | ||
flavors: 'M7', | ||
rootOverride: 'G' | ||
}) | ||
// ----------------------- | ||
printed === 'CM7/G' | ||
``` | ||
----------------- | ||
# ChordTransposer | ||
Change root and | ||
```js | ||
import { ChordTransposer } from 'chord-md-parser'; | ||
let transposer = new ChordTransposer() | ||
let new_chord = transposer.transpose({ | ||
root: 'C', | ||
flavors: 'M7', | ||
rootOverride: 'G' | ||
}, 1) | ||
// ----------------------- | ||
new_chord === { root: 'C#', flavors: 'M7', rootOverride: 'G#', index: 3 } | ||
``` | ||
----------------- | ||
# ChordsConverter | ||
Gets all chords from a string and convert to an array of `chord objects`. | ||
```js | ||
import { ChordsConverter } from 'chord-md-parser'; | ||
let converter = new ChordsConverter() | ||
let all_chords = converter.getChordsList(' A7+ E7/4 B7/9 Dm(7+)'); | ||
// ----------------------- | ||
all_chords: | ||
[ | ||
{ | ||
chord:{ | ||
root: 'A', | ||
flavors: '7+', | ||
rootOverride: null | ||
}, | ||
loc: { start: 5, size: 3 } | ||
}, | ||
{ | ||
chord:{ | ||
root: 'E', | ||
flavors: '7/4', | ||
rootOverride: null | ||
}, | ||
loc: { start: 12, size: 4 } | ||
}, | ||
{ | ||
chord:{ | ||
root: 'B', | ||
flavors: '7/9', | ||
rootOverride: null | ||
}, | ||
loc: { start: 22, size: 4 } | ||
}, | ||
{ | ||
chord:{ | ||
root: 'D', | ||
flavors: 'm(7+)', | ||
rootOverride: null | ||
}, | ||
loc: { start: 30, size: 6 } | ||
} | ||
] | ||
``` | ||
----------------- | ||
# Tests: | ||
```sh | ||
@@ -20,9 +146,1 @@ # start azk [optional] | ||
- [tape](https://github.com/substack/tape) | ||
git commit: | ||
```sh | ||
sudo chown -R `id -un`:`id -gn` . && git add . -A && git commit -m'xxxxxxxxxxxxx' && git push | ||
``` | ||
@@ -17,10 +17,3 @@ 'use strict' | ||
convert (line_content) { | ||
// this.chords = _getChordsList(line_content) | ||
// this.chords.forEach(function(chord_part) { | ||
// /**/console.log('\n>>---------\n chord_part:\n', chord_part, '\n>>---------\n');/* -debug-*/ | ||
// }) | ||
} | ||
_getChordsList (line_content) { | ||
getChordsList (line_content) { | ||
// https://regex101.com/r/kA6aZ9/1 | ||
@@ -45,48 +38,2 @@ var matches = RegexHelpers.matchAllRegex( | ||
} | ||
_convertChord () { | ||
[ 'C', | ||
'Cmaj7', 'CMaj7', 'CM7', | ||
'Cm', | ||
'Cmin7', 'Cm7', | ||
// extended | ||
'C7', | ||
'Cdim7', 'Cº7', | ||
'C9', | ||
'C11', | ||
'C13', | ||
'Caug', | ||
'CMaug', | ||
'CMinor9', | ||
// suspended | ||
'Csus2', | ||
'Csus4', | ||
'Csus', | ||
// added | ||
'CAdd9', | ||
'C2', | ||
'CAdd11', | ||
'C4', | ||
'CMajor6', | ||
'C6', | ||
'CSixNine', | ||
'CPowerChord', | ||
'C5', | ||
// overridingRoot | ||
'C/C' | ||
].forEach(function (item) { | ||
var chord = this.parser.parse(item) | ||
this.chords[item] = chord | ||
}.bind(this)) | ||
// /* */console.log('\n>>---------\n this.chords:\n', /* -debug-*/ | ||
// /* */require('util').inspect(this.chords, /* -debug-*/ | ||
// /* */{ showHidden: false, depth: null, colors: true }), '\n>>---------\n') /* -debug-*/ | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
38196
14
146
333