Permalink
Browse files

Merge branch 'html5-gh64'

  • Loading branch information...
2 parents 57f6d12 + f425e5e commit e6d1870200802f32e17e334272191397e15aec53 @etrepum etrepum committed Oct 15, 2011
Showing with 2,204 additions and 273 deletions.
  1. +9 −0 CHANGES.md
  2. +45 −0 scripts/entities.erl
  3. +1 −1 src/mochiweb.app.src
  4. +2,130 −255 src/mochiweb_charref.erl
  5. +19 −17 src/mochiweb_html.erl
View
@@ -1,3 +1,12 @@
+Version 2.3.0 released 2011-10-14
+
+* Handle ssl_closed message in mochiweb_http (#59)
+* Added support for new MIME types (otf, eot, m4v, svg, svgz, ttc, ttf,
+ vcf, webm, webp, woff) (#61)
+* Updated mochiweb_charref to support all HTML5 entities. Note that
+ if you are using this module directly, the spec has changed to return
+ `[integer()]` for some entities. (#64)
+
Version 2.2.1 released 2011-08-31
* Removed `mochiweb_skel` module from the pre-rebar era
View
@@ -0,0 +1,45 @@
+#!/usr/bin/env escript
+%% -*- mode: erlang -*-
+-export([main/1]).
+
+%% @doc Script used to generate mochiweb_charref.erl table.
+
+main(_) ->
+ application:start(inets),
+ code:add_patha("ebin"),
+ {ok, {_, _, HTML}} = httpc:request("http://www.w3.org/TR/html5/named-character-references.html"),
+ print(lists:sort(search(mochiweb_html:parse(HTML)))).
+
+print([F | T]) ->
+ io:put_chars([clause(F), ";\n"]),
+ print(T);
+print([]) ->
+ io:put_chars(["entity(_) -> undefined.\n"]),
+ ok.
+
+clause({Title, [Codepoint]}) ->
+ ["entity(\"", Title, "\") -> 16#", Codepoint];
+clause({Title, [First | Rest]}) ->
+ ["entity(\"", Title, "\") -> [16#", First,
+ [[", 16#", Codepoint] || Codepoint <- Rest],
+ "]"].
+
+
+search(Elem) ->
+ search(Elem, []).
+
+search({<<"tr">>, [{<<"id">>, <<"entity-", _/binary>>} | _], Children}, Acc) ->
+ %% HTML5 charrefs can have more than one code point(!)
+ [{<<"td">>, _, [{<<"code">>, _, [TitleSemi]}]},
+ {<<"td">>, [], [RawCPs]} | _] = Children,
+ L = byte_size(TitleSemi) - 1,
+ <<Title:L/binary, $;>> = TitleSemi,
+ {match, Matches} = re:run(RawCPs, "(?:\\s*U\\+)([a-fA-F0-9]+)",
+ [{capture, all, binary}, global]),
+ [{Title, [CP || [_, CP] <- Matches]} | Acc];
+search({Tag, Attrs, [H | T]}, Acc) ->
+ search({Tag, Attrs, T}, search(H, Acc));
+search({_Tag, _Attrs, []}, Acc) ->
+ Acc;
+search(<<_/binary>>, Acc) ->
+ Acc.
@@ -1,7 +1,7 @@
%% This is generated from src/mochiweb.app.src
{application, mochiweb,
[{description, "MochiMedia Web Server"},
- {vsn, "2.2.1"},
+ {vsn, "2.3.0"},
{modules, []},
{registered, []},
{env, []},
Oops, something went wrong. Retry.

0 comments on commit e6d1870

Please sign in to comment.