Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

UTF-8 compatibility.

Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
  • Loading branch information...
commit 00ce8410896ec2f7df54dd4a4494059e9dcffb32 1 parent c6f4e90
@akaspin akaspin authored
View
2  .gitignore
@@ -5,3 +5,5 @@ deps
ebin
priv/www
!/priv/www/index.html
+/.settings
+/.project
View
BIN  erldocs 100755 → 100644
Binary file not shown
View
33 src/erldocs_core.erl
@@ -61,7 +61,7 @@ build_file_map(Conf, AppName, File) ->
erlref ->
{modulesummary, [], Sum}
= lists:keyfind(modulesummary,1, Xml),
- Sum;
+ unicode:characters_to_list(Sum);
cref ->
{libsummary, [], Sum}
= lists:keyfind(libsummary, 1, Xml),
@@ -188,11 +188,19 @@ javascript_index(Conf, FIndex) ->
log("Creating erldocs_index.js ...~n"),
F = fun([Else, App, NMod, Sum]) ->
- [Else, App, NMod, string:substr(Sum, 1, 50)]
+ [Else, App, NMod, fmt("~ts", [string:substr(Sum, 1, 50)])]
end,
- Index = lists:sort(fun sort_index/2, lists:map(F, FIndex)),
- Js = fmt("var index = ~p;", [Index]),
+ Index =
+ lists:map(
+ fun([A,B,C,[]]) ->
+ fmt("['~s','~s','~s',[]]", [A,B,C]);
+ ([A,B,C,D]) ->
+ fmt("['~s','~s','~s','~s']", [A,B,C,D])
+ end,
+ lists:sort(fun sort_index/2, lists:map(F, FIndex))),
+
+ Js = fmt("var index = [~s];", [string:join(Index, ",")]),
ok = file:write_file([dest(Conf), "/erldocs_index.js"], Js).
@@ -406,7 +414,7 @@ strip_whitespace(Else) ->
is_whitespace(X) when is_tuple(X); is_number(X) ->
true;
is_whitespace(X) ->
- nomatch == re:run(X, "^[ \n\t]*$"). %"
+ nomatch == re:run(X, "^[ \n\t]*$", [unicode]). %"
%% rather basic xml to string converter, takes xml of the form
%% {tag, [{listof, "attributes"}], ["list of children"]}
@@ -416,15 +424,15 @@ xml_to_str(Xml) ->
xml_to_html({Tag, Attr}) ->
%% primarily for cases such as <a name="">
- fmt("<~s ~s>", [Tag, atos(Attr)]);
+ fmt("<~ts ~ts>", [Tag, atos(Attr)]);
xml_to_html({Tag, Attr, []}) ->
- fmt("<~s ~s />", [Tag, atos(Attr)]);
+ fmt("<~ts ~ts />", [Tag, atos(Attr)]);
xml_to_html({Tag, [], []}) ->
- fmt("<~s />", [Tag]);
+ fmt("<~ts />", [Tag]);
xml_to_html({Tag, [], Child}) ->
- fmt("<~s>~s</~s>", [Tag, xml_to_html(Child), Tag]);
+ fmt("<~ts>~ts</~ts>", [Tag, xml_to_html(Child), Tag]);
xml_to_html({Tag, Attr, Child}) ->
- fmt("<~s ~s>~s</~s>", [Tag, atos(Attr), xml_to_html(Child), Tag]);
+ fmt("<~ts ~ts>~ts</~ts>", [Tag, atos(Attr), xml_to_html(Child), Tag]);
xml_to_html(List) when is_list(List) ->
case io_lib:char_list(List) of
true -> htmlchars(List);
@@ -452,8 +460,9 @@ htmlchars([Else | Rest], Acc) -> htmlchars(Rest, [Else | Acc]).
-spec read_xml(list(), list()) -> tuple().
read_xml(_Conf, XmlFile) ->
- Opts = [{fetch_path, [code:lib_dir(docbuilder, dtd)]},
- {encoding, "latin1"}],
+%% Opts = [{fetch_path, [code:lib_dir(docbuilder, dtd)]},
+%% {encoding, "utf-8"}],
+ Opts = [{fetch_path, [code:lib_dir(docbuilder, dtd)]}],
{Xml, _} = xmerl_scan:file(XmlFile, Opts),
xmerl_lib:simplify_element(Xml).
View
2  templates/erldocs.dtl
@@ -2,7 +2,7 @@
<html lang="en">
<head>
- <meta charset="latin1" />
+ <meta charset="utf-8" />
<title>{{ title }} - erldocs.com (Erlang Documentation)</title>
<link rel="search" type="application/opensearchdescription+xml"
title="erldocs" href="/search.xml">
Please sign in to comment.
Something went wrong with that request. Please try again.