exporter

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTitleFromFilename

func AddTitleFromFilename(content, filename string, level int) string

AddTitleFromFilename Add heading from filename

func CheckPandocAvailability

func CheckPandocAvailability() error

CheckPandocAvailability Check if Pandoc is available

func GetMarkdownFilesInDir

func GetMarkdownFilesInDir(dir string) ([]string, error)

GetMarkdownFilesInDir gets all Markdown files in a directory and sorts them by filename

func ShiftHeadings

func ShiftHeadings(content string, shiftBy int) string

ShiftHeadings Adjust heading levels in Markdown text

Types

type DefaultExporter

type DefaultExporter struct {
	// contains filtered or unexported fields
}

DefaultExporter is the default exporter implementation

func NewExporter

func NewExporter() *DefaultExporter

NewExporter creates a new exporter

func (*DefaultExporter) ExportDirectory

func (e *DefaultExporter) ExportDirectory(inputDir, output string, options ExportOptions) error

ExportDirectory exports Markdown files in a directory

func (*DefaultExporter) ExportFile

func (e *DefaultExporter) ExportFile(input, output string, options ExportOptions) error

ExportFile exports a single Markdown file

type ExportOptions

type ExportOptions struct {
	Template            string      // Word template file path
	GenerateToc         bool        // Whether to generate table of contents
	ShiftHeadingLevelBy int         // Heading level offset
	FileAsTitle         bool        // Whether to use filename as section title
	Format              string      // Output format (docx, pdf, epub)
	SiteType            string      // Site type (mkdocs, hugo, docusaurus)
	Verbose             bool        // Whether to enable verbose logging
	Logger              *log.Logger // Logger
	SourceDirs          []string    // List of source directories for processing image paths
	TocDepth            int         // Table of contents depth, default is 3
	NavPath             string      // Specified navigation path to export
}

ExportOptions defines export options

type Exporter

type Exporter interface {
	Export(input string, output string, options ExportOptions) error
}

Exporter defines exporter interface

type Merger

type Merger struct {
	ShiftHeadingLevelBy int
	FileAsTitle         bool
	Logger              *log.Logger
	// Store all source directories, used to set Pandoc's resource paths
	SourceDirs []string
	// Whether to enable verbose logging
	Verbose bool
}

Merger Merge multiple Markdown files

func (*Merger) Merge

func (m *Merger) Merge(sources []string, target string) error

Merge Merge multiple Markdown files into a single target file

type PandocExporter

type PandocExporter struct {
	PandocPath string
	Logger     *log.Logger
}

PandocExporter Use Pandoc to export Markdown files

func (*PandocExporter) Export

func (e *PandocExporter) Export(input, output string, options ExportOptions) error

Export Use Pandoc to export Markdown files

type SiteReader

type SiteReader interface {
	// Detect if given directory is this type of site
	Detect(dir string) bool
	// Read site structure, return sorted list of files
	ReadStructure(dir string, configPath string) ([]string, error)
}

SiteReader defines site reader interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL