diff options
author | Cheng-Han, Wu | 2016-03-15 10:56:53 +0800 |
---|---|---|
committer | Cheng-Han, Wu | 2016-03-15 10:56:53 +0800 |
commit | e729166c322a06530addd6c63400e08326a682ed (patch) | |
tree | ca8823e3e4e2d20e334fdff8aa65aae1571587fe /public/js | |
parent | 2a42fac6d4730a4362ef488690953f091941998a (diff) |
Updated to support container syntax and styles
Diffstat (limited to '')
-rw-r--r-- | public/js/extra.js | 10 | ||||
-rw-r--r-- | public/js/syncscroll.js | 11 |
2 files changed, 21 insertions, 0 deletions
diff --git a/public/js/extra.js b/public/js/extra.js index a72ca5e1..7b4eb0c0 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -728,6 +728,16 @@ md.use(window.markdownitIns); md.use(window.markdownitSub); md.use(window.markdownitSup); md.use(window.markdownitMathjax); +function renderContainer(tokens, idx, options, env, self) { + tokens[idx].attrJoin('role', 'alert'); + tokens[idx].attrJoin('class', 'alert'); + tokens[idx].attrJoin('class', 'alert-' + tokens[idx].info.trim()); + return self.renderToken.apply(self, arguments); +} +md.use(window.markdownitContainer, 'success', { render: renderContainer }); +md.use(window.markdownitContainer, 'info', { render: renderContainer }); +md.use(window.markdownitContainer, 'warning', { render: renderContainer }); +md.use(window.markdownitContainer, 'danger', { render: renderContainer }); md.renderer.rules.image = function (tokens, idx, options, env, self) { tokens[idx].attrJoin('class', 'raw'); diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js index 7cf62bc5..890188cb 100644 --- a/public/js/syncscroll.js +++ b/public/js/syncscroll.js @@ -93,6 +93,17 @@ md.renderer.rules.code_block = function (tokens, idx, options, env, self) { } return '<pre><code>' + md.utils.escapeHtml(tokens[idx].content) + '</code></pre>\n'; }; +function renderContainer(tokens, idx, options, env, self) { + tokens[idx].attrJoin('role', 'alert'); + tokens[idx].attrJoin('class', 'alert'); + tokens[idx].attrJoin('class', 'alert-' + tokens[idx].info.trim()); + addPart(tokens, idx); + return self.renderToken.apply(self, arguments); +} +md.use(window.markdownitContainer, 'success', { render: renderContainer }); +md.use(window.markdownitContainer, 'info', { render: renderContainer }); +md.use(window.markdownitContainer, 'warning', { render: renderContainer }); +md.use(window.markdownitContainer, 'danger', { render: renderContainer }); var preventSyncScroll = false; |