Skip to content

Commit

Permalink
feat(compiler): support embedded file as code block, close #134
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Feb 10, 2018
1 parent b5eb798 commit 21dd481
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ const compileMedia = {
},
audio (url, config) {
return `<audio src="${url}" ${config || 'controls'}>Not Support</audio>`
},
code (url, config) {
const request = get(url, false)
const id = `docsify-get-${request.uid}`
let ext = url.match(/\.(\w+)$/)

ext = config.ext || (ext && ext[0])

request.then(text => {
document.getElementById(id).innerHTML = this.compile(
'```' + ext + '\n ' + text + '\n```\n'
)
})

return `<div data-origin="${url}" id=${id}></div>`
}
}

Expand Down

0 comments on commit 21dd481

Please sign in to comment.