%% ``The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved via the world wide web at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
%% Portions created by Ericsson are Copyright 1999-2000, Ericsson
%% Utvecklings AB. All Rights Reserved.''
%%
%% $Id$
%%
-module(docb_html).
-export([rule/2, rule/3]).
rule([p, item, list|_], {_, _, _}) ->
{"", "
\n"};
rule([p, item, taglist|_], {_, _, _}) ->
{"", "
\n"};
rule([p|_], _) ->
{"\n
", "\n
"}; rule([pre|_], _) -> {"\n\n", "\n
\n", "\n\n"}; rule([i|_], _) -> {"", ""}; rule([b|_], _) -> {"", ""}; rule([c|_], _) -> {"", ""}; rule([em|_], _) -> {"", ""}; rule([sub|_], _) -> {"", ""}; rule([sup|_], _) -> {"", ""}; rule([termdef|_], _) -> {drop, ""}; rule([citedef|_], _) -> {drop, ""}; rule([br|_], _) -> {"
\n" " | \n" " \n", " \n" " | \n" "
\n", Data, "\n
UNIX: ",
docb_html_util:attribute_cdata_to_html(UNIX),
", ",
"Windows: ",
docb_html_util:attribute_cdata_to_html(Windows),
"
)"]},
Opts};
UnixPart ->
{{drop, [docb_html_util:pcdata_to_html(Text),
" (UNIX: ",
docb_html_util:attribute_cdata_to_html(UNIX),
"
)"]},
Opts};
WinPart ->
{{drop, [docb_html_util:pcdata_to_html(Text),
" (Windows: ",
docb_html_util:attribute_cdata_to_html(Windows),
"
)"]},
Opts};
true ->
{{drop, docb_html_util:pcdata_to_html(Text)}, Opts}
end;
rule([term|_], {_, [ID], _}, Opts) ->
case docb_util:an_option(dict, Opts) of
false ->
case docb_util:lookup_option({defs, term}, Opts) of
false ->
{{drop, ["",
ID,
" "]}, Opts};
TermList ->
case lists:keyfind(ID, 1, TermList) of
false ->
{{drop, ["", ID,
" "]},
Opts};
{ID, Name, _Description, _Resp} ->
{{drop, ["", Name,
" "]},
Opts};
{ID, Name, _Description} ->
{{drop, [ "", Name,
" "]},
Opts}
end
end;
true ->
case docb_util:lookup_option({defs, term}, Opts) of
false ->
{{drop, ["", ID,
" "]}, Opts};
TermList ->
PartApplication =
docb_util:lookup_option(part_application, Opts),
case lists:keyfind(ID, 1, TermList) of
false ->
{{drop, ["", ID,
" "]}, Opts};
{ID, Name, _Description, _Resp} ->
{{drop, ["", Name,
" "]}, Opts};
{ID, Name, _Description} ->
{{drop, ["", Name,
" "]}, Opts}
end
end
end;
rule([cite|_], {_, [ID], _}, Opts) ->
case docb_util:an_option(dict, Opts) of
false ->
case docb_util:lookup_option({defs, cite}, Opts) of
false ->
{{drop, ["", ID, " "]},
Opts};
CiteList ->
case lists:keyfind(ID, 1, CiteList) of
false ->
{{drop,
["", ID, " "]},
Opts};
{ID, Name, _Description, _Resp} ->
{{drop, ["", Name,
" "]},
Opts};
{ID, Name, _Description} ->
{{drop, ["", Name,
" "]},
Opts}
end
end;
true ->
case docb_util:lookup_option({defs, cite}, Opts) of
false ->
{{drop, ["", ID, " "]},
Opts};
CiteList ->
PartApp =
docb_util:lookup_option(part_application, Opts),
case lists:keyfind(ID, 1, CiteList) of
false ->
{{drop, ["", ID,
" "]},
Opts};
{ID, Name, _Description, _Resp} ->
{{drop, ["", Name,
" "]},
Opts};
{ID, Name, _Description} ->
{{drop, ["", Name,
" "]},
Opts}
end
end
end;
rule([code|_], {_, [Type], [{pcdata, _, Code}]}, Opts) ->
case lists:member(Type, ["ERL","C","NONE"]) of
true ->
{{drop, ["\n\n", docb_html_util:element_cdata_to_html(Code), "\n
"})
end.
reorder_table(TableContent) ->
reorder_table(TableContent, [], []).
reorder_table([], Caption, NewTableContent) ->
Caption ++ lists:reverse(NewTableContent);
reorder_table([{tcaption,_,_} = Caption | TableContent], _, NewTableContent) ->
reorder_table(TableContent, [Caption], NewTableContent);
reorder_table([Row | TableContent], Caption, NewTableContent) ->
reorder_table(TableContent, Caption, [Row | NewTableContent]).