|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -42,6 +43,16 @@ func ReadBytes(b []byte) (*Doc, error) {
|
|
|
|
return Read(bytes.NewBuffer(b))
|
|
|
|
return Read(bytes.NewBuffer(b))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func ReadFile(path string) (*Doc, error) {
|
|
|
|
|
|
|
|
f, err := os.Open(path)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Read(f)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func parse(r io.Reader) (node, error) {
|
|
|
|
func parse(r io.Reader) (node, error) {
|
|
|
|
p := &parser{
|
|
|
|
p := &parser{
|
|
|
|
root: newRootNode(),
|
|
|
|
root: newRootNode(),
|
|
|
|