export

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package export 将 OFD 文档导出为 ofd-creator 可读取的 manifest。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildManifest added in v0.1.3

func BuildManifest(input any, index int, options Options) (manifest.Manifest, error)

BuildManifest 将指定文档体导出为 manifest 结构,并把二进制资源交给 Options.AssetSink(或写入 AssetRoot)。用于在内存中继续合并或转换。

func BuildManifestFromOFD added in v0.1.3

func BuildManifestFromOFD(ofd *parser.OFD, index int, options Options) (manifest.Manifest, error)

BuildManifestFromOFD 与 BuildManifest 相同,但复用已打开的解析器。

func WriteBundle added in v0.1.2

func WriteBundle(input any, outputDir string, options Options) error

WriteBundle 将 OFD 的全部文档体写入一个目录包。 每个文档体拥有独立的 manifest 和资源目录,根目录下同时写入索引文件。

func WriteDocumentManifest added in v0.1.2

func WriteDocumentManifest(input any, index int, output io.Writer, options Options) error

WriteDocumentManifest 将指定索引的文档体写入 manifest。 index 从 0 开始;该 API 用于 OFD 包含多个文档体时选择其中一个文档。

func WriteManifest added in v0.1.2

func WriteManifest(input any, output io.Writer, options Options) error

WriteManifest 将 OFD 写入 manifest,并将字体和多媒体资源写入 AssetRoot。 导出的 manifest 可以作为 ofd-creator 的输入,但不承诺原始 OFD 的字节级还原。

Types

type BundleDocument

type BundleDocument struct {
	Index     int    `json:"index" yaml:"index"`
	ID        string `json:"id" yaml:"id"`
	Title     string `json:"title" yaml:"title"`
	Manifest  string `json:"manifest" yaml:"manifest"`
	AssetRoot string `json:"asset_root" yaml:"asset_root"`
	Pages     int    `json:"pages" yaml:"pages"`
}

BundleDocument 标识导出目录包中的一个文档 manifest。

type BundleIndex

type BundleIndex struct {
	Version   int              `json:"version" yaml:"version"`
	Documents []BundleDocument `json:"documents" yaml:"documents"`
}

BundleIndex 描述 WriteBundle 生成的 manifest 集合。

type Options

type Options struct {
	// AssetRoot 是导出二进制资源的实际目录。
	AssetRoot string
	// AssetPrefix 是 manifest 中相对于 manifest 文件的资源目录前缀。
	AssetPrefix string
	// Format 是 manifest 输出格式,可选 yaml、json 或 toml。
	Format string
	// JSONIndent 控制 JSON 输出是否使用 2 空格缩进。
	JSONIndent bool
	// AssetSink 可选,接收导出过程中产生的二进制资源(name 为资源相对路径)。
	// 设置后不再写入 AssetRoot,AssetRoot 可以为空。
	AssetSink func(name string, data []byte) error
}

Options 控制 OFD manifest 导出。

Jump to

Keyboard shortcuts

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