1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-09 01:30:25 +08:00

More tests

This commit is contained in:
Gonzalo Fernandez-Victorio
2021-05-12 21:27:28 +01:00
parent 965e28ba05
commit 4c88ae23fe
4 changed files with 47 additions and 26 deletions

View File

@@ -3,6 +3,8 @@ package docxlib
import (
"encoding/xml"
"io"
"github.com/golang/glog"
)
type ParagraphChild struct {
@@ -31,12 +33,23 @@ func (p *Paragraph) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
if tt.Name.Local == "hyperlink" {
var value Hyperlink
d.DecodeElement(&value, &start)
value.ID = getAtt(tt.Attr, "id")
id := getAtt(tt.Attr, "id")
anchor := getAtt(tt.Attr, "anchor")
if id != "" {
value.ID = id
}
if anchor != "" {
value.ID = anchor
}
elem = ParagraphChild{Link: &value}
} else if tt.Name.Local == "r" {
var value Run
d.DecodeElement(&value, &start)
elem = ParagraphChild{Run: &value}
if value.InstrText == "" && value.Text == nil {
glog.V(0).Infof("Empty run, we ignore")
continue
}
} else if tt.Name.Local == "rPr" {
var value RunProperties
d.DecodeElement(&value, &start)