model

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contents

type Contents struct {
	Content []Text `json:"content"`
}

Contents models the contents of a Paragraph, Blockquote, List Item, or Table Cell.

func (*Contents) AddContent

func (c *Contents) AddContent(text ...Text)

AddContent to a Contents.

func (*Contents) AddStr

func (c *Contents) AddStr(str string)

AddStr adds a string with no styles to Contents.

func (Contents) AllContent

func (c Contents) AllContent() []string

AllContent returns the values of all Text.Text contained in Contents.

func (Contents) JoinContent added in v0.0.5

func (c Contents) JoinContent() string

JoinContent returns the values of all Text.Text contained in Contents.

type ListContent

type ListContent struct {
	Items   []ListItem `json:"items"`
	Ordered bool       `json:"ordered"`
}

ListContent is an array of ListItems.

func (*ListContent) AddItems

func (ls *ListContent) AddItems(listItem ...ListItem)

AddItems appends ListItems to a List's Items.

func (*ListContent) NewItem added in v0.0.4

func (ls *ListContent) NewItem(texts ...Text)

NewItem creates a new ListItem whose contents are comprised of the given Text arguments and adds that ListItem to a List's Items.

type ListItem

type ListItem struct {
	Contents `json:"contents"`
	Children ListContent `json:"children"`
}

ListItem is a single list bullet, and may contain a nested list.

func (ListItem) HasChildren

func (li ListItem) HasChildren() bool

HasChildren returns true if a ListItem contains a nested list.

type TableContent

type TableContent struct {
	Rows       [][]Contents `json:"rows"`
	Alignments []string     `json:"alignments"` // "L", "C", or "R"
}

TableContent represents the contents of a table element.

func (*TableContent) AddRows

func (tc *TableContent) AddRows(cols ...[]Contents)

AddRows to TableContent.

func (TableContent) Body

func (tc TableContent) Body() [][]Contents

Body returns all rows after the first.

func (TableContent) ColCount

func (tc TableContent) ColCount() int

ColCount returns the number of header columns.

func (TableContent) GetColumn

func (tc TableContent) GetColumn(index int) []Contents

GetColumn returns one string for every cell in a column at the given index. First column is 0, not 1.

func (TableContent) Headers

func (tc TableContent) Headers() []Contents

Headers returns the first slice of string in Rows.

func (TableContent) Widths

func (tc TableContent) Widths(pdf *gofpdf.Fpdf, cellMargin float64) []float64

Widths returns the width needed to hold the longest cell in each column.

func (TableContent) WidthsAlt added in v0.0.5

func (tc TableContent) WidthsAlt(pdf *gofpdf.Fpdf, cellMargin float64) []float64

WidthsAlt is an older version of Widths. Still trying to figure out the best way to implement this.

type Text

type Text struct {
	Text   string `json:"text"`
	Bold   bool   `json:"bold"`
	Italic bool   `json:"italic"`
	Code   bool   `json:"code"`
	Strike bool   `json:"strike"`
	HREF   string `json:"href"`
}

Text models text strings that make up a Paragraph, Blockquote, List Item, or Table Cell.

func (Text) Copy

func (txt Text) Copy() Text

Copy returns a new Text struct with the same values as the Text it was called from. Except the Content field, that's empty.

Jump to

Keyboard shortcuts

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