const hljs = require('highlight.js/lib/highlight.js'); hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml.js')); hljs.registerLanguage('css', require('highlight.js/lib/languages/css.js')); hljs.registerLanguage('cmake', require('highlight.js/lib/languages/cmake.js')); hljs.registerLanguage('dockerfile', require('highlight.js/lib/languages/dockerfile.js')); hljs.registerLanguage('Dockerfile', require('highlight.js/lib/languages/dockerfile.js')); hljs.registerLanguage('less', require('highlight.js/lib/languages/less.js')); hljs.registerLanguage('scss', require('highlight.js/lib/languages/scss.js')); hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml.js')); hljs.registerLanguage('powershell', require('highlight.js/lib/languages/powershell.js')); hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript.js')); hljs.registerLanguage('js', require('highlight.js/lib/languages/javascript.js')); hljs.registerLanguage('json', require('highlight.js/lib/languages/json.js')); hljs.registerLanguage('bash', require('highlight.js/lib/languages/shell.js')); hljs.registerLanguage('php', require('highlight.js/lib/languages/php.js')); hljs.registerLanguage('shell', require('highlight.js/lib/languages/shell.js')); hljs.registerLanguage('typescript', require('highlight.js/lib/languages/typescript.js')); hljs.registerLanguage('ts', require('highlight.js/lib/languages/typescript.js')); $(function() { const markdownRenderer = new marked.Renderer(); const kebabCase = require('lodash/kebabCase') markdownRenderer.heading = function (text, level, raw) { const ref = kebabCase(text).replace(/[^\x00-\xFF]/g, ""); const id = ref + '-parent'; const hover = ` onmouseenter="document.getElementById('${ref}').style.display = 'inline'" onmouseleave="document.getElementById('${ref}').style.display = 'none'" `; const element = `
${highlighted}
`;
};
markdownRenderer.codespan = (code) => {
const lang = 'html';
const highlighted = hljs.highlight(lang, code).value ;
return `${highlighted}
`;
}
const mdContent = $('#md-content');
if (mdContent.length) {
global.gitlist.setTheme();
const html = marked(mdContent.text(), {
renderer: markdownRenderer
});
mdContent.html(twemoji.parse(html, {
folder: 'svg',
ext: '.svg',
}));
}
});