Documentation
¶
Overview ¶
Package docpdf renders docrender Markdown to PDF by driving external converters as subprocesses; no PDF renderer is linked into the binary.
Index ¶
Constants ¶
const ( PandocEnv = "OPENSYSML_PANDOC" WeasyPrintEnv = "OPENSYSML_WEASYPRINT" PrinceEnv = "OPENSYSML_PRINCE" MermaidEnv = "OPENSYSML_MMDC" // MermaidPuppeteerEnv names an optional puppeteer configuration file // passed to mmdc, for environments whose browser needs launch flags. MermaidPuppeteerEnv = "OPENSYSML_MMDC_PUPPETEER" )
Environment variables that point each external tool's discovery at a specific executable, ahead of a PATH lookup by its default name.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Capabilities ¶
Capabilities is what a converter states about itself: the form it reads, the executables it drives, and whether it applies the deliverable options natively rather than through the prepared HTML.
type Converter ¶
type Converter interface {
// Name is what -pdf-engine selects the converter by.
Name() string
// Capabilities states the converter's input form and tools.
Capabilities() Capabilities
// Available returns nil, or a typed error naming the missing tool.
Available() error
// Convert lays the prepared document out as PDF bytes.
Convert(doc *Prepared) ([]byte, error)
}
Converter is one external Markdown/HTML-to-PDF toolchain, run as a subprocess.
func EngineNamed ¶
EngineNamed returns the converter -pdf-engine named, the default for "", and a typed error for a name no converter answers to.
type Error ¶
type Error struct {
Kind ErrorKind
// Engine is the converter that was selected, where one was.
Engine string
// Tool is the external executable involved: its configured override or
// its default name for ErrorToolMissing, its path for ErrorToolFailed.
Tool string
// EnvVar is the environment variable that overrides where Tool is found.
EnvVar string
// Engines lists the converters an unknown -pdf-engine could have named.
Engines []string
// Detail carries what the tool said on stderr, trimmed.
Detail string
}
Error is a typed PDF-rendering failure.
type ErrorKind ¶
type ErrorKind string
ErrorKind classifies a PDF-rendering failure.
const ( // ErrorUnknownEngine reports a -pdf-engine name no converter answers to. ErrorUnknownEngine ErrorKind = "unknown-engine" // ErrorToolMissing reports an external tool the selected converter needs // that could not be found. ErrorToolMissing ErrorKind = "tool-missing" // ErrorToolFailed reports an external tool that ran and failed. ErrorToolFailed ErrorKind = "tool-failed" // ErrorNoPDF reports a converter that succeeded without producing a PDF. ErrorNoPDF ErrorKind = "no-pdf" // ErrorUnclosedFence reports a diagram fence the Markdown never closes. ErrorUnclosedFence ErrorKind = "unclosed-fence" // ErrorDanglingCaption reports a caption marker not followed by a // fully-emphasized caption line. ErrorDanglingCaption ErrorKind = "dangling-caption" )
type Options ¶
type Options struct {
// TitlePage puts the document title on a page of its own.
TitlePage bool
// TOC writes a table of contents ahead of the content.
TOC bool
// NumberSections numbers the section headings hierarchically.
NumberSections bool
}
Options are the deliverable-document choices the PDF backend offers. They are presentation options of this backend, never document-model attributes.
type Prepared ¶
type Prepared struct {
// Dir is the working directory holding every input, diagram SVGs included.
Dir string
// MarkdownFile is the Markdown document's name within Dir.
MarkdownFile string
// HTMLFile is the HTML document's name within Dir.
HTMLFile string
// Options are the deliverable choices, for converters with native flags.
Options Options
}
Prepared is one document laid out in a working directory for a converter, as both Markdown (diagrams as image references) and standalone HTML.