Skip to content

arnabsen1729/md2pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Stargazers Issues Builds Tests


Logo

Markdown to PDF

Will take a markdown file as input and then create a PDF file with the markdown formatting.
Explore the docs »

View Demo · Report Bug · Request Feature

About The Project

demo

Many people love using markdown to take notes and write documentation. But when it comes to sharing it, they need to convert it to PDF. md2pdf is a simple tool which does exactly that.

Currently, it supports:

Features Support
Headings (L1 - L6) ✔️
Paragraph ✔️
Blockquotes ✔️
Bold ✔️
Italic ✔️
Code ✔️
Link ✔️
Images ✔️
CodeBlock
Lists (Ordered and Unordered)
Horizontal Rules
Tables

Take a look at the PDF generated from the sample markdown file.

PDF File Markdown File
pdfss mdss

Usage

$ md2pdf -h
Usage of md2pdf:
  -file string
     Name of the markdown file to read
  -output string
     Name of the PDF file to be exported  (default: <input-file-name>.pdf)

Example:

md2pdf -file=MyFile.md -output=MyFile.pdf

Working

We can look at the markdown file as a bunch of lines, and each lines are further a collection of tokens. Tokens refer to the smallest/atomic unit of markdown. Each token has it's own style, content and alternate content (altContent is optional).

For example, a token can be a heading, a paragraph, a bold text, an image, a code block, a list, etc. The token for heading will have the text in the content, the respective style like being bold, a larger font etc in the style.

Alternate content of the token is used in cases of images and links. For example, the alternate content of an image will be the image URL.

diag1

Parser first reads the markdown file splits it by lines and then further splits the lines by tokens.

diag2

This list of list of tokens are then passed to the Writer to generate the final PDF.

This project follows the standard markdown guidelines.


forthebadge forthebadge

About

Convert your markdown files to PDF instantly

Resources

License

Stars

Watchers

Forks