~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/test_server/src/erl2html2.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
3
%% 
4
 
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
 
4
%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
5
5
%% 
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
32
32
%--------------------------------------------------------------------
33
33
 
34
34
-module(erl2html2).
35
 
-export([convert/2]).
 
35
-export([convert/2, convert/3]).
36
36
 
37
37
convert([], _Dest) ->   % Fake clause.
38
38
    ok;
39
39
convert(File, Dest) ->
 
40
    %% The generated code uses the BGCOLOR attribute in the
 
41
    %% BODY tag, which wasn't valid until HTML 3.2.  Also,
 
42
    %% good HTML should either override all colour attributes
 
43
    %% or none of them -- *never* just a few.
 
44
    %%
 
45
    %% FIXME: The colours should *really* be set with
 
46
    %% stylesheets...
 
47
    Header = ["<!DOCTYPE HTML PUBLIC "
 
48
              "\"-//W3C//DTD HTML 3.2 Final//EN\">\n"
 
49
              "<!-- autogenerated by '"++atom_to_list(?MODULE)++"'. -->\n"
 
50
              "<html>\n"
 
51
              "<head><title>", File, "</title></head>\n\n"
 
52
              "<body bgcolor=\"white\" text=\"black\""
 
53
              " link=\"blue\" vlink=\"purple\" alink=\"red\">\n"],
 
54
    convert(File, Dest, Header).
 
55
    
 
56
convert(File, Dest, Header) ->
40
57
    case file:read_file(File) of
41
58
        {ok, Bin} ->
42
59
            Code=binary_to_list(Bin),
43
60
            statistics(runtime),
44
 
            %% The generated code uses the BGCOLOR attribute in the
45
 
            %% BODY tag, which wasn't valid until HTML 3.2.  Also,
46
 
            %% good HTML should either override all colour attributes
47
 
            %% or none of them -- *never* just a few.
48
 
            %%
49
 
            %% FIXME: The colours should *really* be set with
50
 
            %% stylesheets...
51
 
            Html0 
52
 
                = ["<!DOCTYPE HTML PUBLIC "
53
 
                   "\"-//W3C//DTD HTML 3.2 Final//EN\">\n"
54
 
                   "<!-- autogenerated by '"++atom_to_list(?MODULE)++"'. -->\n"
55
 
                   "<html>\n"
56
 
                   "<head><title>", File, "</title></head>\n\n"
57
 
                   "<body bgcolor=\"white\" text=\"black\""
58
 
                   " link=\"blue\" vlink=\"purple\" alink=\"red\">\n"],
59
61
            {Html1, Lines} = root(Code, [], 1),
60
 
            Html = [Html0, 
 
62
            Html = [Header,
61
63
                    "<pre>\n", Html1, "</pre>\n", 
62
64
                    footer(Lines),"</body>\n</html>\n"],
63
65
            file:write_file(Dest, Html);
173
175
        end, 
174
176
    [A,Pred,integer_to_list(Line),":"].
175
177
 
176
 
footer(Lines) ->
177
 
    {_, Time} = statistics(runtime),
178
 
%    io:format("Converted ~p lines in ~.2f Seconds.~n",
179
 
%             [Lines, Time/1000]),
180
 
    S = "<i>The transformation of this file (~p lines) took ~.2f seconds</i>",
181
 
    F = lists:flatten(io_lib:format(S, [Lines, Time/1000])),
182
 
    ["<hr size=1>",F,"<br>\n"].
 
178
footer(_Lines) ->
 
179
    "".
 
180
%%    {_, Time} = statistics(runtime),
 
181
%%    io:format("Converted ~p lines in ~.2f Seconds.~n",
 
182
%%            [Lines, Time/1000]),
 
183
%%    S = "<i>The transformation of this file (~p lines) took ~.2f seconds</i>",
 
184
%%    F = lists:flatten(io_lib:format(S, [Lines, Time/1000])),
 
185
%%    ["<hr size=1>",F,"<br>\n"].