mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Merge branch 'markdown' into v0.5.2
* markdown: markdown strike bug fixed, no emoji shortcut, checkbox syntax added
This commit is contained in:
@@ -14,7 +14,7 @@ const katex = window.katex
|
||||
const sanitizeOpts = {
|
||||
allowedTags: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
|
||||
'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div',
|
||||
'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'img', 'span', 'cite', 'del', 'u', 'sub', 'sup' ],
|
||||
'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'img', 'span', 'cite', 'del', 'u', 'sub', 'sup', 's', 'input', 'label' ],
|
||||
allowedClasses: {
|
||||
'a': ['lineAnchor'],
|
||||
'div': ['math'],
|
||||
@@ -24,14 +24,20 @@ const sanitizeOpts = {
|
||||
allowedAttributes: {
|
||||
a: ['href', 'data-key'],
|
||||
img: [ 'src' ],
|
||||
label: ['for'],
|
||||
input: ['checked', 'type'],
|
||||
'*': ['id', 'name']
|
||||
},
|
||||
transformTags: {
|
||||
'*': function (tagName, attribs) {
|
||||
let href = attribs.href
|
||||
if (tagName === 'input' && attribs.type !== 'checkbox') {
|
||||
return false
|
||||
}
|
||||
if (_.isString(href) && href.match(/^#.+$/)) attribs.href = href.replace(/^#/, '#md-anchor-')
|
||||
if (attribs.id) attribs.id = 'md-anchor-' + attribs.id
|
||||
if (attribs.name) attribs.name = 'md-anchor-' + attribs.name
|
||||
if (attribs.for) attribs.for = 'md-anchor-' + attribs.for
|
||||
return {
|
||||
tagName: tagName,
|
||||
attribs: attribs
|
||||
|
||||
@@ -17,7 +17,9 @@ var md = markdownit({
|
||||
return str
|
||||
}
|
||||
})
|
||||
md.use(emoji)
|
||||
md.use(emoji, {
|
||||
shortcuts: {}
|
||||
})
|
||||
md.use(math, {
|
||||
inlineRenderer: function (str) {
|
||||
return `<span class='math'>${str}</span>`
|
||||
@@ -26,6 +28,7 @@ md.use(math, {
|
||||
return `<div class='math'>${str}</div>`
|
||||
}
|
||||
})
|
||||
md.use(require('markdown-it-checkbox'))
|
||||
|
||||
let originalRenderToken = md.renderer.renderToken
|
||||
md.renderer.renderToken = function renderToken (tokens, idx, options) {
|
||||
|
||||
@@ -78,7 +78,7 @@ marked()
|
||||
font-weight bold
|
||||
em, i
|
||||
font-style italic
|
||||
s
|
||||
s, del, strike
|
||||
text-decoration line-through
|
||||
u
|
||||
text-decoration underline
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
"highlight.js": "^8.9.1",
|
||||
"lodash": "^3.10.1",
|
||||
"markdown-it": "^4.4.0",
|
||||
"markdown-it-checkbox": "^1.1.0",
|
||||
"markdown-it-emoji": "^1.1.0",
|
||||
"markdown-it-math": "^3.0.2",
|
||||
"md5": "^2.0.0",
|
||||
|
||||
@@ -32,7 +32,8 @@ var config = {
|
||||
'markdown-it-emoji',
|
||||
'fs-jetpack',
|
||||
'markdown-it-math',
|
||||
'@rokt33r/sanitize-html'
|
||||
'@rokt33r/sanitize-html',
|
||||
'markdown-it-checkbox'
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user