-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from no-chris/add-ultimateguitar-filer
Add Ultimate Guitar filter
- Loading branch information
Showing
21 changed files
with
278 additions
and
6,250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ChordSymbolUltimateGuitar | ||
|
||
Modify the `ChordSymbol` output to be closer with the chord symbols accepted by the Ultimate Guitar website. | ||
If you use `ChordSymbol` to generate chord charts to be submitted on this website, you definitely want to use this filter. | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { chordParserFactory, chordRendererFactory } from 'chord-symbol'; | ||
import chordSymbolUltimateGuitar from '../src/chordSymbolUltimateGuitar'; | ||
|
||
const parsed = chordParserFactory()('C7(#9)'); | ||
const rendered = chordRendererFactory({ | ||
customFilters: [chordSymbolUltimateGuitar()], | ||
useShortNamings: true, | ||
})(parsed); | ||
|
||
// C7#9 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* eslint-env node */ | ||
const presets = [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
browsers: 'last 2 versions', | ||
}, | ||
}, | ||
], | ||
]; | ||
|
||
module.exports = { presets }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-env node */ | ||
const baseConfig = require('../../jest.config.base'); | ||
const packageJson = require('./package'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
name: packageJson.name, | ||
displayName: packageJson.name, | ||
|
||
rootDir: '../..', | ||
}; |
63 changes: 63 additions & 0 deletions
63
packages/chord-symbol-ultimateguitar/lib/chord-symbol-ultimateguitar.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/chord-symbol-ultimateguitar/lib/chord-symbol-ultimateguitar.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "chord-symbol-ultimateguitar", | ||
"version": "3.0.0-beta.2", | ||
"description": "Format chord symbols in an Ultimate Guitar-friendly way", | ||
"author": "Christophe Noël", | ||
"homepage": "https://github.com/no-chris/chord-symbol/tree/main/packages/chord-symbol-ultimateguitar#readme", | ||
"license": "MIT", | ||
"main": "lib/chord-symbol-ultimateguitar.js", | ||
"directories": { | ||
"lib": "lib", | ||
"test": "src" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/no-chris/chord-symbol.git" | ||
}, | ||
"scripts": { | ||
"build": "webpack" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/no-chris/chord-symbol/issues" | ||
}, | ||
"keywords": [ | ||
"chord", | ||
"chords", | ||
"chord-parsing", | ||
"guitar", | ||
"guitar-chords", | ||
"music", | ||
"music-theory", | ||
"parser", | ||
"piano", | ||
"ukulele" | ||
], | ||
"dependencies": { | ||
"chord-symbol": "^3.0.0-beta.0" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/chord-symbol-ultimateguitar/src/chordSymbolUltimateGuitar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const chordSymbolUltimateGuitar = () => { | ||
return (chord) => { | ||
chord.formatted.symbol = chord.formatted.symbol | ||
.replace(/[() ]/g, '') | ||
.replace('mM', 'mMaj') | ||
.replace('°', 'dim'); | ||
|
||
return chord; | ||
}; | ||
}; | ||
|
||
export default chordSymbolUltimateGuitar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
env: { | ||
jest: true, | ||
node: true, | ||
}, | ||
rules: { | ||
'no-restricted-imports': ['off'], | ||
'max-len': ['off'], | ||
'max-params': ['warn', { max: 6 }], | ||
'max-lines': ['error', { max: 550 }], | ||
}, | ||
}; |
29 changes: 29 additions & 0 deletions
29
packages/chord-symbol-ultimateguitar/tests/chordSymbolUltimateGuitar.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
chordParserFactory, | ||
chordRendererFactory, | ||
} from '../../chord-symbol/src/index'; | ||
import chordSymbolUltimateGuitar from '../src/chordSymbolUltimateGuitar'; | ||
|
||
describe('chordSymbolUltimateGuitar', () => { | ||
test('Module', () => { | ||
expect(chordSymbolUltimateGuitar).toBeInstanceOf(Function); | ||
expect(chordSymbolUltimateGuitar()).toBeInstanceOf(Function); | ||
}); | ||
}); | ||
|
||
describe.each([ | ||
['remove parenthesis', 'A7(#9)', 'A7#9'], | ||
['replace ° with "dim" in dim chords', 'A°', 'Adim'], | ||
['replace ° with "dim" in dim7 chords', 'A7°', 'Adim7'], | ||
['replace mM with "mMaj"', 'AmM7', 'AmMaj7'], | ||
['remove spaces', 'C(#9)', 'Cadd#9'], | ||
])('%s', (title, input, output) => { | ||
test(input + ' => ' + output, () => { | ||
const parsed = chordParserFactory()(input); | ||
const rendered = chordRendererFactory({ | ||
customFilters: [chordSymbolUltimateGuitar()], | ||
useShortNamings: true, | ||
})(parsed); | ||
expect(rendered).toEqual(output); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-env node */ | ||
const path = require('path'); | ||
|
||
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | ||
|
||
const buildDir = 'lib'; | ||
|
||
const config = { | ||
target: 'web', | ||
mode: 'production', | ||
devtool: 'source-map', | ||
|
||
entry: { | ||
'chord-symbol-ultimateguitar': './src/chordSymbolUltimateGuitar.js', | ||
}, | ||
|
||
output: { | ||
filename: '[name].js', | ||
path: path.resolve(process.cwd(), buildDir), | ||
library: 'chord-symbol-ultimateguitar', | ||
libraryTarget: 'umd', | ||
// https://github.com/webpack/webpack/pull/8625 | ||
globalObject: "typeof self !== 'undefined' ? self : this", | ||
}, | ||
|
||
optimization: { | ||
minimize: false, | ||
}, | ||
|
||
performance: { | ||
hints: false, | ||
}, | ||
|
||
plugins: [new CleanWebpackPlugin()], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.