feat(compiler): support embedded file as code block, close #134
This commit is contained in:
parent
524f52f882
commit
761ccc2c2b
1 changed files with 15 additions and 0 deletions
|
|
@ -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>`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue