engine

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 71 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Footnote = "footnote"
	Endnote  = "endnote"
)
View Source
const StructuredSchema = "manydoc-prosemirror/1"
View Source
const VDOCSMIME = "application/vnd.manifold.docs+json;version=3"

Variables

View Source
var ErrLossy = errors.New("conversion would lose document features")
View Source
var ErrUnsupported = errors.New("unsupported document feature")

Functions

func Write

func Write(ctx context.Context, w io.Writer, d *Document, format Format, opts WriteOptions) error

func WriteStructured

func WriteStructured(ctx context.Context, w io.Writer, s *StructuredDocument) error

WriteStructured validates before emitting the persistent representation.

func WriteVDOCS

func WriteVDOCS(ctx context.Context, w io.Writer, d *Document) error

Types

type Block

type Block struct {
	// PageBreakBefore starts a paragraph/heading on a new page unless already
	// at the page's first flow position. PageBreak blocks always advance a page.
	PageBreakBefore bool `json:"page_break_before,omitempty"`
	// Anchors binds names to the start of this block; AnchorPoint has zero height.
	Anchors []string `json:"anchors,omitempty"`
	// Direction is empty (unspecified), ltr or rtl; it describes paragraph flow.
	Direction string `json:"direction,omitempty"`
	Kind      Kind   `json:"kind"`
	Runs      []Run  `json:"runs,omitempty"`
	Level     int    `json:"level,omitempty"`
	List      string `json:"list,omitempty"` // bullet or number
	Rows      []Row  `json:"rows,omitempty"`
	// ColumnWidths are preferred logical grid-column widths in points. Empty uses
	// equal available widths. Renderers shrink proportionally to fit a container.
	ColumnWidths []float64   `json:"column_widths,omitempty"`
	Image        *Image      `json:"image,omitempty"`
	Math         *OfficeMath `json:"math,omitempty"`
	Items        []ListItem  `json:"items,omitempty"`
	// Start is the first ordered-list value; nil means one. Zero is valid.
	Numbering *ListNumbering `json:"numbering,omitempty"`
	Start     *int           `json:"start,omitempty"`
	Source    *SourceInfo    `json:"source,omitempty"`
	Section   *Section       `json:"section,omitempty"`
	// contains filtered or unexported fields
}

type Cell

type Cell struct {
	Blocks  []Block `json:"blocks"`
	ColSpan int     `json:"col_span,omitempty"`
	// RowSpan includes the origin row; zero means one. Covered cells are
	// omitted from subsequent rows, rather than stored as duplicate content.
	RowSpan int         `json:"row_span,omitempty"`
	Source  *SourceInfo `json:"source,omitempty"`
	// contains filtered or unexported fields
}

type Diagnostic

type Diagnostic struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type Document

type Document struct {
	Presentation *Presentation `json:"presentation,omitempty"`
	// UnboundSources retains original source facts without a current content owner.
	UnboundSources    []SourceInfo   `json:"unbound_sources,omitempty"`
	PDFNavigation     *PDFNavigation `json:"pdf_navigation,omitempty"`
	Metadata          Metadata       `json:"metadata,omitempty"`
	Layout            Layout         `json:"layout,omitempty"`
	Blocks            []Block        `json:"blocks"`
	Headers           []Block        `json:"headers,omitempty"`
	Footers           []Block        `json:"footers,omitempty"`
	Notes             []Note         `json:"notes,omitempty"`
	Diagnostics       []Diagnostic   `json:"diagnostics,omitempty"`
	Pages             []PDFPage      `json:"pages,omitempty"`
	EvenAndOddHeaders bool           `json:"even_and_odd_headers,omitempty"`
	// UnresolvedDestinations explicitly retains source links whose target is absent.
	UnresolvedDestinations []string `json:"unresolved_destinations,omitempty"`
}

Document is manifold's interchange model. Diagnostics describe input features whose structure cannot be represented. Converters reject lossy output unless the caller explicitly acknowledges those diagnostics.

func FromStructured

func FromStructured(s *StructuredDocument) (*Document, error)

FromStructured checks the schema and converts without discarding unrepresented semantics. Valid ProseMirror constructs outside the current engine return ErrUnsupported; AllowLossy cannot override these errors.

func Read

func Read(ctx context.Context, r io.Reader, format Format, opts ReadOptions) (*Document, error)

func ReadDOCX

func ReadDOCX(ctx context.Context, src io.Reader) (*Document, error)

ReadDOCX reads the final visible view: insertions are included and deletions excluded. Revision history and unsupported presentation are reported explicitly. No relationships cause network or filesystem access.

func ReadPDF

func ReadPDF(ctx context.Context, src io.Reader, opts ReadOptions) (doc *Document, err error)

func ReadPPTX added in v0.3.0

func ReadPPTX(ctx context.Context, input io.Reader) (*Document, error)

ReadPPTX maps a bounded native package to the central, editable SF model.

func ReadVDOCS

func ReadVDOCS(ctx context.Context, r io.Reader) (*Document, error)

func (*Document) Text

func (d *Document) Text() string

Text includes body content and notes. Page boundaries are form-feed characters.

func (*Document) Validate

func (d *Document) Validate() error

type FontFace

type FontFace struct {
	Family       string
	Bold, Italic bool
	Data         []byte
}

type Format

type Format string
const (
	DOCX Format = "docx"
	PPTX Format = "pptx"
	PDF  Format = "pdf"
	JSON Format = "json"
	// SF is versioned ProseMirror JSON, stored with the .sf extension.
	SF Format = "sf"
	// SFGzip is the same ProseMirror JSON in an RFC 1952 gzip stream (.sf.gz).
	SFGzip Format = "sf.gz"
	// VDOCS is the VDOCS version-3 envelope for Univer 1.0.4 snapshots.
	VDOCS Format = "vdocs"
	Text  Format = "txt"
)

func FormatFromName

func FormatFromName(name string) (Format, error)

type Image

type Image struct {
	Data      []byte  `json:"data"` // JSON represents bytes as base64.
	MediaType string  `json:"media_type"`
	Alt       string  `json:"alt,omitempty"`
	Width     float64 `json:"width,omitempty"`
	Height    float64 `json:"height,omitempty"`
	// contains filtered or unexported fields
}

type Kind

type Kind string
const (
	Paragraph       Kind = "paragraph"
	Heading         Kind = "heading"
	Table           Kind = "table"
	ListBlock       Kind = "list"
	Picture         Kind = "image"
	OfficeMathBlock Kind = "office_math"
	PageBreak       Kind = "page_break"
	SectionBlock    Kind = "section"
	AnchorPoint     Kind = "anchor_point"
)

type Layout

type Layout struct {
	Width  float64 `json:"width,omitempty"`
	Height float64 `json:"height,omitempty"`
	Margin float64 `json:"margin,omitempty"`
	// Margins overrides Margin; its zero edges are explicit, including all zero.
	Margins *PageMargins `json:"margins,omitempty"`
	// Distances are page-edge to header top/footer bottom, in points. Nil retains
	// writer defaults; a nonnil zero selects the actual edge.
	HeaderDistance *float64 `json:"header_distance,omitempty"`
	FooterDistance *float64 `json:"footer_distance,omitempty"`
}

Layout dimensions are points, 72 per inch. Zero Width/Height/Margin use A4 and the legacy 54pt fallback. Margins and distance pointers retain explicit zeros.

type ListItem

type ListItem struct {
	// Marker owns an explicit literal label instead of an automatic counter or
	// bullet. Nil selects the list's automatic rule. An empty paragraph represents
	// a deliberately empty label. Marker content is independent of item body text.
	Marker *ListMarker `json:"marker,omitempty"`
	Blocks []Block     `json:"blocks"`
	Source *SourceInfo `json:"source,omitempty"`
}

ListItem owns its ordered blocks, including continuation paragraphs and nested lists.

type ListMarker

type ListMarker struct {
	Blocks []Block     `json:"blocks"`
	Source *SourceInfo `json:"source,omitempty"`
}

ListMarker retains literal visible label content and its independent source owner. It does not define an automatic numbering or restart rule.

type ListNumbering

type ListNumbering struct {
	Level       int      `json:"level"`
	Template    string   `json:"template"`
	Formats     []string `json:"formats"`
	Ancestors   []int    `json:"ancestors,omitempty"`
	Independent bool     `json:"independent,omitempty"`
	Legal       bool     `json:"legal,omitempty"`
}

