-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmarkdown.html
More file actions
executable file
·37 lines (32 loc) · 1.15 KB
/
markdown.html
File metadata and controls
executable file
·37 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link id="favicon" rel="shortcut icon" type="image/png" href="data:image/png;base64,....==" />
<!-- // https://github.com/showdownjs/showdown -->
<script src="https://unpkg.com/showdown/dist/showdown.min.js"></script>
</head>
<body>
<script type="module">
if (!window.location.search) {window.location.search="source=README.md"}
const sourceUrl = (new URLSearchParams(window.location.search)).get("source")
function renderMarkdownFileToElement(sourceUrl, $el) {
document.title = sourceUrl
fetch(sourceUrl)
.then(response => response.text())
.then((markdown_data) => {
const converter = new showdown.Converter({
tables: true,
tasklists: true,
openLinksInNewWindow: true,
// https://github.com/showdownjs/showdown#valid-options
},)
$el.innerHTML = converter.makeHtml(markdown_data)
})
.catch(err => console.error(err))
}
const $markdownElement = document.getElementById('markdown') || document.getElementsByTagName('body').item(0)
renderMarkdownFileToElement(sourceUrl, $markdownElement)
</script>
</body>
</html>