-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderMarkdown.js
More file actions
23 lines (19 loc) · 859 Bytes
/
renderMarkdown.js
File metadata and controls
23 lines (19 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// renderMarkdown.js
// Function to fetch Markdown content and render it
function renderMarkdown(markdownFilePath) {
// Fetch Markdown content
fetch(markdownFilePath)
.then(response => response.text())
.then(markdownContent => {
// Convert Markdown to HTML
var converter = new showdown.Converter();
var htmlContent = converter.makeHtml(markdownContent);
// Display HTML content
document.getElementById('markdownContent').innerHTML = htmlContent;
})
.catch(error => console.error('Error fetching Markdown:', error));
}
// Get the path to the Markdown file from the script tag's data attribute
var markdownPath = document.currentScript.getAttribute('markdown-path');
// Call renderMarkdown function with the Markdown file path
renderMarkdown(markdownPath);