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