Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merge

  • Loading branch information...
commit ccd4d901cba7b3817158f884062542e320485465 2 parents 0d9b2c3 + d3abe4f
@massemanet authored
Showing with 20 additions and 12 deletions.
  1. +20 −12 src/trane.erl
View
32 src/trane.erl
@@ -13,7 +13,8 @@
-export([sax/3
, unit/0,unit/1
, file_parse/1
- , wget_parse/1,wget_print/1]).
+ , wget_parse/1
+ , wget_print/1]).
sax(Str,Fun,Acc) ->
parse(Str,Fun,Acc).
@@ -35,16 +36,19 @@ eof({_Fun,Acc,_Stack}) -> Acc.
maybe_emit(Token,State) ->
case Token of
- {sc,Tag,Attrs} -> emit({end_tag,Tag},emit({tag,Tag,Attrs},State));
- {open,Tag,Attrs}-> emit({tag,Tag,Attrs},push(Tag,State));
- {close,Tag} -> try emit({end_tag,Tag},pop(Tag,maybe_unroll(Tag,State)))
- catch bogus -> State
- end;
- {comment,Cm} -> emit({comment,Cm},State);
- {'?',DT} -> emit({'?',DT},State);
- {'!',DT} -> emit({'!',DT},State);
- {text,""} -> State;
- {text,Text} -> emit({text,Text},State)
+ {sc,Tag,Attrs} -> emit({end_tag,Tag},emit({tag,Tag,Attrs},State));
+ {open,Tag,Attrs} -> emit({tag,Tag,Attrs},push(Tag,State));
+ {close,Tag} -> emit_end_tag(Tag,State);
+ {comment,Cm} -> emit({comment,Cm},State);
+ {'?',DT} -> emit({'?',DT},State);
+ {'!',DT} -> emit({'!',DT},State);
+ {text,<<>>} -> State;
+ {text,Text} -> emit({text,Text},State)
+ end.
+
+emit_end_tag(Tag,State) ->
+ try emit({end_tag,Tag},pop(Tag,maybe_unroll(Tag,State)))
+ catch bogus -> State
end.
emit(Token,{Fun,Acc,Stack}) -> {Fun,Fun(Token,Acc),Stack}.
@@ -252,5 +256,9 @@ tests() ->
{end_tag,"p"},
{text,"grump"},
{tag,"x",[{"x","y"}]},
- {end_tag,"x"}]}
+ {end_tag,"x"}]},
+ {"<script>visual+basic = rules;</script>",
+ [{tag,"script",[]},
+ {text,<<"visual+basic = rules;">>},
+ {end_tag,"script"}]}
].
Please sign in to comment.
Something went wrong with that request. Please try again.