type Matrix

type Matrix [6]float64

Matrix is [a b c d e f]: x'=a*x+c*y+e, y'=b*x+d*y+f.

type Metadata

type Metadata struct {
	Title     string `json:"title,omitempty"`
	Author    string `json:"author,omitempty"`
	Subject   string `json:"subject,omitempty"`
	PageCount int    `json:"page_count,omitempty"`
}

type Note

type Note struct {

	// BodyLabelContent owns a literal rich body mark. It excludes BodyLabel and
	// BodyLabelStyle; only nonempty text runs are allowed, without nested atoms.
	BodyLabelContent []Run `json:"body_label_content,omitempty"`
	// BodyLabelStyle supplies formatting/navigation for the resolved body mark, without text or atoms.
	BodyLabelStyle *Run `json:"body_label_style,omitempty"`
	// BodyLabel overrides the body mark, independently of citation marks.
	BodyLabel *string `json:"body_label,omitempty"`
	// KindInferred distinguishes an editorial placement choice from an explicit source kind.
	KindInferred bool        `json:"kind_inferred,omitempty"`
	LabelSource  *SourceInfo `json:"label_source,omitempty"`
	Source       *SourceInfo `json:"source,omitempty"`
	// Label is a literal display mark. Empty uses automatic per-kind numbering.
	// Custom labels do not advance the automatic counter.
	Label  string  `json:"label,omitempty"`
	ID     string  `json:"id"`
	Kind   string  `json:"kind"`
	Blocks []Block `json:"blocks"`
	// contains filtered or unexported fields
}

type NoteReference

type NoteReference struct {
	LabelContent []Run `json:"label_content,omitempty"`

	Inferred bool `json:"inferred,omitempty"`

	Label *string `json:"label,omitempty"`
	ID    string  `json:"id"`
	Kind  string  `json:"kind"`
}

type OfficeMath added in v0.4.0

type OfficeMath struct {
	OMML string `json:"omml"`
}

OfficeMath stores native equation structure, not an inferred Unicode formula. PlainText returns source text tokens only; fractions/operators/layout remain in OMML.

func (*OfficeMath) PlainText added in v0.4.0

func (m *OfficeMath) PlainText() string

type PDFArtifact

type PDFArtifact struct {
	ID       string      `json:"id"`
	Stream   string      `json:"stream"`
	Type     string      `json:"type,omitempty"`
	Subtype  string      `json:"subtype,omitempty"`
	BBox     *[4]float64 `json:"bbox,omitempty"`
	Matrix   Matrix      `json:"matrix"`
	Bounds   *Quad       `json:"bounds,omitempty"`
	Attached []string    `json:"attached,omitempty"`
}

type PDFDestination

type PDFDestination struct {
	ID         string     `json:"id"`
	NameKind   string     `json:"name_kind,omitempty"`
	NameBytes  []byte     `json:"name_bytes,omitempty"`
	Page       int        `json:"page,omitempty"`
	PageObject string     `json:"page_object,omitempty"`
	View       string     `json:"view,omitempty"`
	Parameters []*float64 `json:"parameters,omitempty"`
	Point      *Point     `json:"point,omitempty"`
	Region     *Quad      `json:"region,omitempty"`
	Unresolved bool       `json:"unresolved,omitempty"`

	FlowBinding string `json:"flow_binding,omitempty"`
	FlowOrder   int    `json:"flow_order,omitempty"`
}

type PDFNavigation

type PDFNavigation struct {
	Destinations []PDFDestination    `json:"destinations,omitempty"`
	Links        []PDFNavigationLink `json:"links,omitempty"`
}
type PDFNavigationLink struct {
	Kind        string `json:"kind"`
	Page        int    `json:"page"`
	Object      string `json:"object"`
	URI         string `json:"uri,omitempty"`
	Destination string `json:"destination,omitempty"`
	Regions     []Quad `json:"regions"`
}

type PDFPage

