MCPcopy Create free account
hub / github.com/TruthHun/BookStack / highlightedCodeBlock

Function highlightedCodeBlock

static/word2md/turndown-plugin-gfm.js:6–28  ·  view source on GitHub ↗
(turndownService)

Source from the content-addressed store, hash-verified

4var highlightRegExp = /highlight-(?:text|source)-([a-z0-9]+)/;
5
6function highlightedCodeBlock (turndownService) {
7 turndownService.addRule('highlightedCodeBlock', {
8 filter: function (node) {
9 var firstChild = node.firstChild;
10 return (
11 node.nodeName === 'DIV' &&
12 highlightRegExp.test(node.className) &&
13 firstChild &&
14 firstChild.nodeName === 'PRE'
15 )
16 },
17 replacement: function (content, node, options) {
18 var className = node.className || '';
19 var language = (className.match(highlightRegExp) || [null, ''])[1];
20
21 return (
22 '\n\n' + options.fence + language + '\n' +
23 node.firstChild.textContent +
24 '\n' + options.fence + '\n\n'
25 )
26 }
27 });
28}
29
30function strikethrough (turndownService) {
31 turndownService.addRule('strikethrough', {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected