md2pdf

command module
v0.0.0-...-118bd4e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

Contributors Stargazers Issues Builds Tests LinkedIn


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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package parser will parse the markdown files into tokens.
Package parser will parse the markdown files into tokens.
Package writer creates a pdf file and takes care of the formatting of the tokens.
Package writer creates a pdf file and takes care of the formatting of the tokens.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL