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:
19
docx.go
19
docx.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user