Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade marked to 0.5.x, fixed #645, close #644 #662

Merged
merged 1 commit into from
Oct 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 52 additions & 52 deletions package-lock.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
"postinstall": "opencollective postinstall"
},
"dependencies": {
"marked": "^0.3.12",
"marked": "^0.5.1",
"medium-zoom": "^0.4.0",
"opencollective": "^1.0.3",
"prismjs": "^1.9.0",
19 changes: 4 additions & 15 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ export function getAndRemoveConfig(str = '') {

if (str) {
str = str
.replace(/^'|'$/, '')
.replace(/:([\w-]+)=?([\w-]+)?/g, (m, key, value) => {
config[key] = (value && value.replace(/"/g, '')) || true
return ''
@@ -37,17 +38,17 @@ const compileMedia = {
},
iframe(url, title) {
return {
code: `<iframe src="${url}" ${title || 'width=100% height=400'}></iframe>`
html: `<iframe src="${url}" ${title || 'width=100% height=400'}></iframe>`
}
},
video(url, title) {
return {
code: `<video src="${url}" ${title || 'controls'}>Not Support</video>`
html: `<video src="${url}" ${title || 'controls'}>Not Support</video>`
}
},
audio(url, title) {
return {
code: `<audio src="${url}" ${title || 'controls'}>Not Support</audio>`
html: `<audio src="${url}" ${title || 'controls'}>Not Support</audio>`
}
},
code(url, title) {
@@ -296,18 +297,6 @@ export class Compiler {
return `<img src="${url}"data-origin="${href}" alt="${text}"${attrs}>`
}

const CHECKED_RE = /^\[([ x])\] +/
origin.listitem = renderer.listitem = function (text) {
const checked = CHECKED_RE.exec(text)
if (checked) {
text = text.replace(
CHECKED_RE,
`<input type="checkbox" ${checked[1] === 'x' ? 'checked' : ''} />`
)
}
return `<li${checked ? ` class="task-list-item"` : ''}>${text}</li>\n`
}

renderer.origin = origin

return renderer
31 changes: 17 additions & 14 deletions src/core/render/embed.js
Original file line number Diff line number Diff line change
@@ -28,7 +28,12 @@ function walkFetchEmbed({embedTokens, compile, fetch}, cb) {
'\n```\n'
)
} else if (token.embed.type === 'mermaid') {
embedToken = [{type: 'html', text: `<div class="mermaid">\n${text}\n</div>`}]
embedToken = [
{type: 'html', text: `<div class="mermaid">\n${text}\n</div>`}
]
embedToken.links = {}
} else {
embedToken = [{type: 'html', text: text}]
embedToken.links = {}
}
}
@@ -39,10 +44,14 @@ function walkFetchEmbed({embedTokens, compile, fetch}, cb) {
}
})(token)

if (process.env.SSR) {
fetch(token.embed.url).then(next)
if (token.embed.url) {
if (process.env.SSR) {
fetch(token.embed.url).then(next)
} else {
get(token.embed.url).then(next)
}
} else {
get(token.embed.url).then(next)
next(token.embed.html)
}
}
}
@@ -67,16 +76,10 @@ export function prerenderEmbed({compiler, raw = '', fetch}, done) {
const embed = compiler.compileEmbed(href, title)

if (embed) {
if (embed.type === 'markdown' ||
embed.type === 'code' ||
embed.type === 'mermaid'
) {
embedTokens.push({
index,
embed
})
}
return embed.code
embedTokens.push({
index,
embed
})
}

return src
5 changes: 1 addition & 4 deletions src/themes/basic/_layout.styl
Original file line number Diff line number Diff line change
@@ -74,11 +74,8 @@ kbd
padding 3px 5px
vertical-align middle

.task-list-item
list-style-type none

li input[type='checkbox']
margin 0 0.2em 0.25em -1.6em
margin 0 0.2em 0.25em 0
vertical-align middle

/* navbar */