Skip to content

Commit

Permalink
first working variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hanke committed May 14, 2024
1 parent 9f63484 commit e7a88c9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ckanext/markdown_view/templates/markdown_view.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<div id="markdown_content" class="blob-viewer js-syntax-highlight" data-loaded="true">
</div>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>
fetch("{{ resource_view.get('page_url') or resource.get('url') }}") // The path to the raw Markdown file
.then(response => response.blob()) // Unwrap to a blob...
.then(blob => blob.text()) // ...then to raw text...
.then(markdown => { // ...then pass the raw text into marked.parse
document.getElementById("markdown_content").innerHTML = DOMPurify.sanitize(marked.parse(markdown.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, "")));
});
</script>

<iframe title="Markdown Preview" src="{{ resource_view.get('page_url') or resource.get('url') }}" frameborder="0"
width="100%" style="height:100vh" data-module="data-viewer">
<p>{{ _('Your browser does not support iframes.') }}</p>
Expand Down

0 comments on commit e7a88c9

Please sign in to comment.