ParseWithOptions is like Parse, with options.
(r io.Reader, opts ...ParseOption)
| 2286 | |
| 2287 | // ParseWithOptions is like Parse, with options. |
| 2288 | func ParseWithOptions(r io.Reader, opts ...ParseOption) (*Node, error) { |
| 2289 | p := &parser{ |
| 2290 | tokenizer: NewTokenizer(r), |
| 2291 | doc: &Node{ |
| 2292 | Type: DocumentNode, |
| 2293 | }, |
| 2294 | scripting: true, |
| 2295 | framesetOK: true, |
| 2296 | im: initialIM, |
| 2297 | } |
| 2298 | |
| 2299 | for _, f := range opts { |
| 2300 | f(p) |
| 2301 | } |
| 2302 | |
| 2303 | if err := p.parse(); err != nil { |
| 2304 | return nil, err |
| 2305 | } |
| 2306 | return p.doc, nil |
| 2307 | } |
| 2308 | |
| 2309 | // ParseFragmentWithOptions is like ParseFragment, with options. |
| 2310 | func ParseFragmentWithOptions(r io.Reader, context *Node, opts ...ParseOption) ([]*Node, error) { |
searching dependent graphs…