htmlike

package
v0.0.0-...-fa0cb27 Latest Latest
Warning

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

Go to latest
Published: May 25, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BR

type BR struct {
	Align HtmLikeAlign
}

BR represents a <BR/> element.

func NewBR

func NewBR(align ...HtmLikeAlign) *BR

NewBR creates a new BR element.

func (*BR) SetAlign

func (b *BR) SetAlign(v HtmLikeAlign) *BR

SetAlign sets the align attribute for the BR element.

func (*BR) WriteDOT

func (b *BR) WriteDOT(w io.Writer) error

WriteDOT writes the <BR/> element to the writer.

type FONT

type FONT struct {
	Color     string
	Face      string
	PointSize *int // Max 65535 apparently for POINT-SIZE as int? Spec says "value". Let's assume int for now.

	Children []HtmLikeElement // Can contain Text, BR, IMG, style tags, other FONT, or even TABLES/TRs/TDs
}

FONT represents a <FONT> element.

func NewFONT

func NewFONT(children ...HtmLikeElement) *FONT

NewFONT creates a new FONT element.

func (*FONT) AppendChildren

func (f *FONT) AppendChildren(children ...HtmLikeElement) *FONT

AppendChildren adds children to the font element.

func (*FONT) SetColor

func (f *FONT) SetColor(v string) *FONT

Setters for fluent API

func (*FONT) SetFace

func (f *FONT) SetFace(v string) *FONT

func (*FONT) SetPointSize

func (f *FONT) SetPointSize(v int) *FONT

func (*FONT) WriteDOT

func (f *FONT) WriteDOT(w io.Writer) error

WriteDOT writes the <FONT> element and its children to the writer.

type HtmLike

type HtmLike struct {
	Elements []HtmLikeElement
}

HtmLike represents a Graphviz HTML-like label, enclosed in <...>. It can contain one or more HtmLikeElement children. Typically, the root element is a *Table.

func NewHtmLike

func NewHtmLike(elements ...HtmLikeElement) *HtmLike

NewHtmLike creates a new HtmLike label with the given root elements.

func (*HtmLike) AppendElements

func (h *HtmLike) AppendElements(elements ...HtmLikeElement) *HtmLike

AppendElements adds root elements to the HtmLike label.

func (*HtmLike) String

func (h *HtmLike) String() string

String generates the Graphviz HTML-like label string representation (<...>)

type HtmLikeAlign

type HtmLikeAlign string
const (
	AlignCENTER HtmLikeAlign = "CENTER"
	AlignLEFT   HtmLikeAlign = "LEFT"
	AlignRIGHT  HtmLikeAlign = "RIGHT"
	AlignTEXT   HtmLikeAlign = "TEXT" // TD only
)

type HtmLikeElement

type HtmLikeElement interface {
	WriteDOT(w io.Writer) error
}

HtmLikeElement is an interface for any element that can be part of an HTML-like label.

type HtmLikeImgScale

type HtmLikeImgScale string
const (
	ScaleFALSE  HtmLikeImgScale = "FALSE"
	ScaleTRUE   HtmLikeImgScale = "TRUE"
	ScaleWIDTH  HtmLikeImgScale = "WIDTH"
	ScaleHEIGHT HtmLikeImgScale = "HEIGHT"
	ScaleBOTH   HtmLikeImgScale = "BOTH"
)

type HtmLikeValign

type HtmLikeValign string
const (
	ValignMIDDLE HtmLikeValign = "MIDDLE"
	ValignBOTTOM HtmLikeValign = "BOTTOM"
	ValignTOP    HtmLikeValign = "TOP"
)

type IMG

type IMG struct {
	Scale HtmLikeImgScale
	Src   string
}

IMG represents an <IMG/> element.

func NewIMG

func NewIMG(src string) *IMG

NewIMG creates a new IMG element.

func (*IMG) SetScale

func (img *IMG) SetScale(v HtmLikeImgScale) *IMG

Setters for fluent API

func (*IMG) SetSrc

func (img *IMG) SetSrc(v string) *IMG

func (*IMG) WriteDOT

func (img *IMG) WriteDOT(w io.Writer) error

WriteDOT writes the <IMG/> element to the writer.

type RuleElement

type RuleElement struct {
	Tag string
}

Horizontal and Vertical Rules (HR, VR)

func NewHR

func NewHR() *RuleElement

NewHR creates an <HR/> element.

func NewVR

func NewVR() *RuleElement

NewVR creates a <VR/> element.

func (*RuleElement) WriteDOT

