(elements)
| 308 | } |
| 309 | |
| 310 | async function processHighlight(elements) { |
| 311 | if (parseInt(config.markdown.highlight, 10)) { |
| 312 | const hljs = window.hljs; |
| 313 | if (!hljs) { |
| 314 | console.debug(`[plugins/markdown] Tryin to highlight without initializing hljs`); |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | console.debug(`[plugins/markdown] Loading support for line numbers`); |
| 319 | |
| 320 | require('highlightjs-line-numbers.js'); |
| 321 | |
| 322 | elements.each(function (i, block) { |
| 323 | const parentNode = $(block.parentNode); |
| 324 | if (parentNode.hasClass('markdown-highlight')) { |
| 325 | return; |
| 326 | } |
| 327 | parentNode.addClass('markdown-highlight'); |
| 328 | |
| 329 | // Default language if set in ACP |
| 330 | if (!Array.prototype.some.call(block.classList, (className) => className.startsWith('language-')) && config.markdown.defaultHighlightLanguage) { |
| 331 | block.classList.add(`language-${config.markdown.defaultHighlightLanguage}`); |
| 332 | } |
| 333 | |
| 334 | window.hljs.highlightElement(block); |
| 335 | |
| 336 | // Check detected language against whitelist and add lines if enabled |
| 337 | const classIterator = block.classList.values(); |
| 338 | for (const className of classIterator) { |
| 339 | if (className.startsWith('language-')) { |
| 340 | const language = className.split('-')[1]; |
| 341 | const list = config.markdown.highlightLinesLanguageList; |
| 342 | if (aliasMap.has(language) && list && list.includes(aliasMap.get(language))) { |
| 343 | $(block).attr('data-lines', 1); |
| 344 | window.hljs.lineNumbersBlock(block); |
| 345 | } |
| 346 | break; |
| 347 | } |
| 348 | } |
| 349 | }); |
| 350 | } |
| 351 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…