Convert Markdown to HTML on the Fly with mdparse.js

Category: Javascript | March 17, 2024
Author:satsuki-thyme
Views Total:27 views
Official Page:Go to website
Last Update:March 17, 2024
License:MIT

Preview:

Convert Markdown to HTML on the Fly with mdparse.js

Description:

A lightweight markdown parser JavaScript library that takes markdown from files like .md and renders the markdown syntax into clean, semantic HTML on your web pages and apps.

How to use it:

1. Insert the minified version of the mdparse.js library into your HTML.

<script src="mdparse.js"></script>

2. Fetch markdown syntax from a .md file and render it into HTML.

let elm_container = document.querySelector(`#container`)
fetch(`example.md`)
.then(async r => {
  if (r.ok) {
    mdparse(await r.text(), {
      // enable single line breaks
      "permissive": true, 
      // simplify headings
      "section": true
    })
    .then(r => {
      elm_container.innerHTML = r
    })
  }
})

Changelog:

03/17/2024

  • Bugfixes

You Might Be Interested In:


Leave a Reply