-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from rinpatch/feature/fast_html
Add fast_html parser and test all parsers on CI
- Loading branch information
Showing
6 changed files
with
137 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule Floki.HTMLParser.FastHtml do | ||
@moduledoc false | ||
|
||
def parse(html) do | ||
case Code.ensure_loaded(:fast_html) do | ||
{:module, module} -> | ||
case module.decode(html) do | ||
{:ok, result} -> result | ||
{:error, _message} = error -> error | ||
end | ||
|
||
{:error, _reason} -> | ||
raise "Expected module :fast_html to be available." | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# fast_html uses a C-Node worker for parsing, so starting the application | ||
# is necessary for it to work | ||
if Application.get_env(:floki, :html_parser) == Floki.HTMLParser.FastHtml do | ||
Application.ensure_all_started(:fast_html) | ||
end | ||
|
||
ExUnit.start() |