Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Nov 26, 2024
1 parent cdb9682 commit 5093e7c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ jobs:
go-version: 1.x
- name: Test
run: make test
- name: Lint
run: make lint
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Convert Microsoft Word Document to Markdown
$ docx2md NewDocument.docx
```

Or docker

```
$ docker run -it --rm ghcr.io/mattn/docx2md NewDocument.docx
```

## Installation

```
Expand Down
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -177,7 +176,7 @@ func (zf *file) extract(rel *Relationship, w io.Writer) error {
fmt.Fprintf(w, "![](data:image/png;base64,%s)",
base64.StdEncoding.EncodeToString(b[:n]))
} else {
err = ioutil.WriteFile(rel.Target, b, 0644)
err = os.WriteFile(rel.Target, b, 0644)
if err != nil {
return err
}
Expand Down Expand Up @@ -465,7 +464,7 @@ func readFile(f *zip.File) (*Node, error) {
rc, err := f.Open()
defer rc.Close()

b, _ := ioutil.ReadAll(rc)
b, _ := io.ReadAll(rc)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -499,11 +498,11 @@ func docx2md(arg string, embed bool) error {

for _, f := range r.File {
switch f.Name {
case "word/_rels/document.xml.rels":
case "word/_rels/document.xml.rels", "word/_rels/document2.xml.rels":
rc, err := f.Open()
defer rc.Close()

b, _ := ioutil.ReadAll(rc)
b, _ := io.ReadAll(rc)
if err != nil {
return err
}
Expand All @@ -516,7 +515,7 @@ func docx2md(arg string, embed bool) error {
rc, err := f.Open()
defer rc.Close()

b, _ := ioutil.ReadAll(rc)
b, _ := io.ReadAll(rc)
if err != nil {
return err
}
Expand Down

0 comments on commit 5093e7c

Please sign in to comment.