-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown.js
More file actions
23 lines (18 loc) · 764 Bytes
/
markdown.js
File metadata and controls
23 lines (18 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Load the markdown parser library
async function loadMarkdown() {
// Fetch the Markdown content from the hello.md file
const response = await fetch('hello.md');
const markdown = await response.text();
// Use marked.js (imported via CDN) to parse the markdown content into HTML
const htmlContent = marked.parse(markdown);
// Render the HTML inside the #markdown-content div
document.getElementById('markdown-content').innerHTML = htmlContent;
}
// Log success message
console.log('Hello, Markdown!');
// Run the function after DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
loadMarkdown().catch((error) =>
console.error('Error loading Markdown content:', error)
);
});