Documentation
¶
Overview ¶
build.go implements the core mdpress build command. It loads config, resolves sources, and dispatches document generation. Both local directories and GitHub repositories are supported, including zero-config discovery mode.
init_cmd.go implements the init subcommand. It scans Markdown files, extracts structure and titles, and generates book.yaml. When the target directory is empty it creates starter files. Interactive mode collects project metadata, with sensible defaults for non-interactive terminals.
migrate.go implements the `mdpress migrate` command.
It detects a GitBook / HonKit project in the given directory, converts book.json to book.yaml, rewrites GitBook-specific template tags in Markdown files, and prints a migration report.
quickstart.go implements the quickstart subcommand. It creates a complete sample book project so users can see results quickly. The command generates book.yaml, README.md, sample chapters, image placeholders, and next-step instructions.
serve.go implements the local live preview server. It watches files, rebuilds HTML on change, and pushes reload events over WebSocket.
validate.go implements the validate subcommand. It checks the book config, referenced files, and image paths, then prints a readable validation report.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Version is overridden at build time via -ldflags. Version = "0.3.0" // BuildTime is overridden at build time via -ldflags. BuildTime = "unknown" )
Functions ¶
Types ¶
type BuildContext ¶
type BuildContext struct {
Config *config.BookConfig
Theme *theme.Theme
SinglePageParts *renderer.RenderParts
ChaptersHTML []renderer.ChapterHTML
ChapterFiles []string
CustomCSS string
Logger *slog.Logger
}
BuildContext carries all data needed by format builders.
type BuildOrchestrator ¶
type BuildOrchestrator struct {
Config *config.BookConfig
Theme *theme.Theme
Parser *markdown.Parser
Gloss *glossary.Glossary
Logger *slog.Logger
// PluginManager manages loaded plugins and dispatches hook calls throughout the
// build pipeline. It is an empty (no-op) Manager when no plugins are configured.
PluginManager *plugin.Manager
}
BuildOrchestrator encapsulates the shared build initialization workflow used by both `build` and `serve` commands.
func NewBuildOrchestrator ¶
func NewBuildOrchestrator(cfg *config.BookConfig, logger *slog.Logger) (*BuildOrchestrator, error)
NewBuildOrchestrator creates a fully initialized orchestrator from config. It loads the theme (with fallback), creates the parser, and loads the glossary.
func (*BuildOrchestrator) LoadCustomCSS ¶
func (o *BuildOrchestrator) LoadCustomCSS() string
LoadCustomCSS loads user-provided CSS.
func (*BuildOrchestrator) ProcessChapters ¶
func (o *BuildOrchestrator) ProcessChapters() (*ChapterPipelineResult, error)
ProcessChapters runs the ChapterPipeline and returns results.
type ChapterPipeline ¶
type ChapterPipeline struct {
Config *config.BookConfig
Theme *theme.Theme
Parser *markdown.Parser
Glossary *glossary.Glossary
Logger *slog.Logger
// PluginManager is invoked at the AfterParse hook, allowing plugins to
// transform the HTML of each chapter after Markdown parsing.
PluginManager *plugin.Manager
}
ChapterPipeline orchestrates the complete chapter processing workflow.
func NewChapterPipeline ¶
func NewChapterPipeline(cfg *config.BookConfig, thm *theme.Theme, parser *markdown.Parser, gloss *glossary.Glossary, logger *slog.Logger, mgr *plugin.Manager) *ChapterPipeline
NewChapterPipeline creates a new chapter pipeline with the given configuration.
func (*ChapterPipeline) Process ¶
func (p *ChapterPipeline) Process() (*ChapterPipelineResult, error)
Process executes the complete chapter processing pipeline. It returns processed chapters, chapter file paths, validation issues, and any error encountered. Always uses ParseWithDiagnostics regardless of caller preference.
type ChapterPipelineResult ¶
type ChapterPipelineResult struct {
Chapters []renderer.ChapterHTML
ChapterFiles []string
Issues []projectIssue
AllHeadings []toc.HeadingInfo
Resolver *crossref.Resolver
HeadingRecords []chapterHeadingRecord
}
ChapterPipelineResult encapsulates the output of chapter processing.
type EpubBuilder ¶
type EpubBuilder struct{}
EpubBuilder generates an EPUB 3 ebook.
func (*EpubBuilder) Build ¶
func (b *EpubBuilder) Build(ctx *BuildContext, baseName string) error
func (*EpubBuilder) Name ¶
func (b *EpubBuilder) Name() string
type FormatBuilder ¶
type FormatBuilder interface {
// Name returns the format name (e.g. "pdf", "html", "site", "epub").
Name() string
// Build generates the output file(s) at the given base path.
Build(ctx *BuildContext, baseName string) error
}
FormatBuilder generates output in a specific format.
type FormatBuilderRegistry ¶
type FormatBuilderRegistry struct {
// contains filtered or unexported fields
}
FormatBuilderRegistry manages registered format builders.
func NewFormatBuilderRegistry ¶
func NewFormatBuilderRegistry() *FormatBuilderRegistry
NewFormatBuilderRegistry creates a registry pre-populated with all built-in formats.
func (*FormatBuilderRegistry) Get ¶
func (r *FormatBuilderRegistry) Get(name string) FormatBuilder
Get returns a builder by format name, or nil if not found.
func (*FormatBuilderRegistry) Register ¶
func (r *FormatBuilderRegistry) Register(b FormatBuilder)
Register adds a format builder.
type HTMLBuilder ¶
type HTMLBuilder struct{}
HTMLBuilder generates a self-contained single-page HTML document.
func (*HTMLBuilder) Build ¶
func (b *HTMLBuilder) Build(ctx *BuildContext, baseName string) error
func (*HTMLBuilder) Name ¶
func (b *HTMLBuilder) Name() string
type PDFBuilder ¶
type PDFBuilder struct{}
PDFBuilder generates PDF output via Chromium.
func (*PDFBuilder) Build ¶
func (b *PDFBuilder) Build(ctx *BuildContext, baseName string) error
func (*PDFBuilder) Name ¶
func (b *PDFBuilder) Name() string
type ServeOptions ¶
ServeOptions encapsulates configuration for the serve command.
type SiteBuilder ¶
type SiteBuilder struct{}
SiteBuilder generates a multi-page HTML site.
func (*SiteBuilder) Build ¶
func (b *SiteBuilder) Build(ctx *BuildContext, baseName string) error
func (*SiteBuilder) Name ¶
func (b *SiteBuilder) Name() string