showdownjs.html 909 B

123456789101112131415161718192021222324252627
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Showdown.js Example</title>
  6. <script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.1/showdown.min.js"></script>
  7. </head>
  8. <body>
  9. <div id="markdown-content"></div>
  10. <script>
  11. // Fetch your Markdown file (replace with your actual file URL)
  12. fetch('./markdown-file.md')
  13. .then(response => response.text())
  14. .then(markdownText => {
  15. // Create a Showdown converter
  16. const converter = new showdown.Converter();
  17. // Convert Markdown to HTML
  18. const htmlContent = converter.makeHtml(markdownText);
  19. // Display the HTML content
  20. document.getElementById('markdown-content').innerHTML = htmlContent;
  21. })
  22. .catch(error => {
  23. console.error('Error fetching Markdown:', error);
  24. });
  25. </script>
  26. </body>
  27. </html>