DEV Community

Cover image for My little Markdown Parser
Frank Wisniewski
Frank Wisniewski

Posted on

My little Markdown Parser

After trying out several Markdown parsers and realizing that the results were quite different at times, I decided to write my own parser from scratch.

The project can be viewed on GitHub and is pretty easy to integrate.

Frank Wisniewski on Github

<!DOCTYPE html>
<html lang="de">
  <meta charset="UTF-8">
  <link rel="stylesheet" href="">
  <script src=""></script>
  <script type="module">
    import mermaid from '';
    mermaid.initialize({ startOnLoad: true });
    MathJax = {
      tex: {
        inlineMath: [['-$', '$-'], ['\\(', '\\)']]
      svg: {
        fontCache: 'global'
  <script id="MathJax-script" async
<div class=container id="markdownContainer"></div>
"use strict";
async function loadMD(fileName){
  try {
    const req = await fetch( fileName , {
      method: 'get',
      headers: {
        'content-type': 'text/csv;charset=UTF-8'
    if (req.status === 200){
      let markDown = await req.text()
      return markDown
  } catch (err) {console.log(err)}
function process(md){
  let mdToHtm = fhwMD( md, {autoid:true, mathjax:true} )
loadMD("").then( (markdown) => process(markdown))
Enter fullscreen mode Exit fullscreen mode

The function call is as follows: fhwMD( md, {autoid:true, mathjax:true} )

The minified JavaScript code is just under 14 kilobytes in size.

Top comments (0)