Skip to content

Instantly share code, notes, and snippets.

@robkooper
Created October 19, 2022 18:11
Show Gist options
  • Save robkooper/27235ca1c26b766cb56a4f55c376b5c8 to your computer and use it in GitHub Desktop.
Save robkooper/27235ca1c26b766cb56a4f55c376b5c8 to your computer and use it in GitHub Desktop.
markdown renderer for clowder, place the files in a folder .../custom/public/javascripts/previewers/markdown
(function($, Configuration) {
// Preserve these in our current scope
var initialTab = Configuration.tab;
var initialID = Configuration.id;
var initialPreviewer = Configuration.previewer;
// add div for markdown
$(initialTab).append("<div id=\"markdown\"></div>");
// load the script
$.getScript("https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js")
.then(function () {
// load the text
$.get(Configuration.url, function(text) {
var converter = new showdown.Converter(),
html = converter.makeHtml(text);
$("#markdown").append(html);
});
})
}(jQuery, Configuration));
{
"name": "MarkdownViewer",
"main": "markdown.js",
"file": true,
"contentType": [
"text/markdown"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment