Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdown-it-chords

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-chords - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

10

dist/markdown-it-chords.js

@@ -1,2 +0,2 @@

/*! markdown-it-chords 1.0.0 @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownItChords = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/*! markdown-it-chords 1.0.2 @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownItChords = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict'

@@ -134,3 +134,5 @@

const fr = '|', // pipe
nt = String.fromCharCode(0x2016), // double pipe
str = String.fromCharCode(0x0336), // combining long stroke overlay
str0 = String.fromCharCode(0x0335), // combining short stroke overlay
sp = String.fromCharCode(0xa0), // non-breaking space

@@ -145,3 +147,3 @@ finger = String.fromCharCode(0x25cf), // black circle

char, // character to place on fret
nut = '', // the beginning of a line
nut = str0, // the beginning of a line
line, // a single line

@@ -192,3 +194,3 @@ lines = [] // the rendered lines

if (min > 1) {
lines.push(`${sp}${min}`)
lines.push(`${sp}${min}fr`)
nut = str

@@ -203,3 +205,3 @@ }

// first fret of line
line += `${frets ? fr : sp}${nut}`
line += `${frets ? nt : sp}${nut}`
for (let i = min; i <= max; i++) {

@@ -206,0 +208,0 @@ // character in position

2

dist/markdown-it-chords.min.js

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).markdownItChords=e()}}(function(){return function(){return function e(t,n,r){function o(p,u){if(!n[p]){if(!t[p]){var c="function"==typeof require&&require;if(!u&&c)return c(p,!0);if(s)return s(p,!0);var i=new Error("Cannot find module '"+p+"'");throw i.code="MODULE_NOT_FOUND",i}var a=n[p]={exports:{}};t[p][0].call(a.exports,function(e){return o(t[p][1][e]||e)},a,a.exports,e,t,n,r)}return n[p].exports}for(var s="function"==typeof require&&require,p=0;p<r.length;p++)o(r[p]);return o}}()({1:[function(e,t,n){"use strict";const r=/^\[[A-G][b#\u266d\u266f]*(?:M|\u0394|[Mm]aj|m|[Mm]in|-|\u2013|[Dd]im|o|\xb0|\xf8|[Aa]ug|\+|[Ss]usp?|[Aa]dd)?(?:1?[\d])?(?:(?:[\(\/,]?(?:[-\u2013+\u0394ob#\u266d\u266f]|[Mm]aj|[Mm]in|[Ss]usp?)?[0-9]+\)?)*)?(?:\/[A-G][b#\u266d\u266f]*)?(?:\|[XxOo\d,\(\)]{3,})?\]/,o=/^\[([A-G])([\u266d\u266f]*)(M|\u0394|[Mm]aj|m|[Mm]in|\u2011|[Dd]im|\xb0|\xf8|[Aa]ug|\+|[Ss]usp?|[Aa]dd)?(1?[\d])?((?:[\(\/,]?(?:[\u2011+\u0394\xb0\u266d\u266f]|[Mm]aj|[Mm]in|[Ss]usp?)?[0-9]+\)?)*)?(\/[A-G][\u266d\u266f]*)?(\|[XxOo\d,\(\)]{3,})?\]/,s=/(?:[\(\/,1]*(?:[\u2011+\u0394\xb0\u266d\u266f]|[Mm]aj|[Mm]in|[Ss]usp?)?[02-9]+\)?)*/,p=/^\[(?:[XxOo\d,\(\)]{3,})\]/;function u(e,t){let n,u,i,a,h,d,f,l,m=e.pos;return 91===e.src.charCodeAt(m)&&(!!(n=e.src.slice(m)).length&&((u=n.match(r))?(a=((i=u[0].split("|"))[0]+"]").replace(/b/g,"\u266d").replace(/#/g,"\u266f").replace(/o/g,"\xb0").replace(/[-\u2013]/g,"\u2011").match(o),h=c(i[1])):h=c((u=n.match(p)||[""])[0]),!(!a&&!h)&&(l=a?"chord":"chord diagram",t||((f=e.push("chord_open","span",1)).attrs=[["class",l]],(f=e.push("chord_inner_open","span",1)).attrs=[["class","inner"]],a&&(d=!!a[5]&&a[5].match(s),(f=e.push("chord_i_open","i",1)).attrs=[["class","name"]],(f=e.push("text","",0)).content=a[1],a[2]&&(f.content+=a[2]),"\xf8"===a[3]?(e.push("sup_open","sup",1),(f=e.push("text","",0)).content="\xf8",e.push("sup_close","sup",-1)):a[3]&&(f.content+=a[3]),a[4]&&(e.push("sup_open","sup",1),(f=e.push("text","",0)).content=a[4],e.push("sup_close","sup",-1)),d&&d.forEach(t=>{e.push("sup_open","sup",1),(f=e.push("text","",0)).content=t,e.push("sup_close","sup",-1)}),a[6]&&((f=e.push("text","",0)).content=a[6]),f=e.push("chord_i_close","i",-1)),h&&h.length&&((f=e.push("chord_i_open","i",1)).attrs=[["class","diagram"]],h.forEach(t=>{(f=e.push("text","",0)).content=t,e.push("br","br",0)}),f=e.push("chord_i_close","i",-1)),f=e.push("chord_inner_close","span",-1),f=e.push("chord_close","span",-1)),e.pos+=u[0].length,!0)))}function c(e){if(!e)return!1;const t=String.fromCharCode(822),n=String.fromCharCode(160),r=String.fromCharCode(9679),o=String.fromCharCode(9675);let s,p,u,c,i=99,a=0,h="",d=[];return e=e.replace(/[\[\]|]/g,"").replace(/[Oo]/g,"0"),(e=/,/.test(e)?e.split(","):e.match(/\(?[XxOo\d]\)?/g)).reverse(),e=e.map(e=>((s=parseInt(e.replace(/[\(\)]/g,""),10))&&s<i&&(i=s),s&&s>a&&(a=s),u=isNaN(s)?"x":s?/\(/.test(e)?o:r:n,{fret:s||0,char:u})),a<=4&&(i=1),a-i<2&&a++,i>1&&(d.push(`${n}${i}`),h=t),e.forEach((r,o)=>{p=o&&o<e.length-1,c="x"===r.char?"x":n,c+=`${p?"|":n}${h}`;for(let e=i;e<=a;e++)c+=e===r.fret?r.char:`${n}${t}`,c+=`${p?"|":n}${t}`;d.push(`${c}`)}),d}t.exports=function(e){e.inline.ruler.push("chords",u)}},{}]},{},[1])(1)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).markdownItChords=e()}}(function(){return function(){return function e(r,t,n){function o(p,u){if(!t[p]){if(!r[p]){var c="function"==typeof require&&require;if(!u&&c)return c(p,!0);if(s)return s(p,!0);var i=new Error("Cannot find module '"+p+"'");throw i.code="MODULE_NOT_FOUND",i}var a=t[p]={exports:{}};r[p][0].call(a.exports,function(e){return o(r[p][1][e]||e)},a,a.exports,e,r,t,n)}return t[p].exports}for(var s="function"==typeof require&&require,p=0;p<n.length;p++)o(n[p]);return o}}()({1:[function(e,r,t){"use strict";const n=/^\[[A-G][b#\u266d\u266f]*(?:M|\u0394|[Mm]aj|m|[Mm]in|-|\u2013|[Dd]im|o|\xb0|\xf8|[Aa]ug|\+|[Ss]usp?|[Aa]dd)?(?:1?[\d])?(?:(?:[\(\/,]?(?:[-\u2013+\u0394ob#\u266d\u266f]|[Mm]aj|[Mm]in|[Ss]usp?)?[0-9]+\)?)*)?(?:\/[A-G][b#\u266d\u266f]*)?(?:\|[XxOo\d,\(\)]{3,})?\]/,o=/^\[([A-G])([\u266d\u266f]*)(M|\u0394|[Mm]aj|m|[Mm]in|\u2011|[Dd]im|\xb0|\xf8|[Aa]ug|\+|[Ss]usp?|[Aa]dd)?(1?[\d])?((?:[\(\/,]?(?:[\u2011+\u0394\xb0\u266d\u266f]|[Mm]aj|[Mm]in|[Ss]usp?)?[0-9]+\)?)*)?(\/[A-G][\u266d\u266f]*)?(\|[XxOo\d,\(\)]{3,})?\]/,s=/(?:[\(\/,1]*(?:[\u2011+\u0394\xb0\u266d\u266f]|[Mm]aj|[Mm]in|[Ss]usp?)?[02-9]+\)?)*/,p=/^\[(?:[XxOo\d,\(\)]{3,})\]/;function u(e,r){let t,u,i,a,h,d,f,l,m=e.pos;return 91===e.src.charCodeAt(m)&&(!!(t=e.src.slice(m)).length&&((u=t.match(n))?(a=((i=u[0].split("|"))[0]+"]").replace(/b/g,"\u266d").replace(/#/g,"\u266f").replace(/o/g,"\xb0").replace(/[-\u2013]/g,"\u2011").match(o),h=c(i[1])):h=c((u=t.match(p)||[""])[0]),!(!a&&!h)&&(l=a?"chord":"chord diagram",r||((f=e.push("chord_open","span",1)).attrs=[["class",l]],(f=e.push("chord_inner_open","span",1)).attrs=[["class","inner"]],a&&(d=!!a[5]&&a[5].match(s),(f=e.push("chord_i_open","i",1)).attrs=[["class","name"]],(f=e.push("text","",0)).content=a[1],a[2]&&(f.content+=a[2]),"\xf8"===a[3]?(e.push("sup_open","sup",1),(f=e.push("text","",0)).content="\xf8",e.push("sup_close","sup",-1)):a[3]&&(f.content+=a[3]),a[4]&&(e.push("sup_open","sup",1),(f=e.push("text","",0)).content=a[4],e.push("sup_close","sup",-1)),d&&d.forEach(r=>{e.push("sup_open","sup",1),(f=e.push("text","",0)).content=r,e.push("sup_close","sup",-1)}),a[6]&&((f=e.push("text","",0)).content=a[6]),f=e.push("chord_i_close","i",-1)),h&&h.length&&((f=e.push("chord_i_open","i",1)).attrs=[["class","diagram"]],h.forEach(r=>{(f=e.push("text","",0)).content=r,e.push("br","br",0)}),f=e.push("chord_i_close","i",-1)),f=e.push("chord_inner_close","span",-1),f=e.push("chord_close","span",-1)),e.pos+=u[0].length,!0)))}function c(e){if(!e)return!1;const r=String.fromCharCode(8214),t=String.fromCharCode(822),n=String.fromCharCode(821),o=String.fromCharCode(160),s=String.fromCharCode(9679),p=String.fromCharCode(9675);let u,c,i,a,h=99,d=0,f=n,l=[];return e=e.replace(/[\[\]|]/g,"").replace(/[Oo]/g,"0"),(e=/,/.test(e)?e.split(","):e.match(/\(?[XxOo\d]\)?/g)).reverse(),e=e.map(e=>((u=parseInt(e.replace(/[\(\)]/g,""),10))&&u<h&&(h=u),u&&u>d&&(d=u),i=isNaN(u)?"x":u?/\(/.test(e)?p:s:o,{fret:u||0,char:i})),d<=4&&(h=1),d-h<2&&d++,h>1&&(l.push(`${o}${h}fr`),f=t),e.forEach((n,s)=>{c=s&&s<e.length-1,a="x"===n.char?"x":o,a+=`${c?r:o}${f}`;for(let e=h;e<=d;e++)a+=e===n.fret?n.char:`${o}${t}`,a+=`${c?"|":o}${t}`;l.push(`${a}`)}),l}r.exports=function(e){e.inline.ruler.push("chords",u)}},{}]},{},[1])(1)});

@@ -133,3 +133,5 @@ 'use strict'

const fr = '|', // pipe
nt = String.fromCharCode(0x2016), // double pipe
str = String.fromCharCode(0x0336), // combining long stroke overlay
str0 = String.fromCharCode(0x0335), // combining short stroke overlay
sp = String.fromCharCode(0xa0), // non-breaking space

@@ -144,3 +146,3 @@ finger = String.fromCharCode(0x25cf), // black circle

char, // character to place on fret
nut = '', // the beginning of a line
nut = str0, // the beginning of a line
line, // a single line

@@ -191,3 +193,3 @@ lines = [] // the rendered lines

if (min > 1) {
lines.push(`${sp}${min}`)
lines.push(`${sp}${min}fr`)
nut = str

@@ -202,3 +204,3 @@ }

// first fret of line
line += `${frets ? fr : sp}${nut}`
line += `${frets ? nt : sp}${nut}`
for (let i = min; i <= max; i++) {

@@ -205,0 +207,0 @@ // character in position

{
"name": "markdown-it-chords",
"version": "1.0.0",
"version": "1.0.2",
"description": "Add support for lyric sheet chords in markdown.",

@@ -11,3 +11,3 @@ "main": "index.js",

"lint": "eslint .",
"pub": "yarn lint && yarn test && make build && make publish",
"pub": "echo deprecated, use make publish",
"test": "nyc --check-coverage --lines 100 mocha"

@@ -19,6 +19,7 @@ },

],
"author": "",
"author": "David Hunt",
"license": "MIT",
"devDependencies": {
"browserify": "^16.2.3",
"coveralls": "^3.1.0",
"eslint": "^5.16.0",

@@ -31,5 +32,15 @@ "markdown-it": "^8.4.2",

},
"dependencies": {
"coveralls": "^3.0.3"
}
"dependencies": {},
"directories": {
"doc": "docs",
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dnotes/markdown-it-chords.git"
},
"bugs": {
"url": "https://github.com/dnotes/markdown-it-chords/issues"
},
"homepage": "https://dnotes.github.io/markdown-it-chords"
}

@@ -9,15 +9,75 @@ #!/usr/bin/env node

let readmeText = fs.readFileSync('./README.md', { encoding: 'utf8' })
let readme = md.render(readmeText)
let readme = fs.readFileSync('./README.md', { encoding: 'utf8' }).split('<!--song-->\n')
let song = readme.splice(1, 1)[0]
let styles = fs.readFileSync('./markdown-it-chords.css', { encoding: 'utf8' })
let output = `
<html>
let output = `<html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>markdown-it-chords: Write your lyric sheets in markdown</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/11.0.0/markdown-it.min.js" integrity="sha256-3mv+NUxFuBg26MtcnuN2X37WUxuGunWCCiG2YCSBjNc=" crossorigin="anonymous"></script>
<script src="../dist/markdown-it-chords.min.js"></script>
<script>
const md = window.markdownit().use(window.markdownItChords)
$(function() {
$('textarea#markdown').keyup(function() {
$('#preview').html(md.render($(this).val()))
})
$('#handed').change(function() {
$('.chord i.diagram').attr('dir', $(this).val())
})
$('#chord-diagram-font-size').on('input', function() {
$(':root').css('--chord-diagram-font-size', $(this).val() + 'px')
})
$('#song-font-size').on('input', function() {
$('#preview').css('font-size', $(this).val() + 'pt')
})
})
</script>
</head>
<style>
${styles}
body {
padding:50px;
font-size:16pt;
padding: 50px;
font-size: 14pt;
max-width: 1900px;
margin: 0 auto;
}
${styles}
#sandbox div,
#sandbox textarea {
width: 50%;
resize: none;
overflow: scroll;
float: left;
box-sizing: border-box;
padding: 10px;
}
code {
background: #eee;
font-size: 75%;
}
pre {
background: #eee;
padding: 10px 10px 0;
max-width: 100%;
overflow: scroll;
display: inline-block;
}
.clearfix:after, pre:after {
content: "";
display: table;
clear: both;
}
#controls {
background: lightgray;
padding: 10px;
}
#controls select,
#controls input {
vertical-align: middle;
}
</style>

@@ -27,4 +87,22 @@

${readme}
${md.render(readme[0])}
<div id="controls">
<label for="handed">Playing hand:</label>
<select name="handed" id="handed">
<option value="ltr" selected="selected">right-handed</option>
<option value="rtl">left-handed</option>
</select>
<label for="song-font-size">Song font size:</label>
<input type="range" min="10" max="24" value="16" class="slider" name="song-font-size" id="song-font-size">
<label for="chord-diagram-font-size">Diagram size:</label>
<input type="range" min="5" max="24" value="10" class="slider" name="chord-diagram-font-size" id="chord-diagram-font-size">
</div>
<div id="sandbox" class="clearfix">
<textarea name="markdown" id="markdown" rows="30">${song}</textarea>
<div id="preview">${md.render(song)}</div>
</div>
${md.render(readme[1])}
</body>

@@ -31,0 +109,0 @@ </html>

@@ -0,12 +1,18 @@

## Chords for lyric sheets, in Markdown
![build](https://travis-ci.org/dnotes/markdown-it-chords.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/dnotes/markdown-it-chords/badge.svg?branch=master)](https://coveralls.io/github/dnotes/markdown-it-chords?branch=master)
## Chords for lyric sheets, in Markdown
[Github]: https://github.com/dnotes/markdown-it-chords
[NPM]: https://npmjs.com/package/markdown-it-chords
[Docs]: https://dnotes.github.io/markdown-it-chords/
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.
**This README.md file is not rendered properly on Github.** Please see [the documentation site](https://dnotes.github.io/markdown-it-chords/).
**The chords will not be rendered properly on [Github] or [NPM].** Please see [the documentation site][docs].
## Installation and Usage
### Node
`npm i markdown-it-chords` or `yarn add markdown-it-chords`

@@ -20,4 +26,28 @@

see [readme.js](https://github.com/dnotes/markdown-it-chords/blob/master/readme.js)
for an example of usage in NodeJS.
### Browser
1. 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>
```
2. 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][Docs] has a markdown sandbox which uses this plugin in the browser.
## Example and Syntax
<!--song-->
[C]Do, a deer, a female deer\

@@ -33,2 +63,3 @@ [Dm]Ray, a drop of golden sun\

That will [Dm7|x57565]bring — [F6(9)|x87788]us —— [Em7|x79787]back — [G13|x,10,x,12,12,12]to —— [8xx987]Do . . . .[8,(10),10,9,10,x]
<!--song-->

@@ -35,0 +66,0 @@ ### Chords

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc