1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-11 02:50:27 +08:00

add SplitByParagraph

This commit is contained in:
源文雨
2023-03-09 17:20:17 +08:00
parent 2a630f6342
commit 69a899d4a5
12 changed files with 282 additions and 37 deletions

19
docx.go
View File

@@ -24,7 +24,6 @@ package docx
import (
"archive/zip"
"bytes"
"io"
"io/fs"
"sync"
@@ -50,9 +49,6 @@ type Docx struct {
tmplfs fs.FS
tmpfslst []string
buf *bytes.Buffer
isbufempty bool
io.Reader
io.WriterTo
}
@@ -109,20 +105,9 @@ func (f *Docx) WriteTo(writer io.Writer) (_ int64, err error) {
return 0, f.pack(zipWriter)
}
// Read allows to save a docx to buf
// Read is a fake function and cannot be used
func (f *Docx) Read(p []byte) (n int, err error) {
if !f.isbufempty {
n, err = f.buf.Read(p)
if err == io.EOF {
f.buf.Reset()
f.isbufempty = true
return
}
}
zipWriter := zip.NewWriter(f.buf)
defer zipWriter.Close()
f.isbufempty = false
return f.buf.Read(p)
panic("fake stub!")
}
// UseTemplate will replace template files