23 lines
No EOL
950 B
JavaScript
23 lines
No EOL
950 B
JavaScript
// Function to convert Markdown to HTML
|
|
function convertMarkdownToHTML(markdownContent) {
|
|
// Simple Markdown to HTML conversion
|
|
// This is a basic example and may not cover all Markdown features
|
|
// You may need to enhance this function based on your requirements
|
|
return markdownContent
|
|
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>') // Bold
|
|
.replace(/\*(.*?)\*/g, '<em>$1</em>'); // Italics
|
|
}
|
|
|
|
// Function to fetch and display an article
|
|
function displayArticle(articlePath) {
|
|
fetch(articlePath)
|
|
.then(response => response.text())
|
|
.then(markdownContent => {
|
|
const htmlContent = convertMarkdownToHTML(markdownContent);
|
|
document.getElementById('article-container').innerHTML = htmlContent;
|
|
})
|
|
.catch(error => console.error('Error fetching article:', error));
|
|
}
|
|
|
|
// Call the function with the path to your Markdown file
|
|
displayArticle('/md/rants/test.md'); |