- Markdown PDF
- yzane
- Markdown PDF
- Table of Contents
- Features
- markdown-it-container
- markdown-it-plantuml
- markdown-it-include
- mermaid
- Install
- Usage
- Command Palette
- Auto convert
- Extension Settings
- Options
- Save options
- markdown-pdf.type
- markdown-pdf.convertOnSave
- markdown-pdf.convertOnSaveExclude
- markdown-pdf.outputDirectory
- markdown-pdf.outputDirectoryRelativePathFile
- Styles options
- markdown-pdf.styles
- markdown-pdf.stylesRelativePathFile
- markdown-pdf.includeDefaultStyles
- Syntax highlight options
- markdown-pdf.highlight
- markdown-pdf.highlightStyle
- Markdown options
- markdown-pdf.breaks
- Emoji options
- markdown-pdf.emoji
- Configuration options
- markdown-pdf.executablePath
- Common Options
- markdown-pdf.scale
- PDF options
- markdown-pdf.displayHeaderFooter
- markdown-pdf.headerTemplate
- markdown-pdf.footerTemplate
- markdown-pdf.printBackground
- markdown-pdf.orientation
- markdown-pdf.pageRanges
- markdown-pdf.format
- markdown-pdf.width
- markdown-pdf.height
- markdown-pdf.margin.top
- markdown-pdf.margin.bottom
- markdown-pdf.margin.right
- markdown-pdf.margin.left
- PNG JPEG options
- markdown-pdf.quality
- markdown-pdf.clip.x
- markdown-pdf.clip.y
- markdown-pdf.clip.width
- markdown-pdf.clip.height
- markdown-pdf.omitBackground
- PlantUML options
- markdown-pdf.plantumlOpenMarker
- markdown-pdf.plantumlCloseMarker
- markdown-pdf.plantumlServer
- markdown-it-include options
- markdown-pdf.markdown-it-include.enable
- mermaid options
- markdown-pdf.mermaidServer
- How can I change emoji size ?
- Auto guess encoding of files
- Output directory
- Page Break
- Как конвертировать R Markdown в PDF?
- Обновленный ответ (10 февраля 2013 г.)
- Старый ответ (около 2012)
- Использование Pandoc
- Получение обновленной версии Pandoc
Markdown PDF
yzane
Markdown PDF
This extension converts Markdown files to pdf, html, png or jpeg files.
Table of Contents
Features
Supports the following features
markdown-it-container
markdown-it-plantuml
markdown-it-include
Include markdown fragment files: :[alternate-text](https://github.com/yzane/vscode-markdown-pdf/blob/master/relative-path-to-file.md) .
mermaid
Install
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 (
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.
Usage
Command Palette
- Open the Markdown file
- Press F1 or Ctrl+Shift+P
- Type 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)
- Open the Markdown file
- Right click 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)
Auto convert
- Add «markdown-pdf.convertOnSave»: true option to settings.json
- Restart Visual Studio Code
- Open the Markdown file
- Auto convert on save
Extension Settings
- Select File > Preferences > UserSettings or Workspace Settings
- Find markdown-pdf settings in the Default Settings
- Copy markdown-pdf.* settings
- Paste to the settings.json, and change the value
Options
Category | Option name | Configuration scope |
---|---|---|
Save options | markdown-pdf.type | |
markdown-pdf.convertOnSave | ||
markdown-pdf.convertOnSaveExclude | ||
markdown-pdf.outputDirectory | ||
markdown-pdf.outputDirectoryRelativePathFile | ||
Styles options | markdown-pdf.styles | |
markdown-pdf.stylesRelativePathFile | ||
markdown-pdf.includeDefaultStyles | ||
Syntax highlight options | markdown-pdf.highlight | |
markdown-pdf.highlightStyle | ||
Markdown options | markdown-pdf.breaks | |
Emoji options | markdown-pdf.emoji | |
Configuration options | markdown-pdf.executablePath | |
Common Options | markdown-pdf.scale | |
PDF options | markdown-pdf.displayHeaderFooter | resource |
markdown-pdf.headerTemplate | resource | |
markdown-pdf.footerTemplate | resource | |
markdown-pdf.printBackground | resource | |
markdown-pdf.orientation | resource | |
markdown-pdf.pageRanges | resource | |
markdown-pdf.format | resource | |
markdown-pdf.width | resource | |
markdown-pdf.height | resource | |
markdown-pdf.margin.top | resource | |
markdown-pdf.margin.bottom | resource | |
markdown-pdf.margin.right | resource | |
markdown-pdf.margin.left | resource | |
PNG JPEG options | markdown-pdf.quality | |
markdown-pdf.clip.x | ||
markdown-pdf.clip.y | ||
markdown-pdf.clip.width | ||
markdown-pdf.clip.height | ||
markdown-pdf.omitBackground | ||
PlantUML options | markdown-pdf.plantumlOpenMarker | |
markdown-pdf.plantumlCloseMarker | ||
markdown-pdf.plantumlServer | ||
markdown-it-include options | markdown-pdf.markdown-it-include.enable | |
mermaid options | markdown-pdf.mermaidServer |
Save options
markdown-pdf.type
- Output format: pdf, html, png, jpeg
- Multiple output formats support
- Default: pdf
markdown-pdf.convertOnSave
- Enable Auto convert on save
- boolean. Default: false
- To apply the settings, you need to restart Visual Studio Code
markdown-pdf.convertOnSaveExclude
- Excluded file name of convertOnSave option
markdown-pdf.outputDirectory
- Output Directory
- All \ need to be written as \\ (Windows)
- Relative path
- If you open the Markdown file , it will be interpreted as a relative path from the file
- If you open a folder , it will be interpreted as a relative path from the root folder
- If you open the workspace , it will be interpreted as a relative path from the each root folder
- See Multi-root Workspaces
- Relative path (home directory)
- If path starts with
, it will be interpreted as a relative path from the home directory
- If path starts with
- If you set a directory with a relative path , it will be created if the directory does not exist
- If you set a directory with an absolute path , an error occurs if the directory does not exist
markdown-pdf.outputDirectoryRelativePathFile
- If markdown-pdf.outputDirectoryRelativePathFile option is set to true , the relative path set with markdown-pdf.outputDirectory is interpreted as relative from the file
- It can be used to avoid relative paths from folders and workspaces
- boolean. Default: false
Styles options
markdown-pdf.styles
- A list of local paths to the stylesheets to use from the markdown-pdf
- If the file does not exist, it will be skipped
- All \ need to be written as \\ (Windows)
- Relative path
- If you open the Markdown file , it will be interpreted as a relative path from the file
- If you open a folder , it will be interpreted as a relative path from the root folder
- If you open the workspace , it will be interpreted as a relative path from the each root folder
- See Multi-root Workspaces
- Relative path (home directory)
- If path starts with
, it will be interpreted as a relative path from the home directory
- If path starts with
- Online CSS (https://xxx/xxx.css) is applied correctly for JPG and PNG, but problems occur with PDF #67
markdown-pdf.stylesRelativePathFile
- If markdown-pdf.stylesRelativePathFile option is set to true , the relative path set with markdown-pdf.styles is interpreted as relative from the file
- It can be used to avoid relative paths from folders and workspaces
- boolean. Default: false
markdown-pdf.includeDefaultStyles
- Enable the inclusion of default Markdown styles (VSCode, markdown-pdf)
- boolean. Default: true
Syntax highlight options
markdown-pdf.highlight
- Enable Syntax highlighting
- boolean. Default: true
markdown-pdf.highlightStyle
- Set the style file name. for example: github.css, monokai.css .
- file name list
- demo site : https://highlightjs.org/static/demo/
Markdown options
markdown-pdf.breaks
- Enable line breaks
- boolean. Default: false
Emoji options
markdown-pdf.emoji
- Enable emoji. EMOJI CHEAT SHEET
- boolean. Default: true
Configuration options
markdown-pdf.executablePath
- Path to a Chromium or Chrome executable to run instead of the bundled Chromium
- All \ need to be written as \\ (Windows)
- To apply the settings, you need to restart Visual Studio Code
Common Options
markdown-pdf.scale
- Scale of the page rendering
- number. default: 1
PDF options
markdown-pdf.displayHeaderFooter
- Enable display header and footer
- boolean. Default: true
markdown-pdf.headerTemplate
markdown-pdf.footerTemplate
- HTML template for the print header and footer
- : formatted print date
- : markdown file name
- : markdown full path name
- : current page number
- : total pages in the document
markdown-pdf.printBackground
- Print background graphics
- boolean. Default: true
markdown-pdf.orientation
- Paper orientation
- portrait or landscape
- Default: portrait
markdown-pdf.pageRanges
- Paper ranges to print, e.g., ‘1-5, 8, 11-13’
- Default: all pages
markdown-pdf.format
- Paper format
- Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
- Default: A4
markdown-pdf.width
markdown-pdf.height
- Paper width / height, accepts values labeled with units(mm, cm, in, px)
- If it is set, it overrides the markdown-pdf.format option
markdown-pdf.margin.top
markdown-pdf.margin.bottom
markdown-pdf.margin.right
markdown-pdf.margin.left
PNG JPEG options
markdown-pdf.quality
- jpeg only. The quality of the image, between 0-100. Not applicable to png images
markdown-pdf.clip.x
markdown-pdf.clip.y
markdown-pdf.clip.width
markdown-pdf.clip.height
- An object which specifies clipping region of the page
- number
markdown-pdf.omitBackground
- Hides default white background and allows capturing screenshots with transparency
- boolean. Default: false
PlantUML options
markdown-pdf.plantumlOpenMarker
- Oppening delimiter used for the plantuml parser.
- Default: @startuml
markdown-pdf.plantumlCloseMarker
- Closing delimiter used for the plantuml parser.
- Default: @enduml
markdown-pdf.plantumlServer
- Plantuml server. e.g. http://localhost:8080
- Default: http://www.plantuml.com/plantuml
- For example, to run Plantuml Server locally #139 : plantuml/plantuml-server — Docker Hub
markdown-it-include options
markdown-pdf.markdown-it-include.enable
- Enable markdown-it-include.
- boolean. Default: true
mermaid options
markdown-pdf.mermaidServer
How can I change emoji size ?
- Add the following to your stylesheet which was specified in the markdown-pdf.styles
Auto guess encoding of files
Using files.autoGuessEncoding option of the Visual Studio Code is useful because it automatically guesses the character code. See files.autoGuessEncoding
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.
Page Break
Please use the following to insert a page break.
Как конвертировать R Markdown в PDF?
Что такое хороший способ конвертировать файлы R Markdown в документы PDF?
Хорошее решение могло бы сохранить как можно больше контента (например, изображения, уравнения, таблицы html и т.д.). Решение должно быть выполнено из командной строки. Хорошее решение также будет кросс-платформенным и идеально минимизировать зависимости, чтобы упростить совместное использование make файлов и т.д.
В частности, есть много вариантов:
- Преобразовать RMD в MD в HTML в PDF; или RMD до MD в PDF; или RMD для PDF
Если вы используете пакет markdown в R, какие параметры указывать
Использовать ли pandoc , пакет, встроенный в R, или что-то еще
Вот пример rmd file, который предположительно обеспечивает разумную проверку любого предлагаемого решения. Он был использован в качестве основы для этого сообщения в блоге.
Обновленный ответ (10 февраля 2013 г.)
пакет rmarkdown:
В настоящее время существует пакет rmarkdown , доступный в github, который взаимодействует с Pandoc.
Он включает функцию render . В документации очень ясно, как преобразовать rmarkdown в pdf среди ряда других форматов. Это включает в себя выходные форматы в файле rmarkdown или запуск подачи выходного формата в функцию rend. Например.
Командная строка:
Когда я запускаю render из командной строки (например, используя make файл), у меня иногда возникают проблемы с не найденным pandoc. Предположительно, это не на пути поиска.
Следующий ответ объясняет как добавить pandoc в среду R.
Так, например, на моем компьютере с OSX, где у меня есть копия pandoc через RStudio, я могу использовать следующее:
Старый ответ (около 2012)
Итак, многие люди предположили, что Pandoc — это путь. См. Примечания ниже о важности наличия обновленной версии Pandoc.
Использование Pandoc
Я использовал следующую команду для преобразования R Markdown в HTML (т.е. вариант этого файла makefile), где RMDFILE — это имя файла R Markdown без компонента .rmd (он также предполагает, что расширение .rmd , а не .rmd ).
а затем эту команду для преобразования в pdf
Несколько замечаний об этом:
- Я удалил ссылку в файле примера, который экспортирует графики в imgur для размещения изображений.
Я удалил ссылку на изображение, размещенное на imgur. Цифры, по-видимому, должны быть локальными.
Параметры в функции markdownToHTML означали, что ссылки на изображения относятся к файлам, а не к данным, хранящимся в файле HTML (т.е. я удалил ‘base64_images’ из списка опций).
Полученный результат выглядел как this. Он явно сделал документ в стиле LaTeX в отличие от того, что я получаю, если напечатаю HTML файл в pdf из браузера.
Получение обновленной версии Pandoc
Как уже упоминалось @daroczig, важно иметь обновленную версию Pandoc для вывода PDF файлов. На Ubuntu с 15 июня 2012 года я застрял с версией 1.8.1 Pandoc в диспетчере пакетов, но из журнала изменений, который для поддержки в формате pdf вам потребуется как минимум версия 1.9+ от Pandoc.
Таким образом, я установил caball-install .
И затем побежал:
Pandoc был установлен в
/.cabal/bin/pandoc
Таким образом, когда я запустил pandoc , он все еще видел старую версию.
См. Здесь добавление к пути.