-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
4,310 additions
and
3,758 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,33 @@ | ||
%% Attribute | ||
-record(htmlAttribute, | ||
{ | ||
name :: binary(), | ||
prefix = <<>> :: binary(), | ||
-record(htmlAttribute, { | ||
name :: binary(), | ||
prefix = <<>> :: binary(), | ||
namespace = <<>> :: binary(), | ||
value = <<>> :: binary() | ||
}). | ||
value = <<>> :: binary() | ||
}). | ||
|
||
%% Tag | ||
-record(htmlElement, | ||
{ | ||
name :: binary(), | ||
namespace :: binary(), | ||
-record(htmlElement, { | ||
name :: binary(), | ||
namespace :: binary(), | ||
attributes = [] :: [#htmlAttribute{}], | ||
content = [] | ||
}). | ||
content = [] | ||
}). | ||
|
||
%% Text | ||
-record(htmlText, | ||
{ | ||
-record(htmlText, { | ||
value = <<>> :: binary(), | ||
type = text :: text | cdata | ||
}). | ||
type = text :: text | cdata | ||
}). | ||
|
||
%% Comment | ||
-record(htmlComment, | ||
{ | ||
-record(htmlComment, { | ||
value = <<>> :: binary() | ||
}). | ||
}). | ||
|
||
-record(htmlDocument, | ||
{ | ||
name = <<"html">>, | ||
-record(htmlDocument, { | ||
name = <<"html">>, | ||
public, | ||
system, | ||
content = [] | ||
}). | ||
}). |
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,2 +1,3 @@ | ||
{erl_opts, [debug_info]}. | ||
{deps, []}. | ||
{deps, []}. | ||
{project_plugins, [erlfmt, rebar3_hex]}. |
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 @@ | ||
[]. |
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,14 +1,13 @@ | ||
{application, htmerl, | ||
[{description, "An OTP library"}, | ||
{vsn, "0.1.0"}, | ||
{registered, []}, | ||
{applications, | ||
[kernel, | ||
stdlib | ||
]}, | ||
{env,[]}, | ||
{modules, []}, | ||
|
||
{licenses, ["Apache 2.0"]}, | ||
{links, []} | ||
]}. | ||
{application, htmerl, [ | ||
{description, "An OTP library for parsing HTML documents"}, | ||
{vsn, "0.1.0"}, | ||
{registered, []}, | ||
{applications, [kernel, stdlib]}, | ||
{env, []}, | ||
{modules, []}, | ||
{licenses, ["Apache-2.0"]}, | ||
{links, [ | ||
{"GitHub", "https://github.com/zadean/htmerl"}, | ||
{"Specification", "https://www.w3.org/TR/html52/"} | ||
]} | ||
]}. |
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,38 +1,38 @@ | ||
-module(htmerl). | ||
|
||
%% API exports | ||
-export([simple/1, | ||
sax/1, sax/2]). | ||
-export([ | ||
simple/1, | ||
sax/1, sax/2 | ||
]). | ||
|
||
%%==================================================================== | ||
%% API functions | ||
%%==================================================================== | ||
|
||
%% Takes a UTF-8 encoded binary containing an entire HTML document and returns | ||
%% the parsed document as a tree of records found in htmerl.hrl. The root | ||
%% record is htmlDocument. | ||
%% record is htmlDocument. | ||
simple(Bin) -> | ||
htmerl_simple:string(Bin). | ||
|
||
htmerl_simple:string(Bin). | ||
|
||
%% Takes a UTF-8 encoded binary containing an entire HTML document and returns | ||
%% the parsed document as a list of SAX events. The SAX events are identical to | ||
%% the parsed document as a list of SAX events. The SAX events are identical to | ||
%% those returned by xmerl except that the values and names are UTF-8 and | ||
%% not codepoint lists. | ||
sax(Bin) -> | ||
htmerl_sax_utf8:string(Bin). | ||
htmerl_sax_utf8:string(Bin). | ||
|
||
%% Takes a UTF-8 encoded binary containing an entire HTML document and | ||
%% Takes a UTF-8 encoded binary containing an entire HTML document and | ||
%% [{event_fun, fun event/3}, | ||
%% {user_state, state()}] | ||
%% as Opts. | ||
%% For each SAX event, the function in event_fun will be called as follows: | ||
%% Fun(Event, LineNum, UserState) | ||
%% Once all events are consumed {ok, UserState, Warnings} is returned. | ||
%% The SAX events are identical to those used by xmerl_sax_parser except that | ||
%% The SAX events are identical to those used by xmerl_sax_parser except that | ||
%% the values and names are binaries and not codepoint lists. | ||
%% | ||
%% A usage example can be found in htmerl_simple. | ||
%% A usage example can be found in htmerl_simple. | ||
sax(Bin, Opts) -> | ||
htmerl_sax_utf8:string(Bin, Opts). | ||
|
||
htmerl_sax_utf8:string(Bin, Opts). |
Oops, something went wrong.