This markdown-it plugin makes it easy to add chords to your lyric sheets by simply adding the chords, in brackets, wherever they appear in the context of the lyrics. Chords can be anywhere in a line of text, even in the middle of a word. You can also add chord diagrams that will display like a guitar fretboard.
The chords will not be rendered properly on Github or NPM. Please see the documentation site.
npm i markdown-it-chords
or yarn add markdown-it-chords
var md = require('markdown-it')()
md.use(require('markdown-it-chords'))
md.render('[C]La [F]la [G]la [C]la')
see readme.js for an example of usage in NodeJS.
Include the file in the document's head, and initialize the markdown-it object:
<script src="[cdnjs.com link for markdown-it]"></script>
<script src="[cdnjs.com link for markdown-it-chords]"></script>
<script>const md = window.markdown-it('commonmark').use(window.markdownItChords)</script>
Do what you want in the body of the document:
$('textarea#markdown').keyup(function() {
var text = $(this).val()
$('#preview').html(md.render(text))
})
The documentation site has a markdown sandbox which uses this plugin in the browser.
CDo, a deer, a female deer
DmRay, a drop of golden sun
E♭May, a possiD♯bility
D/F♯Fee, the price you pay to run
(half-time, bossanova guitar)
CΔ913So, — I'd C6like to see BraFmaj9zil . . . . .F6(9)
E‑7La, — I'd CM7sus2really like to E9go . . .E7♭9
AmΔ7/9Tea, — I A‑7sit and sip so D♯ø7slow . . .D♯°7
That will Dm7 5fr
̶● ̶ ̶ ̶ ̶ ̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶●|̶ ̶|̶ ̶|̶
‖̶ ̶|̶ ̶|̶●|̶
‖̶●|̶ ̶|̶ ̶|̶
x ̶ ̶ ̶ ̶ ̶ ̶ ̶
bring — F6(9) 7fr
̶ ̶ ̶● ̶ ̶ ̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶●|̶ ̶|̶ ̶|̶
‖̶●|̶ ̶|̶ ̶|̶
‖̶ ̶|̶●|̶ ̶|̶
x ̶ ̶ ̶ ̶ ̶ ̶ ̶
us —— Em7 7fr
̶● ̶ ̶ ̶ ̶ ̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶●|̶ ̶|̶ ̶|̶
‖̶ ̶|̶ ̶|̶●|̶
‖̶●|̶ ̶|̶ ̶|̶
x ̶ ̶ ̶ ̶ ̶ ̶ ̶
back — G13 10fr
̶ ̶ ̶ ̶ ̶● ̶
‖̶ ̶|̶ ̶|̶●|̶
‖̶ ̶|̶ ̶|̶●|̶
x‖̶ ̶|̶ ̶|̶ ̶|̶
‖̶●|̶ ̶|̶ ̶|̶
x ̶ ̶ ̶ ̶ ̶ ̶ ̶
to —— 7fr
̶● ̶ ̶ ̶ ̶ ̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶ ̶|̶ ̶|̶●|̶
x‖̶ ̶|̶ ̶|̶ ̶|̶
x‖̶ ̶|̶ ̶|̶ ̶|̶
̶ ̶ ̶● ̶ ̶ ̶
Do . . . . 8fr
x ̶ ̶ ̶ ̶ ̶ ̶ ̶
‖̶ ̶|̶ ̶|̶●|̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶ ̶|̶ ̶|̶●|̶
‖̶ ̶|̶ ̶|̶○|̶
̶● ̶ ̶ ̶ ̶ ̶
Chords are written inside brackets. The parts of a chord are as follows:
The one-letter name of the root note with an optional sharp or flat. The chord root must be capitalized. Sharps and flats can be indicated as the unicode sharp (♯
) and flat (♭
) symbols, or by the more common hash (#) and lowercase B (b) symbols.
C[C]
,
F♯[F#]
,
B♭[Bb]
(optional) Color and/or number indicators. Recognized color indications include M
, Δ
, maj
, m
, min
, -
, dim
, o
, °
, ø
, aug
, +
, sus
, and add
. The first letter of abbreviations may be capitalized.
Dmaj[Dmaj]
,
DMaj7[DMaj7]
,
DΔ7[DΔ7]
,
D7[D7]
,
Dm[Dm]
,
Dmin[Dmin]
,
D‑7[D-7]
,
Ddim[Ddim]
,
Dø[Dø]
,
D°7[Do7]
,
DAug[DAug]
,
D+[D+]
,
Dsus4[Dsus4]
,
Dadd9[Dadd9]
(optional) Extended color for the chord. Recognized extended chord indications include -
, +
, Δ
, b
, #
, ♭
, ♯
, maj
, min
, and sus
. Extensions may be separated from each other by a comma (,♭9
) or slash (/♭9
), or may be placed in parentheses ((♭9)
).
CΔ9(13)[CΔ9(13)]
,
Fmaj9[Fmaj9]
,
F6,9[F6,9]
,
E‑7[E-7/b13]
,
CM7sus2[CM7sus2]
,
E7♭9[E7b9]
,
AmΔ7/9[AmΔ7/9]
,
(optional) Bass note for the chord. The bass note is separated from the rest of the chord by a slash (/
).
D/F♯[D/F#]
,
Am7/C[Am7/C]
(optional) Chord diagram. The chord diagram is separated from the rest of the chord by a vertical bar (|
). See below for syntax.
Chord diagrams are pictures of where the fingers go on the neck of a guitar or other stringed instrument. In markdown, they are written with one place for each string, consiting of one of the following:
0
, O
, or o
for an open stringX
or x
for a string that is not playedDiagrams can be attached to a chord (C ̵ ̶ ̶ ̶ ̶ ̶ ̶
‖̵●|̶ ̶|̶ ̶|̶
‖̵ ̶|̶ ̶|̶ ̶|̶
‖̵ ̶|̶●|̶ ̶|̶
‖̵ ̶|̶ ̶|̶●|̶
̵ ̶ ̶ ̶ ̶○ ̶[C|(3)32010]
) or may stand alone ( ̵ ̶ ̶ ̶ ̶ ̶ ̶
‖̵●|̶ ̶|̶ ̶|̶
‖̵ ̶|̶ ̶|̶ ̶|̶
‖̵ ̶|̶●|̶ ̶|̶
‖̵ ̶|̶ ̶|̶●|̶
̵ ̶ ̶ ̶ ̶○ ̶[(3)32010]
). Usually a chord is rendered within a <span class="chord">
element, but a standalone diagram will have an additional class: <span class="chord diagram">
. This eases some use cases like having chord diagrams that appear when hovering over a chord name, as is the case with the C chord above.
Chord diagrams for frets beyond the 9th must be written with each fret separated by a comma. Diagrams extending beyond the 4th fret are calculated from a numbered fret.
̵ ̶ ̶ ̶ ̶ ̶ ̶
‖̵●|̶ ̶|̶ ̶|̶
‖̵ ̶|̶ ̶|̶ ̶|̶
‖̵ ̶|̶●|̶ ̶|̶
‖̵ ̶|̶ ̶|̶●|̶
̵ ̶ ̶ ̶ ̶○ ̶
Cmaj ([(3)32010]
) ,
̵ ̶ ̶ ̶ ̶ ̶ ̶● ̶
‖̵ ̶|̶ ̶|̶ ̶|̶●|̶
‖̵ ̶|̶ ̶|̶ ̶|̶●|̶
‖̵ ̶|̶ ̶|̶●|̶ ̶|̶
‖̵ ̶|̶ ̶|̶ ̶|̶●|̶
x ̵ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶
D♭9 ([x43444]
) ,
4fr
̶ ̶ ̶● ̶ ̶ ̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶●|̶ ̶|̶ ̶|̶
‖̶ ̶|̶●|̶ ̶|̶
x ̶ ̶ ̶ ̶ ̶ ̶ ̶
D9 ([x54555]
) ,
8fr
x ̶ ̶ ̶ ̶ ̶ ̶ ̶
‖̶ ̶|̶ ̶|̶●|̶
‖̶ ̶|̶●|̶ ̶|̶
‖̶ ̶|̶ ̶|̶●|̶
‖̶ ̶|̶ ̶|̶○|̶
̶● ̶ ̶ ̶ ̶ ̶
C6 ([8,(10),10,9,10,x]
)
Chord diagrams are, fundamentally, plain text written in Unicode, which means that they can be easily reversed by adding dir="rtl"
to the proper element, which may be useful for left-handed guitar players.