1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-03 00:46:51 +02:00

Refactoring/externalized html (#234)

* Externalized HTML drivers

* Fixed unit tests

* Updated logging

* Added support to set default driver

* Updated GetIn and SetIn helpers
This commit is contained in:
Tim Voronov
2019-02-19 18:10:18 -05:00
committed by GitHub
parent f8e061cc80
commit 34c8c02258
62 changed files with 1356 additions and 1054 deletions

View File

@ -1,38 +0,0 @@
package html
import (
"context"
"github.com/MontFerret/ferret/pkg/drivers"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Parse parses a given HTML string and returns a HTML document.
// Returned HTML document is always static.
// @param html (String) - Target HTML string.
// @returns (HTMLDocument) - Parsed HTML static document.
func Parse(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
if err != nil {
return values.None, err
}
err = core.ValidateType(args[0], types.String)
if err != nil {
return values.None, err
}
drv, err := drivers.StaticFrom(ctx)
if err != nil {
return values.None, err
}
str := args[0].(values.String)
return drv.ParseDocument(ctx, str)
}