type PDFPage struct {
	Artifacts []PDFArtifact `json:"artifacts,omitempty"`
	Number    int           `json:"number"`
	MediaBox  [4]float64    `json:"media_box"`
	CropBox   [4]float64    `json:"crop_box"`
	Rotate    int           `json:"rotate"`
	UserUnit  float64       `json:"user_unit"`
	Width     float64       `json:"width"`
	Height    float64       `json:"height"`
	Transform Matrix        `json:"transform"`
}

PDFPage records physical page boundaries even when a logical tagged paragraph spans pages. Boxes retain PDF user units; Width/Height and source quads use pt.

type PDFReadLimits added in v0.4.0

type PDFReadLimits struct {
	MaxDecodedBytes      int   `json:"max_decoded_bytes,omitempty"`
	MaxRasterPixels      int64 `json:"max_raster_pixels,omitempty"`
	MaxNavigationEntries int   `json:"max_navigation_entries,omitempty"`
	MaxStructureEntries  int   `json:"max_structure_entries,omitempty"`
	MaxParentTreeSlots   int   `json:"max_parent_tree_slots,omitempty"`
}

PDFReadLimits bounds aggregate work for a single import. Zero fields use the conservative defaults; increasing one requires explicit caller resource policy. Per-stream, per-image, recursion and model validation bounds still apply.

type PageMargins

type PageMargins struct {
	Top    float64 `json:"top"`
	Right  float64 `json:"right"`
	Bottom float64 `json:"bottom"`
	Left   float64 `json:"left"`
}

type Point

type Point struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Point is in physical points in displayed page coordinates: top-left origin, x right and y down. PDFPage.Transform maps original PDF user coordinates here.

type Presentation added in v0.3.0

type Presentation struct {
	Version     int                    `json:"version"`
	Width       float64                `json:"width"`
	Height      float64                `json:"height"`
	Slides      []PresentationSlide    `json:"slides"`
	Resources   []PresentationResource `json:"resources,omitempty"`
	SourceParts map[string][]byte      `json:"source_parts,omitempty"`
}

Presentation is the positioned-slide extension of the shared document model. SourceParts preserve native package features; authored content lives in Slides and Resources and takes precedence when a supported object is edited.

type PresentationResource added in v0.3.0

type PresentationResource struct {
	Part        string        `json:"part"`
	Kind        string        `json:"kind"`
	MasterPart  string        `json:"master_part,omitempty"`
	Background  string        `json:"background,omitempty"`
	Objects     []SlideObject `json:"objects,omitempty"`
	Unsupported []string      `json:"unsupported,omitempty"`
}

type PresentationSlide added in v0.3.0

type PresentationSlide struct {
	Hidden      bool          `json:"hidden,omitempty"`
	ID          string        `json:"id"`
	Part        string        `json:"part,omitempty"`
	LayoutPart  string        `json:"layout_part,omitempty"`
	MasterPart  string        `json:"master_part,omitempty"`
	Width       float64       `json:"width,omitempty"`
	Height      float64       `json:"height,omitempty"`
	Background  string        `json:"background,omitempty"`
	Objects     []SlideObject `json:"objects,omitempty"`
	Notes       []Block       `json:"notes,omitempty"`
	Unsupported []string      `json:"unsupported,omitempty"`
}

type Quad

type Quad [4]Point

type ReadOptions

type ReadOptions struct {
	PDFLimits *PDFReadLimits
	Password  string
	// PDFSkipInference retains untagged PDF paint order and baseline groups for
	// callers inspecting physical extraction. Tagged logical trees still apply.
	// The default recovers geometric structure with disclosed uncertainty.
	PDFSkipInference bool
	// PDFSkipStructure ignores the logical tree and retains positioned content.
	// Combine with PDFSkipInference for a physical paint-order inspection.
	PDFSkipStructure bool
}

type Row

type Row struct {
	// RepeatHeader repeats a contiguous prefix of rows on table continuation pages.
	// It is a pagination property, separate from semantic header-cell roles.
	RepeatHeader bool   `json:"repeat_header,omitempty"`
	Cells        []Cell `json:"cells"`
}

type Run

