This repository modifies vscode-markdown-pdf to add command line and docker support.
This extension converts Markdown files to pdf, html, png or jpeg files.
Supports the following features
Sample files
INPUT
::: warning
*here be dragons*
:::
OUTPUT
<div class="warning">
<p><em>here be dragons</em></p>
</div>
INPUT
@startuml
Bob -[#red]> Alice : hello
Alice -[#0000FF]->Bob : ok
@enduml
OUTPUT
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
INPUT
```mermaid stateDiagram [*] --> First state First { [*] --> second second --> [*] } ```
OUTPUT
Chromium download starts automatically when Markdown PDF is installed and Markdown file is first opened with Visual Studio Code.
However, it is time-consuming depending on the environment because of its large size (~ 170Mb Mac, ~ 282Mb Linux, ~ 280Mb Win).
During downloading, the message Installing Chromium
is displayed in the status bar.
If you are behind a proxy, set the http.proxy
option to settings.json and restart Visual Studio Code.
If the download is not successful or you want to avoid downloading every time you upgrade Markdown PDF, please specify the installed Chrome or 'Chromium' with markdown-pdf.executablePath option.
# install
> npm i -g markdown-to-file
# help
> m2f
Usage: m2f <md> [type] [options...]
md -- path to markdown file to convert
type -- Output file format: pdf|html|jpeg|png|all
options -- See: https://github.com/wll8/markdown-to-file
Eg:
m2f README.md
m2f README.md html
m2f README.md pdf outputDirectory=./mydoc/ markdown-it-include.enable=false
# docker
docker run -it --rm -v "$(pwd)":/data bladerunner2020/markdown-to-file:1.0 sh -c "m2f /data/somefile.md pdf"
markdown-pdf.*
F1
or Ctrl+Shift+P
export
and select below
markdown-pdf: Export (settings.json)
markdown-pdf: Export (pdf)
markdown-pdf: Export (html)
markdown-pdf: Export (png)
markdown-pdf: Export (jpeg)
markdown-pdf: Export (all: pdf, html, png, jpeg)
markdown-pdf: Export (settings.json)
markdown-pdf: Export (pdf)
markdown-pdf: Export (html)
markdown-pdf: Export (png)
markdown-pdf: Export (jpeg)
markdown-pdf: Export (all: pdf, html, png, jpeg)
"markdown-pdf.convertOnSave": true
option to settings.jsonVisual Studio Code User and Workspace Settings
markdown-pdf.*
settingsmarkdown-pdf.type
"markdown-pdf.type": [
"pdf",
"html",
"png",
"jpeg"
],
markdown-pdf.convertOnSave
markdown-pdf.convertOnSaveExclude
"markdown-pdf.convertOnSaveExclude": [
"^work",
"work.md$",
"work|test",
"[0-9][0-9][0-9][0-9]-work",
"work\\test" // All '\' need to be written as '\\' (Windows)
],
markdown-pdf.outputDirectory
\
need to be written as \\
(Windows)"markdown-pdf.outputDirectory": "C:\\work\\output",
Markdown file
, it will be interpreted as a relative path from the filefolder
, it will be interpreted as a relative path from the root folderworkspace
, it will be interpreted as a relative path from the each root folder
"markdown-pdf.outputDirectory": "output",
~
, it will be interpreted as a relative path from the home directory"markdown-pdf.outputDirectory": "~/output",
relative path
, it will be created if the directory does not existabsolute path
, an error occurs if the directory does not existmarkdown-pdf.outputDirectoryRelativePathFile
markdown-pdf.outputDirectoryRelativePathFile
option is set to true
, the relative path set with markdown-pdf.outputDirectory is interpreted as relative from the filemarkdown-pdf.styles
\
need to be written as \\
(Windows)"markdown-pdf.styles": [
"C:\\Users\\<USERNAME>\\Documents\\markdown-pdf.css",
"/home/<USERNAME>/settings/markdown-pdf.css",
],
Markdown file
, it will be interpreted as a relative path from the filefolder
, it will be interpreted as a relative path from the root folderworkspace
, it will be interpreted as a relative path from the each root folder
"markdown-pdf.styles": [
"markdown-pdf.css",
],
~
, it will be interpreted as a relative path from the home directory"markdown-pdf.styles": [
"~/.config/Code/User/markdown-pdf.css"
],
"markdown-pdf.styles": [
"https://xxx/markdown-pdf.css"
],
markdown-pdf.stylesRelativePathFile
markdown-pdf.stylesRelativePathFile
option is set to true
, the relative path set with markdown-pdf.styles is interpreted as relative from the filemarkdown-pdf.includeDefaultStyles
markdown-pdf.highlight
markdown-pdf.highlightStyle
"markdown-pdf.highlightStyle": "github.css",
markdown-pdf.breaks
markdown-pdf.emoji
markdown-pdf.executablePath
\
need to be written as \\
(Windows)"markdown-pdf.executablePath": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
markdown-pdf.scale
"markdown-pdf.scale": 1
markdown-pdf.displayHeaderFooter
"markdown-pdf.headerTemplate": "",
"markdown-pdf.footerTemplate": "",
markdown-pdf.headerTemplate
markdown-pdf.displayHeaderFooter
to true
<span class='date'></span>
: formatted print date. The format depends on the environment<span class='title'></span>
: markdown file name<span class='url'></span>
: markdown full path name<span class='pageNumber'></span>
: current page number<span class='totalPages'></span>
: total pages in the document%%ISO-DATETIME%%
: current date and time in ISO-based format (YYYY-MM-DD hh:mm:ss
)%%ISO-DATE%%
: current date in ISO-based format (YYYY-MM-DD
)%%ISO-TIME%%
: current time in ISO-based format (hh:mm:ss
)%%ISO-DATE%%
"markdown-pdf.headerTemplate": "<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>",
<span class='date'></span>
"markdown-pdf.headerTemplate": "<div style=\"font-size: 9px; margin-left: 1cm;\"> <span class='title'></span></div> <div style=\"font-size: 9px; margin-left: auto; margin-right: 1cm; \"> <span class='date'></span></div>",
markdown-pdf.footerTemplate
"markdown-pdf.footerTemplate": "<div style=\"font-size: 9px; margin: 0 auto;\"> <span class='pageNumber'></span> / <span class='totalPages'></span></div>",
markdown-pdf.printBackground
markdown-pdf.orientation
markdown-pdf.pageRanges
"markdown-pdf.pageRanges": "1,4-",
markdown-pdf.format
"markdown-pdf.format": "A4",
markdown-pdf.width
markdown-pdf.height
"markdown-pdf.width": "10cm",
"markdown-pdf.height": "20cm",
markdown-pdf.margin.top
markdown-pdf.margin.bottom
markdown-pdf.margin.right
markdown-pdf.margin.left
"markdown-pdf.margin.top": "1.5cm",
"markdown-pdf.margin.bottom": "1cm",
"markdown-pdf.margin.right": "1cm",
"markdown-pdf.margin.left": "1cm",
markdown-pdf.quality
"markdown-pdf.quality": 100,
markdown-pdf.clip.x
markdown-pdf.clip.y
markdown-pdf.clip.width
markdown-pdf.clip.height
// x-coordinate of top-left corner of clip area
"markdown-pdf.clip.x": 0,
// y-coordinate of top-left corner of clip area
"markdown-pdf.clip.y": 0,
// width of clipping area
"markdown-pdf.clip.width": 1000,
// height of clipping area
"markdown-pdf.clip.height": 1000,
markdown-pdf.omitBackground
markdown-pdf.plantumlOpenMarker
markdown-pdf.plantumlCloseMarker
markdown-pdf.plantumlServer
docker run -d -p 8080:8080 plantuml/plantuml-server:jetty
markdown-pdf.markdown-it-include.enable
markdown-pdf.mermaidServer
.emoji {
height: 2em;
}
Using files.autoGuessEncoding
option of the Visual Studio Code is useful because it automatically guesses the character code. See files.autoGuessEncoding
"files.autoGuessEncoding": true,
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,
Please use the following to insert a page break.
<div class="page"/>
markdown-pdf.styles
optionMIT
and