translations: [ de/Deutsch ] · [ es/Español ] · [ fr/Français ]
Table of contents
Markdown is a lightweight markup language used for formatting plain text. Rendering Markdown to HTML allows you to convert the Markdown syntax into a presentable web format. cmark is a powerful tool for this task, providing various options to customize the output.
Installation
For Ubuntu:
sudo apt-get install libcmark-dev
For Fedora:
sudo dnf install cmark-devel
For openSUSE:
sudo zypper install libcmark
Using cmark to Render Markdown to HTML
cmark offers several arguments to customize the rendering process. Here are some popular options:
-t
: Specifies the output format (e.g., -t html for HTML output).--unsafe
: Allows unsafe HTML in the output.--smart
: Enables smart punctuation and typographic enhancements.--hardbreaks
: Renders soft line breaks as hard breaks.--normalize
: Normalizes the document before rendering.
To render a Markdown file to HTML via the terminal, use the following command:
cmark [options] input.md > output.html
Replace [options]
with the desired arguments and input.md with the name of your Markdown file. The HTML output will be saved in output.html.
Example:
To render a Markdown file named example.md to HTML with smart punctuation enabled, use:
cmark -t html --smart example.md > example.html
Experiment with different options to tailor the output according to your preferences.
Created on: Jan 3, 2024