From c4142b1c822541b59e616a4bddad2f47882e7de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 9 Feb 2023 14:38:21 +0800 Subject: [PATCH] fix: tag in Paragraph --- structnodes.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/structnodes.go b/structnodes.go index a284032..a056ca5 100644 --- a/structnodes.go +++ b/structnodes.go @@ -13,11 +13,18 @@ type ParagraphChild struct { type Paragraph struct { XMLName xml.Name `xml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main p"` - Children []ParagraphChild // Children will generate an unnecessary tag ... but we have no other choice + Children []ParagraphChild // Children will generate an unnecessary tag ... and we skip it by a self-defined xml.Marshaler file *Docx } +func (p *Paragraph) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + for _, c := range p.Children { + e.EncodeElement(c, start) + } + return nil +} + func (p *Paragraph) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { children := make([]ParagraphChild, 0, 64) for {