type Run struct {
	// Language tags preserve the general, East Asian and complex-script bindings.
	Language         string `json:"language,omitempty"`
	EastAsiaLanguage string `json:"east_asia_language,omitempty"`
	ComplexLanguage  string `json:"complex_language,omitempty"`
	// ComplexScript forces complex-script formatting/language selection (OOXML cs).
	ComplexScript bool `json:"complex_script,omitempty"`
	// Direction enables/disables RTL run characteristics, independently of
	// paragraph flow. Empty is unspecified; ltr does not override strong RTL text.
	Direction string `json:"direction,omitempty"`

	// Empty family/color and zero size use the renderer default. Sizes are points.
	FontFamily string  `json:"font_family,omitempty"`
	FontSize   float64 `json:"font_size,omitempty"`
	Color      string  `json:"color,omitempty"` // #RRGGBB or auto

	Text      string `json:"text"`
	Bold      bool   `json:"bold,omitempty"`
	Italic    bool   `json:"italic,omitempty"`
	Underline bool   `json:"underline,omitempty"`
	Strike    bool   `json:"strike,omitempty"`
	Link      string `json:"link,omitempty"`
	// Destination is an internal name, separate from generic URI Link references.
	Destination string `json:"destination,omitempty"`
	// Anchor declares a zero-width named navigation point between text runs.
	Anchor string         `json:"anchor,omitempty"`
	Note   *NoteReference `json:"note,omitempty"`
	Source *SourceInfo    `json:"source,omitempty"`
	// contains filtered or unexported fields
}

type RunningStories

type RunningStories struct {
	Default *RunningStory `json:"default,omitempty"`
	First   *RunningStory `json:"first,omitempty"`
	Even    *RunningStory `json:"even,omitempty"`
}

type RunningStory

type RunningStory struct {
	Blocks []Block `json:"blocks"`
}

type Section

type Section struct {
	Layout    *Layout        `json:"layout,omitempty"`
	Start     SectionStart   `json:"start,omitempty"`
	FirstPage bool           `json:"first_page,omitempty"`
	Headers   RunningStories `json:"headers"`
	Footers   RunningStories `json:"footers"`
	Blocks    []Block        `json:"blocks"`
}

type SectionStart

type SectionStart string
const (
	SectionNextPage   SectionStart = "nextPage"
	SectionContinuous SectionStart = "continuous"
	SectionEvenPage   SectionStart = "evenPage"
	SectionOddPage    SectionStart = "oddPage"
)

type SlideObject added in v0.3.0

type SlideObject struct {
	Hidden           bool          `json:"hidden,omitempty"`
	Insets           *PageMargins  `json:"insets,omitempty"`
	ParagraphAlign   []string      `json:"paragraph_align,omitempty"`
	VerticalAlign    string        `json:"vertical_align,omitempty"`
	NoWrap           bool          `json:"no_wrap,omitempty"`
	ID               string        `json:"id"`
	Kind             string        `json:"kind"` // shape, image, group, native
	Name             string        `json:"name,omitempty"`
	X                float64       `json:"x"`
	Y                float64       `json:"y"`
	Width            float64       `json:"width"`
	Height           float64       `json:"height"`
	Rotation         float64       `json:"rotation,omitempty"` // clockwise degrees
	FlipH            bool          `json:"flip_h,omitempty"`
	FlipV            bool          `json:"flip_v,omitempty"`
	Geometry         string        `json:"geometry,omitempty"` // rect, ellipse, line, roundRect
	Fill             string        `json:"fill,omitempty"`     // #RRGGBB, empty means none
	Stroke           string        `json:"stroke,omitempty"`
	StrokeWidth      float64       `json:"stroke_width,omitempty"`
	Placeholder      string        `json:"placeholder,omitempty"`
	PlaceholderIndex string        `json:"placeholder_index,omitempty"`
	Content          []Block       `json:"content,omitempty"`
	Image            *Image        `json:"image,omitempty"`
	Children         []SlideObject `json:"children,omitempty"`
	Unsupported      []string      `json:"unsupported,omitempty"`
}

type SourceElementReference

type SourceElementReference struct {
	Row     int    `json:"row"` // zero-based row in the explicit table
	Element string `json:"element"`
	Role    string `json:"role"`
	Tag     string `json:"tag"`
	Page    int    `json:"page,omitempty"`
}

SourceElementReference retains an explicit logical cell that was an empty continuation of a geometrically recovered merged cell.

type SourceInfo

