-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
44 lines (39 loc) · 1.24 KB
/
index.html
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
38
39
40
41
42
43
44
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Marked hook frontmatter</title>
</head>
<body>
<div id="content"></div>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked-sequential-hooks/dist/index.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moo/moo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/dist/js-yaml.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked-hook-frontmatter/dist/index.umd.min.js"></script>
<script>
const md = `---
title: Hello, world!
author: John Doe
---
# {title}
This is the main content of your Markdown file autored by **{author}**.
`
document.getElementById("content").innerHTML = new marked.Marked()
.use(
markedSequentialHooks({
markdownHooks: [markedHookFrontmatter()],
htmlHooks: [
(html, data) => {
console.log(data)
return html
.replace("{title}", data.title)
.replace("{author}", data.author)
}
]
})
)
.parse(md)
</script>
</body>
</html>