mirror of https://github.com/status-im/codimd.git
Support "spoiler" container syntax
Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
parent
75513fae85
commit
8d889a6736
|
@ -993,6 +993,22 @@ md.use(markdownitContainer, 'success', { render: renderContainer })
|
||||||
md.use(markdownitContainer, 'info', { render: renderContainer })
|
md.use(markdownitContainer, 'info', { render: renderContainer })
|
||||||
md.use(markdownitContainer, 'warning', { render: renderContainer })
|
md.use(markdownitContainer, 'warning', { render: renderContainer })
|
||||||
md.use(markdownitContainer, 'danger', { render: renderContainer })
|
md.use(markdownitContainer, 'danger', { render: renderContainer })
|
||||||
|
md.use(markdownitContainer, 'spoiler', {
|
||||||
|
validate: function (params) {
|
||||||
|
return params.trim().match(/^spoiler\s+(.*)$/)
|
||||||
|
},
|
||||||
|
render: function (tokens, idx) {
|
||||||
|
var m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/)
|
||||||
|
|
||||||
|
if (tokens[idx].nesting === 1) {
|
||||||
|
// opening tag
|
||||||
|
return '<details><summary>' + md.utils.escapeHtml(m[1]) + '</summary>\n'
|
||||||
|
} else {
|
||||||
|
// closing tag
|
||||||
|
return '</details>\n'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
let defaultImageRender = md.renderer.rules.image
|
let defaultImageRender = md.renderer.rules.image
|
||||||
md.renderer.rules.image = function (tokens, idx, options, env, self) {
|
md.renderer.rules.image = function (tokens, idx, options, env, self) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ var updateViewDebounce = 100
|
||||||
var cursorMenuThrottle = 50
|
var cursorMenuThrottle = 50
|
||||||
var cursorActivityDebounce = 50
|
var cursorActivityDebounce = 50
|
||||||
var cursorAnimatePeriod = 100
|
var cursorAnimatePeriod = 100
|
||||||
var supportContainers = ['success', 'info', 'warning', 'danger']
|
var supportContainers = ['success', 'info', 'warning', 'danger', 'spoiler']
|
||||||
var supportCodeModes = ['javascript', 'typescript', 'jsx', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'haskell', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki', 'go', 'gherkin'].concat(hljs.listLanguages())
|
var supportCodeModes = ['javascript', 'typescript', 'jsx', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'haskell', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki', 'go', 'gherkin'].concat(hljs.listLanguages())
|
||||||
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid', 'abc']
|
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid', 'abc']
|
||||||
var supportHeaders = [
|
var supportHeaders = [
|
||||||
|
|
|
@ -110,6 +110,22 @@ md.use(markdownitContainer, 'success', { render: renderContainer })
|
||||||
md.use(markdownitContainer, 'info', { render: renderContainer })
|
md.use(markdownitContainer, 'info', { render: renderContainer })
|
||||||
md.use(markdownitContainer, 'warning', { render: renderContainer })
|
md.use(markdownitContainer, 'warning', { render: renderContainer })
|
||||||
md.use(markdownitContainer, 'danger', { render: renderContainer })
|
md.use(markdownitContainer, 'danger', { render: renderContainer })
|
||||||
|
md.use(markdownitContainer, 'spoiler', {
|
||||||
|
validate: function (params) {
|
||||||
|
return params.trim().match(/^spoiler\s+(.*)$/)
|
||||||
|
},
|
||||||
|
render: function (tokens, idx) {
|
||||||
|
var m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/)
|
||||||
|
|
||||||
|
if (tokens[idx].nesting === 1) {
|
||||||
|
// opening tag
|
||||||
|
return '<details><summary>' + md.utils.escapeHtml(m[1]) + '</summary>\n'
|
||||||
|
} else {
|
||||||
|
// closing tag
|
||||||
|
return '</details>\n'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
window.preventSyncScrollToEdit = false
|
window.preventSyncScrollToEdit = false
|
||||||
window.preventSyncScrollToView = false
|
window.preventSyncScrollToView = false
|
||||||
|
|
Loading…
Reference in New Issue