Documentation
¶
Overview ¶
Package converter orchestrates the Markdown → HTML → PDF pipeline.
The pipeline consists of three stages:
- Parse Markdown and extract fenced Mermaid code blocks.
- Render each Mermaid block to an SVG file using the mmdc CLI.
- Build a self-contained GitHub-styled HTML file and print it to PDF using a headless Chromium browser (via the Playwright Python driver).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// InputFile is the path to the source Markdown file.
InputFile string
// OutputFile is the destination output path (PDF or DOCX).
OutputFile string
// Format selects the output format: "pdf" (default) or "docx".
// An empty value is treated as "pdf".
Format string
// FontRegular is the file path to the Noto Sans CJK JP Regular font.
FontRegular string
// FontBold is the file path to the Noto Sans CJK JP Bold font.
FontBold string
// FontMedium is the file path to the Noto Sans CJK JP Medium font.
FontMedium string
// MmdcPath is the path to the mmdc (Mermaid CLI) binary.
MmdcPath string
// PandocPath is the path to the pandoc binary used for DOCX output.
// When empty, md2pdf auto-detects pandoc on PATH and in common locations.
PandocPath string
// DOCXFont is the font family applied to DOCX output for both Latin and
// East Asian text. When empty, a Japanese-friendly default is used.
DOCXFont string
// PythonPath is the path to the Python 3 interpreter used to drive Playwright.
// When empty, md2pdf auto-detects an interpreter on PATH that can import the
// playwright package.
PythonPath string
// PuppeteerConfig is an optional path to a Puppeteer JSON config file
// passed to mmdc via its -p flag. When empty the converter auto-generates
// a temporary config pointing at the system Chromium.
PuppeteerConfig string
// PageSize controls the PDF paper size (A4, Letter, A3).
PageSize string
// MarginTop, MarginBottom, MarginLeft, MarginRight set PDF page margins.
MarginTop string
MarginBottom string
MarginLeft string
MarginRight string
// Verbose enables detailed progress logging.
Verbose bool
}
Config holds all runtime options for the converter.
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter manages the conversion lifecycle including temporary file cleanup.
func (*Converter) Close ¶
func (c *Converter) Close()
Close removes the temporary working directory and all intermediate files.
func (*Converter) Convert ¶
Convert runs the conversion pipeline for the given input file, writing the result to outputPath. PDF output flows through the Markdown → HTML → Chromium stages; DOCX output is produced directly from Markdown by pandoc so the result uses clean, Word-native styling instead of HTML-derived markup.
Click to show internal directories.
Click to hide internal directories.