converters

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default() *convert.Registry

Default returns a Registry wired with the built-in converters. Lower priority values are tried first: specific structured parsers (0) beat markup/fenced converters (5), which beat the plain-text catch-all (10).

func RegisterPlugins added in v0.1.1

func RegisterPlugins(reg *convert.Registry) (plugins []plugin.Plugin, discoverErrs []error, err error)

RegisterPlugins loads configured plugin manifests, discovers their capabilities, and registers each ahead of the built-in converters (priority -10, so a plugin can override a built-in format). It returns the discovered plugins and any per-plugin discovery errors (non-fatal). A fatal config-load error is returned separately.

Types

type Archive

type Archive struct {
	Reg *convert.Registry
}

Archive converts the entries of a ZIP or TAR archive. Each supported entry is converted via Reg and emitted under a heading. Nested archives are noted but not recursed into, and entry count/byte totals are capped (zip-bomb guard).

func (Archive) Accepts

func (Archive) Accepts(info convert.StreamInfo) bool

func (Archive) Convert

func (a Archive) Convert(r io.Reader, info convert.StreamInfo) (convert.Result, error)

type CSV

type CSV struct{}

CSV converts CSV/TSV input into a Markdown table (priority 0).

func (CSV) Accepts

func (CSV) Accepts(info convert.StreamInfo) bool

func (CSV) Convert

func (CSV) Convert(r io.Reader, info convert.StreamInfo) (convert.Result, error)

type DOCX

type DOCX struct{}

DOCX converts a Word document to Markdown, preserving heading levels (Heading1..N → # ..######), bullet lists (numPr → -), and tables (w:tbl).

func (DOCX) Accepts

func (DOCX) Accepts(info convert.StreamInfo) bool

func (DOCX) Convert

func (DOCX) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type EML

type EML struct{}

EML converts an RFC 822 e-mail: key headers become a small block, then the body. For multipart messages, text/plain is preferred, falling back to text/html (converted to Markdown). Base64 / quoted-printable parts are decoded.

func (EML) Accepts

func (EML) Accepts(info convert.StreamInfo) bool

func (EML) Convert

func (EML) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type EPUB

type EPUB struct{}

EPUB converts an e-book by reading its OPF spine order and converting each XHTML document to Markdown via the HTML pipeline.

func (EPUB) Accepts

func (EPUB) Accepts(info convert.StreamInfo) bool

func (EPUB) Convert

func (EPUB) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type Feed

type Feed struct{}

Feed converts an RSS or Atom feed into a title heading plus a list of dated, linked items. Non-feed input returns errNotFeed so the dispatcher falls through to the generic XML converter.

func (Feed) Accepts

func (Feed) Accepts(info convert.StreamInfo) bool

func (Feed) Convert

func (Feed) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type Fenced

type Fenced struct {
	Lang  string
	Exts  []string
	Mimes []string
}

Fenced wraps input verbatim in a language-tagged code fence. Used for config and markup formats whose most faithful Markdown form is the original text (parsing then re-serializing would lose comments and ordering).

func (Fenced) Accepts

func (f Fenced) Accepts(info convert.StreamInfo) bool

func (Fenced) Convert

func (f Fenced) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type HTML

type HTML struct{}

HTML converts HTML to Markdown via html-to-markdown/v2 (CommonMark output with ATX headings; scripts and styles are dropped by the library).

func (HTML) Accepts

func (HTML) Accepts(info convert.StreamInfo) bool

func (HTML) Convert

func (HTML) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type Image

type Image struct{}

Image emits format + pixel dimensions for common raster images, and appends OCR text when Tesseract is available.

func (Image) Accepts

func (Image) Accepts(info convert.StreamInfo) bool

func (Image) Convert

func (Image) Convert(r io.Reader, info convert.StreamInfo) (convert.Result, error)

type Ipynb

type Ipynb struct{}

Ipynb converts a Jupyter notebook (.ipynb) to Markdown: markdown cells are emitted verbatim, code cells as fenced blocks, and text outputs included.

func (Ipynb) Accepts

func (Ipynb) Accepts(info convert.StreamInfo) bool

func (Ipynb) Convert

func (Ipynb) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type JSON

type JSON struct{}

JSON validates and pretty-prints JSON into a fenced ```json block.

func (JSON) Accepts

func (JSON) Accepts(info convert.StreamInfo) bool

func (JSON) Convert

func (JSON) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type Media

type Media struct{}

Media converts audio/video files to a Markdown metadata block via ffprobe, optionally appending a transcript when the `whisper` CLI is available.

func (Media) Accepts

func (Media) Accepts(info convert.StreamInfo) bool

func (Media) Convert

func (Media) Convert(r io.Reader, info convert.StreamInfo) (convert.Result, error)

type ODF

type ODF struct{}

ODF converts ODT/ODS/ODP files by reading content.xml, mapping text:h outline-level → #..######, text:p → paragraphs (or list items inside text:list), and table:table → Markdown tables.

func (ODF) Accepts

func (ODF) Accepts(info convert.StreamInfo) bool

func (ODF) Convert

func (ODF) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type PDF

type PDF struct{}

PDF extracts text from a PDF. It prefers poppler's `pdftotext -layout` when available (better spacing/layout), falls back to a pure-Go reader, and as a last resort OCRs scanned PDFs when Tesseract + pdftoppm are present.

func (PDF) Accepts

func (PDF) Accepts(info convert.StreamInfo) bool

func (PDF) Convert

func (PDF) Convert(r io.Reader, _ convert.StreamInfo) (res convert.Result, err error)

type PPTX

type PPTX struct{}

PPTX converts a PowerPoint deck to Markdown: each slide becomes "## Slide N" (or "## Slide N: <title>" with a title placeholder), with body text emitted as bullets honoring lvl, and embedded tables (a:tbl in a graphicFrame) rendered as Markdown tables.

func (PPTX) Accepts

func (PPTX) Accepts(info convert.StreamInfo) bool

func (PPTX) Convert

func (PPTX) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

type PlainText

type PlainText struct{}

PlainText is the generic catch-all converter (priority 10). It treats the input as text and passes it through unchanged.

func (PlainText) Accepts

func (PlainText) Accepts(info convert.StreamInfo) bool

func (PlainText) Convert

type XLSX

type XLSX struct{}

XLSX renders each worksheet of an .xlsx workbook as a Markdown table under a heading with the sheet name.

func (XLSX) Accepts

func (XLSX) Accepts(info convert.StreamInfo) bool

func (XLSX) Convert

func (XLSX) Convert(r io.Reader, _ convert.StreamInfo) (convert.Result, error)

Jump to

Keyboard shortcuts

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