func (r *RuleElement) WriteDOT(w io.Writer) error

WriteDOT writes the rule element to the writer.

type StyleElement

type StyleElement struct {
	Tag      string
	Children []HtmLikeElement
}

Style elements (B, I, U, O, SUB, SUP, S)

func NewB

func NewB(children ...HtmLikeElement) *StyleElement

NewB creates a <B> element.

func NewI

func NewI(children ...HtmLikeElement) *StyleElement

NewI creates an <I> element.

func NewO

func NewO(children ...HtmLikeElement) *StyleElement

NewO creates an <O> element.

func NewS

func NewS(children ...HtmLikeElement) *StyleElement

NewS creates an <S> element.

func NewSUB

func NewSUB(children ...HtmLikeElement) *StyleElement

NewSUB creates a <SUB> element.

func NewSUP

func NewSUP(children ...HtmLikeElement) *StyleElement

NewSUP creates a <SUP> element.

func NewU

func NewU(children ...HtmLikeElement) *StyleElement

NewU creates a <U> element.

func (*StyleElement) AppendChildren

func (s *StyleElement) AppendChildren(children ...HtmLikeElement) *StyleElement

AppendChildren adds children to the style element.

func (*StyleElement) WriteDOT

func (s *StyleElement) WriteDOT(w io.Writer) error

WriteDOT writes the style element and its children to the writer.

type TD

type TD struct {
	Align         HtmLikeAlign // Can also be TEXT
	BAlign        HtmLikeAlign // Default ALIGN for child BRs
	BGColor       string
	Border        *uint // Max 255
	CellPadding   *uint // Max 255
	CellSpacing   *uint // Max 127 (Note: TD doesn't have CellSpacing in spec? Maybe inherited?)
	Color         string
	Colspan       *uint // Max 65535
	FixedSize     *bool
	GradientAngle *int
	Height        *uint // Max 65535
	HREF          string
	ID            string
	Port          string
	Rowspan       *uint  // Max 65535
	Sides         string // e.g., "LT", "B", "LRTB"
	Style         string // Only "RADIAL" currently
	Target        string
	Title         string // Alias for TOOLTIP
	Tooltip       string
	Valign        HtmLikeValign
	Width         *uint // Max 65535

	Children []HtmLikeElement // Can contain anything a label can contain (Text, <TABLE>, <FONT>, <BR>, <IMG>, style tags)
}

TD represents a <TD> element.

func NewTD

func NewTD(children ...HtmLikeElement) *TD

NewTD creates a new TD element.

func (*TD) AppendChildren

func (td *TD) AppendChildren(children ...HtmLikeElement) *TD

AppendChildren adds children to the table cell.

func (*TD) SetAlign

func (td *TD) SetAlign(v HtmLikeAlign) *TD

Setters for fluent API

func (*TD) SetBAlign

func (td *TD) SetBAlign(v HtmLikeAlign) *TD

func (*TD) SetBGColor

func (td *TD) SetBGColor(v string) *TD

func (*TD) SetBorder

func (td *TD) SetBorder(v uint) *TD

func (*TD) SetCellPadding

func (td *TD) SetCellPadding(v uint) *TD

func (*TD) SetColor

func (td *TD) SetColor(v string) *TD

SetCellSpacing seems incorrect based on spec, TD doesn't have it. func (td *TD) SetCellSpacing(v uint) *TD { td.CellSpacing = &v; return td }

func (*TD) SetColspan

func (td *TD) SetColspan(v uint) *TD

func (*TD) SetFixedSize

func (td *TD) SetFixedSize(v bool) *TD

func (*TD) SetGradientAngle

func (td *TD) SetGradientAngle(v int) *TD

func (*TD) SetHREF

func (td *TD) SetHREF(v string) *TD

func (*TD) SetHeight

func (td *TD) SetHeight(v uint) *TD

func (*TD) SetID

func (td *TD) SetID(v string) *TD

func (*TD) SetPort

func (td *TD) SetPort(v string) *TD

func (*TD) SetRowspan

func (td *TD) SetRowspan(v uint) *TD

func (*TD) SetSides

func (td *TD) SetSides(v string) *TD

func (*TD) SetStyle

func (td *TD) SetStyle(v string) *TD

func (*TD) SetTarget

func (td *TD) SetTarget(v string) *TD

func (*TD) SetTitle

func (td *TD) SetTitle(v string) *TD

func (*TD) SetTooltip

func (td *TD) SetTooltip(v string) *TD

