markdownbdf

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package markdownbdf writes a document as Markdown: the structure its MARKs carry (headings, paragraphs, lists, tables, figures with their alternative texts; docs/spec.md §7.8) as the blocks of GitHub Flavored Markdown, the fonts of its runs as emphasis and code, its LINKs as links and its images as files beside the text.

The text is the document's in plain text: a document that was encrypted should not have it written where the password does not protect it.

Index

Constants

View Source
const DefaultInlineRows = 100

DefaultInlineRows is the rows of a table written inline when Options.InlineRows is 0.

Variables

DefaultSkipRoles are the roles of the layers that are not the content of a page: what is under it and around it on every page.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Views are the ids of the views to write. By default the scroll views
	// are written when the document has one (the same text laid out
	// without pages: Word, HTML, Markdown and EPUB documents), else every
	// view.
	Views []string
	// SkipRoles are the roles of the layers that are left out. Nil leaves
	// out DefaultSkipRoles: what is around the content on every page.
	SkipRoles []string
	// InternalLinks keeps the links into the document itself (#page=N),
	// which have no target in the Markdown. By default their text stands
	// alone.
	InternalLinks bool
	// KeepRunning keeps the running heads and feet of the pages of a
	// paged view: the short text at the same place in the top or bottom
	// margin of two pages or more (a journal's name, a paper's title, a
	// notice; the digits of "Page 3 of 9" aside), and page numbers alone
	// there. By default they are left out, as the header and footer
	// layers of a Word document are.
	KeepRunning bool
	// Image is called once for each image the Markdown refers to, with a
	// file name made of the hash of its part and its format (the same
	// image is one file), and the bytes of the part. It returns the path
	// the Markdown refers to the image by: the name, when the images are
	// written beside the text. Nil leaves the images out, and a figure
	// keeps its alternative text.
	Image func(name string, data []byte) (string, error)
	// Tables says how the tables the document holds beside its drawing
	// (docs/spec.md §4.6; the data of charts) are written: "inline" (the
	// default: a table of the figure's data after its text, up to
	// InlineRows rows, and the whole as a CSV file beside the text when
	// there are more and File is set), "files" (as CSV files only, linked
	// from the figure; the tables of sheets too) or "none".
	Tables string
	// InlineRows is the most rows of a table written inline (100 when 0).
	InlineRows int
	// File is called for each CSV file of a table, as Image is for images.
	// Nil writes no files: a table of more rows than InlineRows is cut.
	File func(name string, data []byte) (string, error)
}

Options say what to write and how.

type Result

type Result struct {
	Views    int
	Images   int
	Tables   int // the tables written, inline or as files
	Warnings []string
}

Result tells what was written.

func Write

func Write(w io.Writer, doc *bdf.Document, opts *Options) (*Result, error)

Write writes the document as Markdown.

func WriteDir

func WriteDir(dir, name string, doc *bdf.Document, opts *Options) (*Result, error)

WriteDir writes the document as dir/name.md, with its images beside it (the directory is made when it is missing). opts.Image is replaced.

Jump to

Keyboard shortcuts

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