adapters

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package adapters contains source-format codecs for rich text documents.

Index

Constants

View Source
const DOCXMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
View Source
const HTMLMediaType = "text/html"
View Source
const XLSXMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

Variables

This section is empty.

Functions

func RegisterCommon

func RegisterCommon(reg *vfs.ContentRegistry) error

RegisterCommon registers Word and Excel. HTML stays a TextCodec type unless a host registers adapters.HTML itself — stealing text/html makes .html EROFS. Safe to call more than once on the same registry: existing DOCX/XLSX bindings are left in place (first registration wins).

Types

type DOCX

type DOCX struct{}

DOCX converts the main document part of a Word document. It intentionally operates on the portable WordprocessingML subset used by common editors.

func (DOCX) DecodeBlocks

func (DOCX) DecodeBlocks(ctx context.Context, path, _ string, data []byte) ([]vfs.Block, error)

func (DOCX) EncodeBlocks

func (DOCX) EncodeBlocks(ctx context.Context, blocks []vfs.Block) ([]byte, error)

type HTML

type HTML struct{}

HTML encodes and decodes the pretty HTML dialect used for Docs/Word agent buffers. It is not registered as the text/html file codec (FUSE would steal .html). One heading, paragraph, list item, or table per line.

func (HTML) DecodeBlocks

func (HTML) DecodeBlocks(ctx context.Context, _ string, _ string, data []byte) ([]vfs.Block, error)

func (HTML) EncodeBlocks

func (HTML) EncodeBlocks(ctx context.Context, blocks []vfs.Block) ([]byte, error)

type XLSX

type XLSX struct{}

XLSX maps workbook.xml / sheetN.xml / sharedStrings.xml / styles.xml to TabularDocument.

func (XLSX) Decode

func (XLSX) Decode(ctx context.Context, virtualPath, mediaType string, data []byte) (vfs.Document, error)

func (XLSX) DecodeSheets

func (XLSX) DecodeSheets(ctx context.Context, _, _ string, data []byte) ([]vfs.Sheet, []vfs.NamedRange, error)

func (XLSX) Encode

func (XLSX) Encode(ctx context.Context, doc vfs.Document) ([]byte, error)

func (XLSX) EncodeSheets

func (XLSX) EncodeSheets(ctx context.Context, sheets []vfs.Sheet, _ []vfs.NamedRange) ([]byte, error)

func (XLSX) MediaTypes

func (XLSX) MediaTypes() []string

Jump to

Keyboard shortcuts

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