Skip to content

Commit

Permalink
Fixes #2
Browse files Browse the repository at this point in the history
mattn committed Jan 9, 2020
1 parent 32a7f7a commit 029cc5a
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/mattn/docx2md

require github.com/mattn/go-runewidth v0.0.4
go 1.14

require github.com/mattn/go-runewidth v0.0.7
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -215,20 +215,20 @@ func (zf *file) walk(node *Node, w io.Writer) error {
switch n.XMLName.Local {
case "ind":
if left, ok := attr(n.Attrs, "left"); ok {
if i, err := strconv.Atoi(left); err == nil {
if i, err := strconv.Atoi(left); err == nil && i > 0 {
fmt.Fprint(w, strings.Repeat(" ", i/360))
}
}
case "pStyle":
if val, ok := attr(n.Attrs, "val"); ok {
if strings.HasPrefix(val, "Heading") {
if i, err := strconv.Atoi(val[7:]); err == nil {
if i, err := strconv.Atoi(val[7:]); err == nil && i > 0 {
fmt.Fprint(w, strings.Repeat("#", i)+" ")
}
} else if val == "Code" {
code = true
} else {
if i, err := strconv.Atoi(val); err == nil {
if i, err := strconv.Atoi(val); err == nil && i > 0 {
fmt.Fprint(w, strings.Repeat("#", i)+" ")
}
}
@@ -280,7 +280,7 @@ func (zf *file) walk(node *Node, w io.Writer) error {
fmt.Fprint(w, strings.Repeat(" ", ind))
switch numFmt {
case "decimal", "aiueoFullWidth":
key := fmt.Sprint("%s:%d", numId, ind)
key := fmt.Sprintf("%s:%d", numId, ind)
cur, ok := zf.list[key]
if !ok {
zf.list[key] = start

0 comments on commit 029cc5a

Please sign in to comment.