type SourceInfo struct {
	// Historical means the original source facts no longer assert correspondence to current edited content.
	Historical bool `json:"historical,omitempty"`
	// ParentElement records explicit source-tree containment, not a note reference.
	ParentElement string `json:"parent_element,omitempty"`
	// References retains explicit PDF structure Ref edges, including unresolved targets.
	StructureID        []byte                     `json:"structure_id,omitempty"` // original PDF ID bytes, not a Unicode text string
	References         []SourceStructureReference `json:"references,omitempty"`
	Artifacts          []string                   `json:"artifacts,omitempty"`
	Format             Format                     `json:"format"`
	Page               int                        `json:"page,omitempty"`
	Object             string                     `json:"object,omitempty"`
	Stream             string                     `json:"stream,omitempty"`
	Role               string                     `json:"role,omitempty"`
	Element            string                     `json:"element,omitempty"`
	Order              int                        `json:"order,omitempty"`
	Quad               *Quad                      `json:"quad,omitempty"`
	Baseline           *[2]Point                  `json:"baseline,omitempty"`
	Matrix             *Matrix                    `json:"matrix,omitempty"`
	Regions            []SourceRegion             `json:"regions,omitempty"`
	Font               string                     `json:"font,omitempty"`
	FontFamilyEvidence string                     `json:"font_family_evidence,omitempty"`
	ColorSpace         string                     `json:"color_space,omitempty"`
	ColorComponents    []float64                  `json:"color_components,omitempty"`
	FontSize           float64                    `json:"font_size,omitempty"`
	MCID               *int                       `json:"mcid,omitempty"`
	Tag                string                     `json:"tag,omitempty"`
	Structure          string                     `json:"structure"` // explicit, inferred or unstructured
	Evidence           string                     `json:"evidence"`
	Confidence         float64                    `json:"confidence"`
	Precision          string                     `json:"precision,omitempty"`
	Label              string                     `json:"label,omitempty"`
	RenderMode         int                        `json:"render_mode,omitempty"`
	TableWidths        *TableWidthSource          `json:"table_widths,omitempty"`
	TableSpans         *TableSpanSource           `json:"table_spans,omitempty"`
}

SourceInfo records provenance, not an alternative copy of content. Quads use advance/font metrics, not glyph ink outlines. Precision discloses estimates. Confidence is a heuristic ranking, not a calibrated probability.

type SourceRegion

type SourceRegion struct {
	Page int  `json:"page"`
	Quad Quad `json:"quad"`
}

type SourceStructureReference

type SourceStructureReference struct {
	Element string   `json:"element,omitempty"`
	Targets []string `json:"targets"`
}

SourceStructureReference identifies the explicit owner and targets of a PDF structure Ref entry. Aggregate source bounds retain contributing edges too.

type StructuredAttributes

type StructuredAttributes struct {
	Presentation           *StructuredPresentation `json:"presentation,omitempty"`
	UnboundSources         []SourceInfo            `json:"unboundSources,omitempty"`
	PDFNavigation          *PDFNavigation          `json:"pdfNavigation,omitempty"`
	Schema                 string                  `json:"schema"`
	Metadata               Metadata                `json:"metadata,omitempty"`
	Layout                 Layout                  `json:"layout,omitempty"`
	Headers                []StructuredNode        `json:"headers,omitempty"`
	Footers                []StructuredNode        `json:"footers,omitempty"`
	Notes                  []StructuredNote        `json:"notes,omitempty"`
	Diagnostics            []Diagnostic            `json:"diagnostics,omitempty"`
	Pages                  []PDFPage               `json:"pages,omitempty"`
	EvenAndOddHeaders      bool                    `json:"evenAndOddHeaders,omitempty"`
	UnresolvedDestinations []string                `json:"unresolvedDestinations,omitempty"`
}

type StructuredDocument

type StructuredDocument struct {
	Type    string               `json:"type"`
	Attrs   StructuredAttributes `json:"attrs"`
	Content []StructuredNode     `json:"content,omitempty"`
}

StructuredDocument is a ProseMirror document using the versioned schema in docs/reference/STRUCTURED_FORMAT.md. It needs no JavaScript or ProseMirror runtime.

func ReadStructured

func ReadStructured(ctx context.Context, r io.Reader) (*StructuredDocument, error)

