✨ Added io.Reader type support of input data for ContentFormat method
This commit is contained in:
parent
5f83fd5342
commit
2aa4b849d5
|
@ -3,6 +3,7 @@ package telegraph
|
|||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
|
@ -46,6 +47,12 @@ func ContentFormat(data interface{}) ([]Node, error) {
|
|||
return nil, err
|
||||
}
|
||||
doc = *dom
|
||||
case io.Reader:
|
||||
dom, err := html.Parse(dst)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
doc = *dom
|
||||
default:
|
||||
return nil, errors.New("invalid data type, use []byte or string")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue