Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Nov 17, 2020
1 parent 5702c24 commit cb912b1
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
)

const name = "docx2md"
const version = "0.0.5"
const version = "0.0.6"

var revision = "HEAD"

// Relationship is
type Relationship struct {
Text string `xml:",chardata"`
ID string `xml:"Id,attr"`
Expand All @@ -34,18 +35,21 @@ type Relationship struct {
TargetMode string `xml:"TargetMode,attr"`
}

// Relationships is
type Relationships struct {
XMLName xml.Name `xml:"Relationships"`
Text string `xml:",chardata"`
Xmlns string `xml:"xmlns,attr"`
Relationship []Relationship `xml:"Relationship"`
}

// TextVal is
type TextVal struct {
Text string `xml:",chardata"`
Val string `xml:"val,attr"`
}

// NumberingLvl is
type NumberingLvl struct {
Text string `xml:",chardata"`
Ilvl string `xml:"ilvl,attr"`
Expand Down Expand Up @@ -76,6 +80,7 @@ type NumberingLvl struct {
} `xml:"rPr"`
}

// Numbering is
type Numbering struct {
XMLName xml.Name `xml:"numbering"`
Text string `xml:",chardata"`
Expand All @@ -101,7 +106,7 @@ type Numbering struct {
Ignorable string `xml:"Ignorable,attr"`
AbstractNum []struct {
Text string `xml:",chardata"`
AbstractNumId string `xml:"abstractNumId,attr"`
AbstractNumID string `xml:"abstractNumId,attr"`
RestartNumberingAfterBreak string `xml:"restartNumberingAfterBreak,attr"`
Nsid TextVal `xml:"nsid"`
MultiLevelType TextVal `xml:"multiLevelType"`
Expand All @@ -110,8 +115,8 @@ type Numbering struct {
} `xml:"abstractNum"`
Num []struct {
Text string `xml:",chardata"`
NumId string `xml:"numId,attr"`
AbstractNumId TextVal `xml:"abstractNumId"`
NumID string `xml:"numId,attr"`
AbstractNumID TextVal `xml:"abstractNumId"`
} `xml:"num"`
}

Expand All @@ -123,13 +128,15 @@ type file struct {
list map[string]int
}

// Node is
type Node struct {
XMLName xml.Name
Attrs []xml.Attr `xml:"-"`
Content []byte `xml:",innerxml"`
Nodes []Node `xml:",any"`
}

// UnmarshalXML is
func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
n.Attrs = start.Attr
type node Node
Expand Down Expand Up @@ -240,15 +247,15 @@ func (zf *file) walk(node *Node, w io.Writer) error {
}
}
case "numPr":
numId := ""
numID := ""
ilvl := ""
numFmt := ""
start := 1
ind := 0
for _, nn := range n.Nodes {
if nn.XMLName.Local == "numId" {
if val, ok := attr(nn.Attrs, "val"); ok {
numId = val
numID = val
}
}
if nn.XMLName.Local == "ilvl" {
Expand All @@ -258,11 +265,11 @@ func (zf *file) walk(node *Node, w io.Writer) error {
}
}
for _, num := range zf.num.Num {
if numId != num.NumId {
if numID != num.NumID {
continue
}
for _, abnum := range zf.num.AbstractNum {
if abnum.AbstractNumId != num.AbstractNumId.Val {
if abnum.AbstractNumID != num.AbstractNumID.Val {
continue
}
for _, ablvl := range abnum.Lvl {
Expand All @@ -286,7 +293,7 @@ func (zf *file) walk(node *Node, w io.Writer) error {
fmt.Fprint(w, strings.Repeat(" ", ind))
switch numFmt {
case "decimal", "aiueoFullWidth":
key := fmt.Sprintf("%s:%d", numId, ind)
key := fmt.Sprintf("%s:%d", numID, ind)
cur, ok := zf.list[key]
if !ok {
zf.list[key] = start
Expand Down

0 comments on commit cb912b1

Please sign in to comment.