DEV Community

Cover image for Creating markdown blog or docs generator with js (serverless).
ShGI
ShGI

Posted on • Updated on • Originally published at sgi-capp-at2.github.io

Creating markdown blog or docs generator with js (serverless).

Hey there everyone ,
If you've created blog on dev.to , you're might be familiar with blog generator with md.
I'll share how you can create that type of generator with only js.

libraries to use.

showdown.js

showdownjs-image

Showdownjs is a library which converts markdown code into HTML code.
From

# header
**Bold**
_italic_
Enter fullscreen mode Exit fullscreen mode

To

<h1>header</h1>
<strong>bold</strong>
<em>italic</em>
Enter fullscreen mode Exit fullscreen mode

How to use showdown.js

You should visit to official docs for advanced level tools of library.
I'll show you how you can convert the md into html with GitHub flavour of markdown.

var my_markdown_input = document.querySelector("#mdinput") , converter = new showdown.converter();
var converted_text = converter.makeHtml(my_markdown_input);
// converted_text will be variable having html code 
Enter fullscreen mode Exit fullscreen mode

Markdown css

The style created by sindresorhus which looks like github markdown body.

How to use markdown css ?

The markdown css by sindresorhus is very simple to use. You just have to add classname "markdown-body" and it will convert html into GitHub like markdown styled html.

<div class="markdown-body"></div>
Enter fullscreen mode Exit fullscreen mode

..Read More

to get notified about latest webdev news join us ondiscord

Top comments (1)

Collapse
 
shubham_ingale profile image
ShGI

Go to sgi-capp-at2.github.io/ new/
To see live blog generator