formatter

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTMLToMarkdown

func HTMLToMarkdown(htmlContent string) string

HTMLToMarkdown converts HTML content to Markdown format using the html-to-markdown library.

func List

func List() []string

List returns a list of available formatter names.

Types

type EPUBFormatter

type EPUBFormatter struct{}

EPUBFormatter implements the Formatter interface for EPUB output.

func NewEPUBFormatter

func NewEPUBFormatter() *EPUBFormatter

NewEPUBFormatter creates a new EPUB formatter.

func (*EPUBFormatter) Format

func (f *EPUBFormatter) Format(w io.Writer, digest *models.Digest, opts *Options) error

Format writes the formatted digest to the provided writer.

type Formatter

type Formatter interface {
	// Format writes the formatted digest to the provided writer
	Format(w io.Writer, digest *models.Digest, opts *Options) error
}

Formatter defines the interface for digest output formatters.

func New

func New(name string) (Formatter, error)

New returns a new instance of the specified formatter.

type MarkdownFormatter

type MarkdownFormatter struct{}

MarkdownFormatter implements the Formatter interface for Markdown output.

func NewMarkdownFormatter

func NewMarkdownFormatter() *MarkdownFormatter

NewMarkdownFormatter creates a new Markdown formatter.

func (*MarkdownFormatter) Format

func (f *MarkdownFormatter) Format(w io.Writer, digest *models.Digest, opts *Options) error

Format writes the formatted digest to the provided writer.

type Options

type Options struct {
	// IncludeSummary toggles whether article summaries are included
	IncludeSummary bool

	// IncludeMetadata toggles whether metadata is included
	IncludeMetadata bool

	// StoreImages toggles whether to store images locally. Doesn't apply to
	// Markdown.
	StoreImages bool

	// Fetcher is a fetcher used to fetch images and other resources if
	// required.
	Fetcher fetcher.Fetcher

	// AdditionalOptions contains format-specific options
	AdditionalOptions map[string]any
}

Options contains configuration options for formatters.

func DefaultOptions

func DefaultOptions() Options

func OptionsFromConfig

func OptionsFromConfig(config map[string]any, fetcher fetcher.Fetcher) Options

OptionsFromConfig converts a configuration map to Options.

Jump to

Keyboard shortcuts

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