mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-30 11:08:58 +08:00
feat(compiler): support embedded file as code block, close #134
This commit is contained in:
parent
524f52f882
commit
761ccc2c2b
@ -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…
Reference in New Issue
Block a user