Convert Markdown to HTML in javascript

Convert Markdown to HTML in javascript

Convert Markdown to HTML in javascript

Converting markdown to JS in browser

Markdown sent in the browser can be converted into html and appended into the DOM. The other method is to use a library like parsedown in PHP and convert the markdown to HTML on the server.

Understand the difference between client side rendering and server side rendering

Using Showdown JS

<div class="article" id="article-section"></div>
<script type="text/javascript" src=""></script>

Here we are trying to load the markdown in the page from the server using PHP.

const htmlContent = document.createElement("div");
var converter = new showdown.Converter(),
text      = '<?php //echo str_replace("\n",'\\n',addslashes($markdown)); ?>';

Icon For Arrow-up

Post a comment