-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d74ddfd
commit 6a7b8e7
Showing
2 changed files
with
32 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |