Documentation
¶
Overview ¶
Package textfmt can be used to format structured data into plain text for terminal, roff, markdown or HTML.
Index ¶
- func HTML(out io.Writer, doc Document, lang string) error
- func HTMLFragment(out io.Writer, doc Document) error
- func Markdown(out io.Writer, d Document) error
- func Runoff(out io.Writer, d Document) error
- func Teletype(out io.Writer, d Document) error
- type DefinitionItem
- type Document
- type Entry
- func CodeBlock(codeBlock string) Entry
- func DefinitionList(items ...DefinitionItem) Entry
- func Indent(e Entry, indent, indentFirst int) Entry
- func List(items ...ListItem) Entry
- func NumberedDefinitionList(items ...DefinitionItem) Entry
- func NumberedList(items ...ListItem) Entry
- func Paragraph(t Txt) Entry
- func Syntax(items ...SyntaxItem) Entry
- func Table(rows ...TableRow) Entry
- func Title(level int, text string, manInfo ...TitleInfo) Entry
- func Wrap(e Entry, width int) Entry
- type ItemStyle
- type ListItem
- type SyntaxItem
- type TableCell
- type TableRow
- type TitleInfo
- type Txt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTML ¶
HTML renders the input document as an HTML document. If the lang attribute is empty, it will be omitted from the html element.
func HTMLFragment ¶
HTMLFragment renders the input document as HTML fragments, without html and body tags.
func Markdown ¶
Markdown can be used to render the input document in basic markdown format. The only not entirely standard output feature is the support for tables.
func Runoff ¶
Runoff is an attempt to render roff format. It is primarily targeting man pages. While it may be possible to use for other purposes, the man macro will likely be required to render the output.
Text is always wrapped, or as controlled by the roff processor, except for tables. The Wrap instrunction has no effect, except for tables.
Types ¶
type DefinitionItem ¶
type DefinitionItem struct {
// contains filtered or unexported fields
}
func Definition ¶
func Definition(name, value Txt, style ...ItemStyle) DefinitionItem
Definition creates a definition list item for bulleted or numbered definition lists. Item style may behave different depending ont the output format.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
func DefinitionList ¶
func DefinitionList(items ...DefinitionItem) Entry
func Indent ¶
Indent can be used to control indentation. Indentation may behave different depending on the output format. The indent parameter sets the indentation in spaces for a section. The indentFirst parameter sets the indentation for the first line in the section and it is relative to the indent parameter.
func NumberedDefinitionList ¶
func NumberedDefinitionList(items ...DefinitionItem) Entry
func NumberedList ¶
func Syntax ¶
func Syntax(items ...SyntaxItem) Entry
func Title ¶
Title can be used for document titles or subtitles. Titles with different levels behave differently with the different output formats. TTY output does prints every level the same way. HTML and markdown titles utilize the level info from 0 to 5, where 0 will mean H1. In case of Roff, if the level is 0 and the ManSection is set, the output will be in manpage title format, expecting the man macro to be used when processing the roff output.
type SyntaxItem ¶
type SyntaxItem struct {
// contains filtered or unexported fields
}
func Choice ¶
func Choice(items ...SyntaxItem) SyntaxItem
func OneOrMore ¶
func OneOrMore(item SyntaxItem) SyntaxItem
func Optional ¶
func Optional(item SyntaxItem) SyntaxItem
func Required ¶
func Required(item SyntaxItem) SyntaxItem
func Sequence ¶
func Sequence(items ...SyntaxItem) SyntaxItem
func Symbol ¶
func Symbol(text string) SyntaxItem
func ZeroOrMore ¶
func ZeroOrMore(item SyntaxItem) SyntaxItem
type TitleInfo ¶
type TitleInfo struct {
// contains filtered or unexported fields
}