convert markdown to html in linux

How to Convert Markdown to HTML in Linux

Markdown is a simple markup language used to define different models such as data models, object-relationships, etc. It is easy to understand unlike source code, and can be used across platforms. But sometimes you may need to convert markdown to HTML. In this article, we will learn how to convert markdown to HTML in Linux. There are several tools available for this purpose. We will use pandoc utility for doing it via command line, and VSCodium to do it via GUI.


How to Convert Markdown to HTML in Linux

In this article, we will look at how to convert markdown to HTML via command line

Convert Markdown to HTML via command line

The advantage of converting markdown to HTML via command line is that you can embed the commands into your application or create cronjobs out out them for automation.

Open terminal and run the following command to install pandoc.

$ sudo apt-get install pandoc

Let us say you have the following markdown files in your directory.

$ ls
file1.md file2.md file3.md file4.md

Here is the command to convert these markdown files to HTML. pandoc command converts only one file at a time so we will run a for loop and call pandoc in each iteration.

$ for i in *.md ; do echo "$i" && pandoc -s $i -o $i.html ; done

Now if you check the folder you will find corresponding HTML files are also generated.

$ ls
file1.md file2.md file3.md file4.md file1.html file2.html file3.html file4.html

Please note, pandoc can also be used to convert markdown into other file formats such as .epubs. It is one of the best open source file creators.

That’s it. In this short article, we have learnt how to convert markdown to HTML in Linux.

Also read:

How to Create SFTP User for Specific Folder
How to Open File Dialog Box in Python
How to Share Folder Between Linux Systems
How to Disable SELinux in CentOS & RHEL
How to Setup SSH Tunneling in Linux

Leave a Reply

Your email address will not be published.