Skip to content

Commit 7872bfe

Browse files
committed
Merge branch 'markdown' into v0.5.2
* markdown: markdown strike bug fixed, no emoji shortcut, checkbox syntax added
2 parents af008e6 + 9d0d851 commit 7872bfe

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

browser/components/MarkdownPreview.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const katex = window.katex
1414
const sanitizeOpts = {
1515
allowedTags: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
1616
'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div',
17-
'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'img', 'span', 'cite', 'del', 'u', 'sub', 'sup' ],
17+
'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'img', 'span', 'cite', 'del', 'u', 'sub', 'sup', 's', 'input', 'label' ],
1818
allowedClasses: {
1919
'a': ['lineAnchor'],
2020
'div': ['math'],
@@ -24,14 +24,20 @@ const sanitizeOpts = {
2424
allowedAttributes: {
2525
a: ['href', 'data-key'],
2626
img: [ 'src' ],
27+
label: ['for'],
28+
input: ['checked', 'type'],
2729
'*': ['id', 'name']
2830
},
2931
transformTags: {
3032
'*': function (tagName, attribs) {
3133
let href = attribs.href
34+
if (tagName === 'input' && attribs.type !== 'checkbox') {
35+
return false
36+
}
3237
if (_.isString(href) && href.match(/^#.+$/)) attribs.href = href.replace(/^#/, '#md-anchor-')
3338
if (attribs.id) attribs.id = 'md-anchor-' + attribs.id
3439
if (attribs.name) attribs.name = 'md-anchor-' + attribs.name
40+
if (attribs.for) attribs.for = 'md-anchor-' + attribs.for
3541
return {
3642
tagName: tagName,
3743
attribs: attribs

browser/lib/markdown.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ var md = markdownit({
1717
return str
1818
}
1919
})
20-
md.use(emoji)
20+
md.use(emoji, {
21+
shortcuts: {}
22+
})
2123
md.use(math, {
2224
inlineRenderer: function (str) {
2325
return `<span class='math'>${str}</span>`
@@ -26,6 +28,7 @@ md.use(math, {
2628
return `<div class='math'>${str}</div>`
2729
}
2830
})
31+
md.use(require('markdown-it-checkbox'))
2932

3033
let originalRenderToken = md.renderer.renderToken
3134
md.renderer.renderToken = function renderToken (tokens, idx, options) {

browser/styles/mixins/marked.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ marked()
7878
font-weight bold
7979
em, i
8080
font-style italic
81-
s
81+
s, del, strike
8282
text-decoration line-through
8383
u
8484
text-decoration underline

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"highlight.js": "^8.9.1",
4040
"lodash": "^3.10.1",
4141
"markdown-it": "^4.4.0",
42+
"markdown-it-checkbox": "^1.1.0",
4243
"markdown-it-emoji": "^1.1.0",
4344
"markdown-it-math": "^3.0.2",
4445
"md5": "^2.0.0",

webpack-skeleton.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ var config = {
3232
'markdown-it-emoji',
3333
'fs-jetpack',
3434
'markdown-it-math',
35-
'@rokt33r/sanitize-html'
35+
'@rokt33r/sanitize-html',
36+
'markdown-it-checkbox'
3637
]
3738
}
3839

0 commit comments

Comments
 (0)