document.addEventListener("DOMContentLoaded", function(event) { 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 = `
${text} #
`; return element } markdownRenderer.link = function(href, title, text) { let a; if (href.startsWith('https:/') || href.startsWith('http:/')) { a = '' + text + ''; } else { const start = gitlist.basepath + '/' + gitlist.repo + '/blob/' + gitlist.branch + '/'; if (!location.pathname.startsWith(start)) { href = start + href; } a = '' + text + ''; } return a; } markdownRenderer.image = function(href, title, text) { title = title || ''; text = text || ''; let resultText = title; if (text !== '') { if (title !== '') { resultText += ' - '; } resultText += text; } const result = '' + htmlEncode(resultText) + ''; return result; }; const mdContent = $('#md-content'); if (mdContent.length) { const html = marked(mdContent.text(), { renderer: markdownRenderer }); mdContent.html(twemoji.parse(html, { folder: 'svg', ext: '.svg', })); global.gitlist.scrollHash(location) } });