Skip to content

Commit 61dc6db

Browse files
committed
Add support of abcjs
1 parent aaf4948 commit 61dc6db

6 files changed

Lines changed: 73 additions & 7 deletions

File tree

public/css/markdown.css

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@
113113
.markdown-body pre.flow-chart,
114114
.markdown-body pre.sequence-diagram,
115115
.markdown-body pre.graphviz,
116-
.markdown-body pre.mermaid {
116+
.markdown-body pre.mermaid,
117+
.markdown-body pre.abc {
117118
text-align: center;
118119
background-color: inherit;
119120
border-radius: 0;
@@ -123,14 +124,16 @@
123124
.markdown-body pre.flow-chart > code,
124125
.markdown-body pre.sequence-diagram > code,
125126
.markdown-body pre.graphviz > code,
126-
.markdown-body pre.mermaid > code {
127+
.markdown-body pre.mermaid > code,
128+
.markdown-body pre.abc > code {
127129
text-align: left;
128130
}
129131

130132
.markdown-body pre.flow-chart > svg,
131133
.markdown-body pre.sequence-diagram > svg,
132134
.markdown-body pre.graphviz > svg,
133-
.markdown-body pre.mermaid > svg {
135+
.markdown-body pre.mermaid > svg,
136+
.markdown-body pre.abc > svg {
134137
max-width: 100%;
135138
height: 100%;
136139
}

public/css/slide.css

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ code[data-gist-id]:after {
221221
pre.flow-chart,
222222
pre.sequence-diagram,
223223
pre.graphviz,
224-
pre.mermaid {
224+
pre.mermaid,
225+
pre.abc {
225226
text-align: center;
226227
background-color: white;
227228
border-radius: 0;
@@ -231,14 +232,16 @@ pre.mermaid {
231232
pre.flow-chart > code,
232233
pre.sequence-diagram > code,
233234
pre.graphviz > code,
234-
pre.mermaid > code {
235+
pre.mermaid > code,
236+
pre.abc > code {
235237
text-align: left;
236238
}
237239

238240
pre.flow-chart > svg,
239241
pre.sequence-diagram > svg,
240242
pre.graphviz > svg,
241-
pre.mermaid > svg {
243+
pre.mermaid > svg,
244+
pre.abc > svg {
242245
max-width: 100%;
243246
height: 100%;
244247
}

public/docs/features.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,24 @@ gantt
280280
anther task : 24d
281281
```
282282

283+
### Abc
284+
```abc
285+
X:1
286+
T:Speed the Plough
287+
M:4/4
288+
C:Trad.
289+
K:G
290+
|:GABc dedB|dedB dedB|c2ec B2dB|c2A2 A2BA|
291+
GABc dedB|dedB dedB|c2ec B2dB|A2F2 G4:|
292+
|:g2gf gdBd|g2f2 e2d2|c2ec B2dB|c2A2 A2df|
293+
g2gf g2Bd|g2f2 e2d2|c2ec B2dB|A2F2 G4:|
294+
```
295+
283296
> More information about **sequence diagrams** syntax [here](http://bramp.github.io/js-sequence-diagrams/).
284297
> More information about **flow charts** syntax [here](http://adrai.github.io/flowchart.js/).
285298
> More information about **graphviz** syntax [here](http://www.tonyballantyne.com/graphs.html)
286299
> More information about **mermaid** syntax [here](http://knsv.github.io/mermaid)
300+
> More information about **abc** syntax [here](http://abcnotation.com/learn)
287301
288302
Alert Area
289303
---

public/js/extra.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,26 @@ export function finishView (view) {
385385
$value.parent().append('<div class="alert alert-warning">' + err + '</div>')
386386
console.warn(err)
387387
}
388+
})
389+
// abc.js
390+
const abcs = view.find('div.abc.raw').removeClass('raw')
391+
abcs.each((key, value) => {
392+
try {
393+
var $value = $(value)
394+
var $ele = $(value).parent().parent()
395+
396+
ABCJS.renderAbc(value, $value.text())
397+
398+
$ele.addClass('abc')
399+
$value.children().unwrap().unwrap()
400+
const svg = $ele.find('> svg')
401+
svg[0].setAttribute('viewBox', `0 0 ${svg.attr('width')} ${svg.attr('height')}`)
402+
svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet')
403+
} catch (err) {
404+
$value.unwrap()
405+
$value.parent().append('<div class="alert alert-warning">' + err + '</div>')
406+
console.warn(err)
407+
}
388408
})
389409
// image href new window(emoji not included)
390410
const images = view.find('img.raw[src]').removeClass('raw')
@@ -888,6 +908,8 @@ function highlightRender (code, lang) {
888908
return `<div class="graphviz raw">${code}</div>`
889909
} else if (lang === 'mermaid') {
890910
return `<div class="mermaid raw">${code}</div>`
911+
} else if (lang === 'abc') {
912+
return `<div class="abc raw">${code}</div>`
891913
}
892914
const result = {
893915
value: code

public/vendor/abcjs_basic_3.1.1-min.js

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webpackBaseConfig.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ module.exports = {
202202
'script!ot',
203203
'flowchart.js',
204204
'js-sequence-diagrams',
205+
'script!abcjs',
205206
'expose?RevealMarkdown!reveal-markdown',
206207
path.join(__dirname, 'public/js/google-drive-upload.js'),
207208
path.join(__dirname, 'public/js/google-drive-picker.js'),
@@ -258,6 +259,7 @@ module.exports = {
258259
'flowchart.js',
259260
'js-sequence-diagrams',
260261
'expose?Viz!viz.js',
262+
'script!abcjs',
261263
'expose?io!socket.io-client',
262264
'expose?RevealMarkdown!reveal-markdown',
263265
path.join(__dirname, 'public/js/google-drive-upload.js'),
@@ -269,6 +271,7 @@ module.exports = {
269271
'expose?filterXSS!xss',
270272
'flowchart.js',
271273
'js-sequence-diagrams',
274+
'script!abcjs',
272275
'expose?RevealMarkdown!reveal-markdown',
273276
path.join(__dirname, 'public/js/pretty.js')
274277
],
@@ -297,6 +300,7 @@ module.exports = {
297300
'flowchart.js',
298301
'js-sequence-diagrams',
299302
'expose?Viz!viz.js',
303+
'script!abcjs',
300304
'expose?RevealMarkdown!reveal-markdown',
301305
path.join(__dirname, 'public/js/pretty.js')
302306
],
@@ -306,6 +310,7 @@ module.exports = {
306310
'expose?filterXSS!xss',
307311
'flowchart.js',
308312
'js-sequence-diagrams',
313+
'script!abcjs',
309314
'expose?RevealMarkdown!reveal-markdown',
310315
path.join(__dirname, 'public/js/slide.js')
311316
],
@@ -337,6 +342,7 @@ module.exports = {
337342
'flowchart.js',
338343
'js-sequence-diagrams',
339344
'expose?Viz!viz.js',
345+
'script!abcjs',
340346
'headjs',
341347
'expose?Reveal!reveal.js',
342348
'expose?RevealMarkdown!reveal-markdown',
@@ -370,7 +376,8 @@ module.exports = {
370376
'gist-embed': path.join(__dirname, 'node_modules/gist-embed/gist-embed.min.js'),
371377
'bootstrap-tooltip': path.join(__dirname, 'public/vendor/bootstrap/tooltip.min.js'),
372378
'headjs': path.join(__dirname, 'node_modules/reveal.js/lib/js/head.min.js'),
373-
'reveal-markdown': path.join(__dirname, 'public/js/reveal-markdown.js')
379+
'reveal-markdown': path.join(__dirname, 'public/js/reveal-markdown.js'),
380+
abcjs: path.join(__dirname, 'public/vendor/abcjs_basic_3.1.1-min.js')
374381
}
375382
},
376383

0 commit comments

Comments
 (0)