Skip to content

Commit

Permalink
Format with erlfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
zadean committed Jan 5, 2022
1 parent a14cba6 commit 3d2d16c
Show file tree
Hide file tree
Showing 8 changed files with 4,310 additions and 3,758 deletions.
41 changes: 18 additions & 23 deletions include/htmerl.hrl
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 = []
}).
}).
3 changes: 2 additions & 1 deletion rebar.config
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]}.
1 change: 1 addition & 0 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[].
27 changes: 13 additions & 14 deletions src/htmerl.app.src
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/"}
]}
]}.
24 changes: 12 additions & 12 deletions src/htmerl.erl
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).
Loading

0 comments on commit 3d2d16c

Please sign in to comment.