1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-08 17:20:26 +08:00

feat: add shade effect

This commit is contained in:
源文雨
2023-02-26 15:01:17 +08:00
parent 592c7b5d13
commit 0e18f8a163
11 changed files with 154 additions and 80 deletions

View File

@@ -30,8 +30,9 @@ import (
// ParagraphProperties <w:pPr>
type ParagraphProperties struct {
XMLName xml.Name `xml:"w:pPr,omitempty"`
Justification *Justification `xml:"w:jc,omitempty"`
XMLName xml.Name `xml:"w:pPr,omitempty"`
Justification *Justification
Shade *Shade
}
// UnmarshalXML ...
@@ -48,6 +49,13 @@ func (p *ParagraphProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElemen
switch tt.Name.Local {
case "jc":
p.Justification = &Justification{Val: getAtt(tt.Attr, "val")}
case "shd":
var value Shade
err = d.DecodeElement(&value, &tt)
if err != nil && !strings.HasPrefix(err.Error(), "expected") {
return err
}
p.Shade = &value
default:
err = d.Skip() // skip unsupported tags
if err != nil {