From 61dc6dbc150dd80e4c1aaa5068cd1432363998dc Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 26 Mar 2017 20:39:07 +0800 Subject: Add support of abcjs --- public/js/extra.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'public/js') 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 @@ -385,6 +385,26 @@ export function finishView (view) { $value.parent().append('
' + err + '
') 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('
' + err + '
') + console.warn(err) + } }) // image href new window(emoji not included) const images = view.find('img.raw[src]').removeClass('raw') @@ -888,6 +908,8 @@ function highlightRender (code, lang) { return `
${code}
` } else if (lang === 'mermaid') { return `
${code}
` + } else if (lang === 'abc') { + return `
${code}
` } const result = { value: code -- cgit v1.2.3