summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
authorWu Cheng-Han2017-03-26 20:39:07 +0800
committerWu Cheng-Han2017-03-26 20:39:07 +0800
commit61dc6dbc150dd80e4c1aaa5068cd1432363998dc (patch)
tree34c4afe6ab1c4b0aa4148ba63e9152e3410e4099 /public/js
parentaaf4948c557e7b59cfb7af844fe41d0cd451b834 (diff)
Add support of abcjs
Diffstat (limited to '')
-rw-r--r--public/js/extra.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index d237a2f2..605c8305 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -386,6 +386,26 @@ export function finishView (view) {
console.warn(err)
}
})
+ // abc.js
+ const abcs = view.find('div.abc.raw').removeClass('raw')
+ abcs.each((key, value) => {
+ try {
+ var $value = $(value)
+ var $ele = $(value).parent().parent()
+
+ ABCJS.renderAbc(value, $value.text())
+
+ $ele.addClass('abc')
+ $value.children().unwrap().unwrap()
+ const svg = $ele.find('> svg')
+ svg[0].setAttribute('viewBox', `0 0 ${svg.attr('width')} ${svg.attr('height')}`)
+ svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet')
+ } catch (err) {
+ $value.unwrap()
+ $value.parent().append('<div class="alert alert-warning">' + err + '</div>')
+ console.warn(err)
+ }
+ })
// image href new window(emoji not included)
const images = view.find('img.raw[src]').removeClass('raw')
images.each((key, value) => {
@@ -888,6 +908,8 @@ function highlightRender (code, lang) {
return `<div class="graphviz raw">${code}</div>`
} else if (lang === 'mermaid') {
return `<div class="mermaid raw">${code}</div>`
+ } else if (lang === 'abc') {
+ return `<div class="abc raw">${code}</div>`
}
const result = {
value: code