Configure Marp to syntax highlight Chapel
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
This commit is contained in:
parent
59fea61d2d
commit
985763d19c
26
engine.js
Normal file
26
engine.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// https://github.com/orgs/marp-team/discussions/422#discussioncomment-5268779
|
||||||
|
|
||||||
|
const { Marp } = require('@marp-team/marp-core')
|
||||||
|
const hljs = require('highlight.js')
|
||||||
|
|
||||||
|
// highlightjs-chapel for static web page is required a globally exposed `hljs` to
|
||||||
|
// extend highlight.js.
|
||||||
|
globalThis.hljs = hljs
|
||||||
|
|
||||||
|
require('highlightjs-chapel/dist/chapel.min.js')
|
||||||
|
|
||||||
|
// Create extended Marp class from an original Marp Core.
|
||||||
|
class MarpWithHighlightJSChapel extends Marp {
|
||||||
|
// Overload highlighter to use highlight.js with extended by highlightjs-chapel.
|
||||||
|
highlighter(code, lang, _attrs) {
|
||||||
|
if (lang && hljs.getLanguage(lang)) {
|
||||||
|
return hljs.highlight(code, {
|
||||||
|
language: lang,
|
||||||
|
ignoreIllegals: true,
|
||||||
|
}).value
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = MarpWithHighlightJSChapel
|
1897
package-lock.json
generated
Normal file
1897
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
package.json
Normal file
6
package.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"devDependencies": {
|
||||||
|
"@marp-team/marp-cli": "^4.2.3",
|
||||||
|
"highlightjs-chapel": "^0.1.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user