func (*TD) SetValign

func (td *TD) SetValign(v HtmLikeValign) *TD

func (*TD) SetWidth

func (td *TD) SetWidth(v uint) *TD

func (*TD) WriteDOT

func (td *TD) WriteDOT(w io.Writer) error

WriteDOT writes the <TD> element and its children to the writer.

type TR

type TR struct {
	Children []HtmLikeElement // Expected to contain *TD elements or HR/VR
}

TR represents a <TR> element.

func NewTR

func NewTR(children ...HtmLikeElement) *TR

NewTR creates a new TR element.

func (*TR) AppendChildren

func (tr *TR) AppendChildren(children ...HtmLikeElement) *TR

AppendChildren adds children to the table row.

func (*TR) WriteDOT

func (tr *TR) WriteDOT(w io.Writer) error

WriteDOT writes the <TR> element and its children to the writer.

type Table

type Table struct {
	Align         HtmLikeAlign
	BGColor       string
	Border        *uint // Note: BORDER is uint up to 255 for TABLE, 127 for CELLBORDER
	CellBorder    *uint // Max 127
	CellPadding   *uint // Max 255
	CellSpacing   *uint // Max 127
	Color         string
	Columns       string // Only "*" currently
	FixedSize     *bool
	GradientAngle *int
	Height        *uint // Max 65535
	HREF          string
	ID            string
	Port          string
	Rows          string // Only "*" currently
	Sides         string // e.g., "LT", "B", "LRTB"
	Style         string // e.g., "ROUNDED", "RADIAL"
	Target        string
	Title         string // Alias for TOOLTIP
	Tooltip       string
	Valign        HtmLikeValign
	Width         *uint // Max 65535

	Children []HtmLikeElement // Expected to contain *TR elements
}

Table represents a <TABLE> element.

func NewTable

func NewTable(children ...HtmLikeElement) *Table

NewTable creates a new Table element.

func (*Table) AppendChildren

func (t *Table) AppendChildren(children ...HtmLikeElement) *Table

AppendChildren adds children to the table.

func (*Table) SetAlign

func (t *Table) SetAlign(v HtmLikeAlign) *Table

Setters for fluent API

func (*Table) SetBGColor

func (t *Table) SetBGColor(v string) *Table

func (*Table) SetBorder

func (t *Table) SetBorder(v uint) *Table

func (*Table) SetCellBorder

func (t *Table) SetCellBorder(v uint) *Table

func (*Table) SetCellPadding

func (t *Table) SetCellPadding(v uint) *Table

func (*Table) SetCellSpacing

func (t *Table) SetCellSpacing(v uint) *Table

func (*Table) SetColor

func (t *Table) SetColor(v string) *Table

func (*Table) SetColumns

func (t *Table) SetColumns(v string) *Table

func (*Table) SetFixedSize

func (t *Table) SetFixedSize(v bool) *Table

func (*Table) SetGradientAngle

func (t *Table) SetGradientAngle(v int) *Table

func (*Table) SetHREF

func (t *Table) SetHREF(v string) *Table

func (*Table) SetHeight

func (t *Table) SetHeight(v uint) *Table

func (*Table) SetID

func (t *Table) SetID(v string) *Table

func (*Table) SetPort

func (t *Table) SetPort(v string) *Table

func (*Table) SetRows

func (t *Table) SetRows(v string) *Table

func (*Table) SetSides

func (t *Table) SetSides(v string) *Table

func (*Table) SetStyle

func (t *Table) SetStyle(v string) *Table

func (*Table) SetTarget

func (t *Table) SetTarget(v string) *Table

func (*Table) SetTitle

func (t *Table) SetTitle(v string) *Table

func (*Table) SetTooltip

func (t *Table) SetTooltip(v string) *Table

func (*Table) SetValign

func (t *Table) SetValign(v HtmLikeValign) *Table

func (*Table) SetWidth

func (t *Table) SetWidth(v uint) *Table

func (*Table) WriteDOT

func (t *Table) WriteDOT(w io.Writer) error

WriteDOT writes the <TABLE> element and its children to the writer.

type Text

type Text string

Text represents simple text content within an HTML-like label. The text content needs to be HTML-escaped.

func NewText

func NewText(s string) Text

NewText creates a new Text element.

func (Text) String

func (t Text) String() string

String converts Text to its string representation.

func (Text) WriteDOT

func (t Text) WriteDOT(w io.Writer) error

WriteDOT writes the escaped text content to the writer.

Jump to

Keyboard shortcuts

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