Added io.Reader type support of input data for ContentFormat method

This commit is contained in:
Maxim Lebedev 2017-12-13 15:05:27 +05:00
parent 5f83fd5342
commit 2aa4b849d5
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
1 changed files with 7 additions and 0 deletions

View File

@ -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")
}