Skip to content

Commit

Permalink
chore: Update web.bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 12, 2022
1 parent d74ddfd commit 6a7b8e7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
33 changes: 2 additions & 31 deletions Sources/Markdown/Resources/web.bundle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,7 @@
<script src="./marked.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="__markdown_preview__" class="markdown-body">
</div>
<script>
marked.setOptions({
highlight: function(code, lang) {
const language = Prism.languages[lang];
if (language) {
return Prism.highlight(code, language, lang);
}
return code;
},
});
const renderer = {
listitem: (text, task, checked) => {
const input = typeof checked == "boolean" ? `<input type="checkbox" disabled=""${checked ? ' checked=""' : ''} class="task-list-item-checkbox">`: '';
const cls = typeof checked == "boolean" && typeof task === "boolean" ? 'class="task-list-item"' : ""
return `<li ${cls}>${input} ${(text || '').replace(/^<.*?>\s/, '')}</li>`;
}
}
marked.use({ renderer });
window.__markdown_preview_dom__ = document.getElementById('__markdown_preview__');
function markdownPreview(content) {
__markdown_preview_dom__.innerHTML = marked.parse(content);
}

if (window.webkit) {
window.webkit.messageHandlers.mdPreviewDidReady.postMessage(null);
// __markdown_preview_dom__.innerHTML = JSON.stringify(typeof window.webkit.messageHandlers.mdPreviewDidReady)
}
</script>

<div id="__markdown_preview__" class="markdown-body"></div>
<script src="./main.js" type="text/javascript"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions Sources/Markdown/Resources/web.bundle/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
marked.setOptions({
highlight: (code, lang) => {
const language = Prism.languages[lang];
if (language) {
return Prism.highlight(code, language, lang);
}
return code;
},
});

const renderer = {
listitem: (text, task, checked) => {
const input = typeof checked == "boolean" ? `<input type="checkbox" disabled=""${checked ? ' checked=""' : ''} class="task-list-item-checkbox">`: '';
const cls = typeof checked == "boolean" && typeof task === "boolean" ? 'class="task-list-item"' : ""
return `<li ${cls}>${input} ${(text || '').replace(/^<.*?>\s/, '')}</li>`;
}
}

marked.use({ renderer });

window.__markdown_preview_dom__ = document.getElementById('__markdown_preview__');

function markdownPreview(content) {
__markdown_preview_dom__.innerHTML = marked.parse(content);
}

if (window.webkit) {
window.webkit.messageHandlers.mdPreviewDidReady.postMessage(null);
// __markdown_preview_dom__.innerHTML = JSON.stringify(typeof window.webkit.messageHandlers.mdPreviewDidReady)
}

0 comments on commit 6a7b8e7

Please sign in to comment.