Sign inSign up

blackrose01/markdown-pdf

By blackrose01

•Updated about 2 years ago

Create PDFs from Markdown without pandoc

Image
Integration & delivery
Developer tools
0

251

blackrose01/markdown-pdf repository overview

⁠Docker for Markdown PDF

This repository provides a Dockerfile to convert Markdown files into PDF.

⁠Table of Contents

⁠Features

Supports the following features

⁠markdown-it-container

INPUT

::: warning
*here be dragons*
:::

OUTPUT

<div class="warning">
  <p><em>here be dragons</em></p>
</div>
⁠markdown-it-plantuml

INPUT

@startuml
Bob -[#red]> Alice : hello
Alice -[#0000FF]->Bob : ok
@enduml

OUTPUT

PlantUML

⁠markdown-it-include

Include markdown fragment files: :[alternate-text](relative-path-to-file.md).

├── [plugins]
│  └── README.md
├── CHANGELOG.md
└── README.md

INPUT

README Content

:[Plugins](./plugins/README.md)

:[Changelog](CHANGELOG.md)

OUTPUT

Content of README.md

Content of plugins/README.md

Content of CHANGELOG.md

⁠Usage

Download the image from Docker Hub. Then set the environment variables and link your markdown files into the container. The ouput files should appear in the folder.

⁠Example
Example for Project Folder

├── [folder_1]
│  └── README.md
│  └── README_APPENDIX.md
├── CHANGELOG.md
└── README.md
  1. Only convert 1 file docker run --rm -v ./CHANGELOG.md:/data/CHANGELOG.md -e INPUT_FILE=/data/CHANGELOG.md blackrose01/markdown-pdf
  2. Convert connected files docker run --rm -v ./folder_1:/data -e INPUT_FILE=/data/README.md blackrose01/markdown-pdf

⁠Available Environment Variables

⁠Description
⁠DEBUG

Default Value: false

Enables the debugging mode of the program.

⁠CHROMIUM_PATH

Default Value: /usr/bin/chromium-browser

Path to the executable of Chromium. Normally this does not need to be adjusted.

⁠CHROMIUM_ARGS

Default Value: --lang=en,--no-sandbox,--disable-setuid-sandbox

Arguments which will be passed to Chromium via Pupeteer.

⁠INPUT_FILE

Name of the Input file which needs to be converted. This is a required.

⁠OUTPUT_FILE_NAME

Name of the Output file. Default is the name of the Input File.

⁠OUTPUT_FILE_NAME_USE_FOLDERNAME

Default Value: true

File name is the name of the parent folder in which the file is located. This option overwrites OUTPUT_FILE_NAME.

⁠OUTPUT_FILE_NAME_CASE_STYLE

Default Value: capital Options: camel, capital, constant, dot, kebab, no, pascal, pascalsnake, path, sentence, snake, train

Name of the Output file. Default is the name of the Input File.

⁠OUTPUT_TYPE

Default Value: pdf Options: pdf, html, png, jpeg, all

Determines the output format for the converter. If the all option is selected, all output formats are used.

⁠OUTPUT_PATH

Specifies where the generated files are to be stored. The default is where the files to be converted are located.

⁠ENABLE_SYNTAX_HIGHLIGHT

Default Value: true

Enables syntax highlighting.

⁠HIGHLIGHT_STYLE

Default Value:

Options:
- 1c-light.css \
- a11y-dark.css \
- a11y-light.css \
- agate.css \
- androidstudio.css \
- an-old-hope.css \
- arduino-light.css \
- arta.css \
- ascetic.css \
- atom-one-dark.css \
- atom-one-dark-reasonable.css \
- atom-one-light.css \
- brown-paper.css \
- brown-papersq.png \
- codepen-embed.css \
- color-brewer.css \
- dark.css \
- default.css \
- devibeans.css \
- docco.css \
- far.css \
- felipec.css \
- foundation.css \
- github.css \
- github-dark.css \
- github-dark-dimmed.css \
- gml.css \
- googlecode.css \
- gradient-dark.css \
- gradient-light.css \
- grayscale.css \
- hybrid.css \
- idea.css \
- intellij-light.css \
- ir-black.css \
- isbl-editor-dark.css \
- isbl-editor-light.css \
- kimbie-dark.css \
- kimbie-light.css \
- lightfair.css \
- lioshi.css \
- magula.css \
- mono-blue.css \
- monokai.css \
- monokai-sublime.css \
- night-owl.css \
- nnfx-dark.css \
- nnfx-light.css \
- nord.css \
- obsidian.css \
- panda-syntax-dark.css \
- panda-syntax-light.css \
- paraiso-dark.css \
- paraiso-light.css \
- pojoaque.css \
- pojoaque.jpg \
- purebasic.css \
- qtcreator-dark.css \
- qtcreator-light.css \
- rainbow.css \
- routeros.css \
- school-book.css \
- shades-of-purple.css \
- srcery.css \
- stackoverflow-dark.css \
- stackoverflow-light.css \
- sunburst.css \
- tokyo-night-dark.css \
- tokyo-night-light.css \
- tomorrow-night-blue.css \
- tomorrow-night-bright.css \
- vs.css \
- vs2015.css \
- xcode.css \
- xt256.css

Which syntax highlighter should be used.

⁠ENABLE_LINE_BREAKS

Default Value: true

Enable line breaks in documents.

<div class="page" />
⁠ENABLE_EMOJIS

Default Value: true

Enable Emojis in Markdown.

⁠SCALE

Default Value: 1

Scaling for the document

⁠PDF_RANGED

Default Value:

Only save specific pages in PDF document. Example: 1, 2-5, 9

Defaul Value: true

Print a header and a footer on each page in PDF.

⁠HEADER_TEMPLATE

Default Value: <div style='font-size: 9px; margin-left: 1cm;'> <span class='title'></span></div> <div style='font-size: 9px; margin-left: auto; margin-right: 1cm;' >%%ISO-DATE%%</div>

Template for the Header.

Default Value: <div style='font-size: 9px; margin: 0 auto;'> <span class='pageNumber'></span> / <span class='totalPages'></span></div>

Template for the Footer.

⁠PRINT_BACKGROUND

Default Value: true

Print the background.

⁠OMIT_BACKGROUND

Default Value: true

Omit the background.

⁠ORIENTATION

Default Value: portrait Available Options: portrait, landscape

Orientation of the pages.

⁠PAPER_FORMAT

Default Value: A4 Available Options: A0, A1, A2, A3, A4, A5, A6, Ledger, Tabloid, Legal, Letter

Format of the pages.

⁠PAPER_WIDTH

Width of a page. Overwrites environment variable PAPER_FORMAT.

⁠PAPER_HEIGHT

Height of a page. Overwrites environment variable PAPER_FORMAT.

⁠PAPER_MARGIN_TOP

Default Value: 1.5cm

Border margin top. Usable with unit.

⁠PAPER_MARGIN_RIGHT

Default Value: 1cm

Border margin right. Usable with unit.

⁠PAPER_MARGIN_BOTTOM

Default Value: 1cm

Border margin bottom. Usable with unit.

⁠PAPER_MARGIN_LEFT

Default Value: 1cm

Border margin left. Usable with unit.

⁠PLANTUML_OPEN_MARKER

Default Value: @startuml

Open marker for PlantUML containers.

⁠PLANTUML_CLOSE_MARKER

Default Value: @enduml

Close marker for PlantUML containers.

⁠PLANTUML_URL

URL for PlantUML parser files.

⁠MERMAID_URL

JS file for Mermaid parser file.

⁠ENABLE_MARKDOWN_IT_INCLUDE

Default Value: true

Enable inclusions of Markdown files.

⁠MARKDOWN_IT_REGEX_INCLUDE

Default Value: :\\[.+\\]\\((.+\\..+)\\)

Define the pattern of the include links in a markdown file.

⁠JPEG_QUALITY

Default Value: 100

Quality of the JPEG file. Only for OUTPUT_TYPE jpeg.

⁠IMAGE_CLIP_X

X-Coordinate for clipper.

⁠IMAGE_CLIP_Y

Y-Coordinate for clipper.

⁠IMAGE_CLIP_HEIGHT

Height of the Image from clipper.

⁠IMAGE_CLIP_WIDTH

Width of the Image from clipper.

⁠INCLUDE_DEFAULT_STYLES

Default Value: true

Include default CSS styles.

⁠ADDITIONAL_STYLES

List of local additional css files. Use absolute path in container.

⁠FAQ

⁠How can I change emoji size ?
  1. Add the following to your stylesheet which was specified in the markdown-pdf.styles
.emoji {
  height: 2em;
}
⁠Output directory

If you always want to output to the relative path directory from the Markdown file.

For example, to output to the "output" directory in the same directory as the Markdown file, set it as follows.

"markdown-pdf.outputDirectory" : "output",
"markdown-pdf.outputDirectoryRelativePathFile": true,
⁠Page Break

Please use the following to insert a page break.

<div class="page" />

⁠License

This project uses the MIT license.

⁠Special thanks

This repository based on yzanes VSCode extension Markdown PDF⁠.

Tag summary

Content type

Image

Digest

sha256:9b8c10072…

Size

333.3 MB

Last updated

about 2 years ago

docker pull blackrose01/markdown-pdf