ReadStructured reads and validates the supported ProseMirror schema.

func ToStructured

func ToStructured(d *Document) (*StructuredDocument, error)

ToStructured maps the declared Document semantics to ProseMirror JSON. Empty text runs and the equivalent zero/one column spans are normalized.

type StructuredMark

type StructuredMark struct {
	Type  string          `json:"type"`
	Attrs json.RawMessage `json:"attrs,omitempty"`
}

type StructuredNode

type StructuredNode struct {
	Type    string           `json:"type"`
	Attrs   json.RawMessage  `json:"attrs,omitempty"`
	Content []StructuredNode `json:"content,omitempty"`
	Marks   []StructuredMark `json:"marks,omitempty"`
	Text    string           `json:"text,omitempty"`
}

Attrs contains the attributes defined for this node type, encoded as an object. Unknown nodes, marks and attributes are rejected, never silently flattened.

type StructuredNote

type StructuredNote struct {
	BodyLabelContent []StructuredNode  `json:"body_label_content,omitempty"`
	BodyLabelMarks   *[]StructuredMark `json:"body_label_marks,omitempty"`
	BodyLabel        *string           `json:"body_label,omitempty"`
	LabelSource      *SourceInfo       `json:"label_source,omitempty"`
	KindInferred     bool              `json:"kind_inferred,omitempty"`
	Source           *SourceInfo       `json:"source,omitempty"`
	Label            string            `json:"label,omitempty"`
	ID               string            `json:"id"`
	Kind             string            `json:"kind"`
	Content          []StructuredNode  `json:"content"`
}

type StructuredPresentation added in v0.3.0

type StructuredPresentation struct {
	Version     int                       `json:"version"`
	Width       float64                   `json:"width"`
	Height      float64                   `json:"height"`
	Slides      []StructuredSlide         `json:"slides"`
	Resources   []StructuredSlideResource `json:"resources,omitempty"`
	SourceParts map[string][]byte         `json:"source_parts,omitempty"`
}

type StructuredSlide added in v0.3.0

type StructuredSlide struct {
	Attrs   PresentationSlide       `json:"attrs"`
	Objects []StructuredSlideObject `json:"objects,omitempty"`
	Notes   []StructuredNode        `json:"notes,omitempty"`
}

type StructuredSlideObject added in v0.3.0

type StructuredSlideObject struct {
	Attrs    SlideObject             `json:"attrs"`
	Content  []StructuredNode        `json:"content,omitempty"`
	Children []StructuredSlideObject `json:"children,omitempty"`
}

type StructuredSlideResource added in v0.3.0

type StructuredSlideResource struct {
	Attrs   PresentationResource    `json:"attrs"`
	Objects []StructuredSlideObject `json:"objects,omitempty"`
}

type TableSpanSource

type TableSpanSource struct {
	ColSpan       string                   `json:"colspan"`
	RowSpan       string                   `json:"rowspan"`
	Evidence      string                   `json:"evidence"`
	Confidence    float64                  `json:"confidence"`
	Bounds        Quad                     `json:"bounds"`
	Continuations []SourceElementReference `json:"continuations,omitempty"`
}

TableSpanSource separates explicit logical membership from recovered spans. ColSpan and RowSpan are "explicit" or "inferred". Bounds records the painted cell boundary; SourceInfo.Quad continues to record its content bounds.

type TableWidthSource

type TableWidthSource struct {
	Evidence   string  `json:"evidence"`
	Confidence float64 `json:"confidence"`
	Bounds     Quad    `json:"bounds"`
}

TableWidthSource records measured painted-grid widths independently from explicit PDF logical table membership. Confidence is not a probability.

type WriteOptions

type WriteOptions struct {
	// AllowLossy acknowledges import/reflow diagnostics and documented output
	// normalizations, including DOCX half-point font-size rounding with checked
	// original intent. Unsupported writer features still return errors.
	AllowLossy bool
	// PDFFonts supplies in-memory TTF faces; missing families/styles never substitute.
	PDFFonts []FontFace
	// PDFFontMap explicitly maps requested families to supplied/built-in families.
	PDFFontMap map[string]string
}

Jump to

Keyboard shortcuts

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