1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-06 00:00:24 +08:00
Files
go-docx/apitext.go
2023-02-22 21:05:15 +08:00

36 lines
568 B
Go

package docxlib
import "encoding/xml"
// AddTab adds tab to para
func (p *Paragraph) AddTab() *Run {
run := &Run{
RunProperties: &RunProperties{},
FrontTab: []struct {
XMLName xml.Name "xml:\"w:tab,omitempty\""
}{{}},
}
p.Children = append(p.Children, run)
return run
}
// AddText adds text to paragraph
func (p *Paragraph) AddText(text string) *Run {
if text == "\t" {
return p.AddTab()
}
t := &Text{
Text: text,
}
run := &Run{
Text: t,
RunProperties: &RunProperties{},
}
p.Children = append(p.Children, run)
return run
}