Skip to content

Modules

Modules

The 10 modules of go-richdoc. Each links to its source and to its generated API reference.

ModuleWhat it isDirectionsReference
richdocthe model itself: the tree, and Walk, Clone, PlainText and a builder—pkg.go.dev
markdownCommonMark + GFM tables and strikethrough, delegating the parse to goldmarkread, writepkg.go.dev
latexa practical subset of LaTeX, plus a PDF subpackageread, writepkg.go.dev
rstreStructuredText, delegating the parse to go-docutils/docutilsread, writepkg.go.dev
dataCSV, JSON, XML and plain text, plus the richdata commandreadpkg.go.dev
fb2FictionBook 2 (.fb2): one XML file, images base64 inside itreadpkg.go.dev
htmlHTML and XHTML, delegating the parse to golang.org/x/net/htmlreadpkg.go.dev
epubEPUB 2 and 3: the ZIP, the manifest and the spine, chapters through htmlreadpkg.go.dev
emailRFC 5322 messages and MIME, HTML parts through htmlreadpkg.go.dev
mobiKindle MOBI: a Palm database, a PalmDOC stream and one HTML document, through htmlreadpkg.go.dev

Which directions a module has is in the table, because “converter” said of a one-way reader is the kind of claim that costs somebody an afternoon. A module that only reads is not unfinished: a .fb2, an EPUB, a mailbox or a .csv is a source, and writing one back is a job nobody has asked for.

⛔ One missing reader was three missing formats

html is not a format anybody asked this organisation for. It is the piece epub and email both needed — EPUB’s content documents are XHTML and an HTML mail’s body is HTML — and mobi needed it as well: a MOBI’s text IS one HTML document, cut into 4096-byte pieces and each piece compressed on its own. Three entries on go-pdfkit’s parity table were blocked on one reader, which is the argument for naming a gap rather than working around it: all three are closed now, and the third is mobi.

⛔ And the shared reader is where the next defect was

Reading a real Kindle book is also what found go-richdoc/html#4: a space following an inline element is dropped, so <i>Walt Whitman</i> has comes out as one word. It had been there all along, under epub and email too — any paragraph with an <i>, a <b>, a <span> or a link loses a space at every one of those boundaries.

What made it visible was a second rendering of the same text: Project Gutenberg publishes a MOBI and a plain text of every title it has, and 125 816 words against 126 630 is a question a reader cannot ask of its own output. A shared reader multiplies a defect by its callers, which is the same property that made it worth writing once.

A one-line summary each, and nothing more: what a converter does with a construct its format cannot express lives in that repository’s README, beside the measurement that decided it, so there is one place to correct when it changes.