HTML code script for Markdown to HTML

Created on 3 July, 2024 • 115 views

HTML code script for Markdown to HTML

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <title>Blog Post</title>

  <script src="https://github.com/showdownjs"></script>

</head>

<body>

  <h1>My Blog Post</h1>

  <div id="markdown-content"></div>

  <script>

    // Replace this with your actual Markdown content

    const markdownText = "# This is a heading\n* This is a list item\n[Link Text](https://www.example.com)";

     

    const converter = new showdown.Converter();

    const html = converter.makeHtml(markdownText);

    document.getElementById("markdown-content").innerHTML = html;

  </script>

</body>

</html>