32
32
%--------------------------------------------------------------------
34
34
-module(erl2html2).
35
-export([convert/2, convert/3]).
37
37
convert([], _Dest) -> % Fake clause.
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.
45
%% FIXME: The colours should *really* be set with
47
Header = ["<!DOCTYPE HTML PUBLIC "
48
"\"-//W3C//DTD HTML 3.2 Final//EN\">\n"
49
"<!-- autogenerated by '"++atom_to_list(?MODULE)++"'. -->\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).
56
convert(File, Dest, Header) ->
40
57
case file:read_file(File) of
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.
49
%% FIXME: The colours should *really* be set with
52
= ["<!DOCTYPE HTML PUBLIC "
53
"\"-//W3C//DTD HTML 3.2 Final//EN\">\n"
54
"<!-- autogenerated by '"++atom_to_list(?MODULE)++"'. -->\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),
61
63
"<pre>\n", Html1, "</pre>\n",
62
64
footer(Lines),"</body>\n</html>\n"],
63
65
file:write_file(Dest, Html);
174
176
[A,Pred,integer_to_list(Line),":"].
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"].
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"].