objects/heading.go

23 lines
658 B
Go
Raw Normal View History

2023-08-10 15:52:01 -06:00
package objects
import "fmt"
import "git.tebibyte.media/tomo/tomo"
// Heading is a label that denotes the start of some section of content. It can
// have a level from 0 to 2, with 0 being the most prominent and 2 being the
// most subtle. The level is described in the role variation.
type Heading struct {
tomo.TextBox
}
// NewHeading creates a new section heading. The level can be from 0 to 2.
func NewHeading (level int, text string) *Heading {
2023-08-10 15:52:01 -06:00
if level < 0 { level = 0 }
if level > 2 { level = 2 }
this := &Heading { TextBox: tomo.NewTextBox() }
2024-06-03 19:13:18 -06:00
this.SetRole(tomo.R("objects", "Heading", fmt.Sprint(level)))
2023-08-10 15:52:01 -06:00
this.SetText(text)
return this
}