Commit c8d455a3 authored by gerd's avatar gerd

Support for PUBLIC name in DTD.

Added some layout options.


git-svn-id: https://godirepo.camlcity.org/svn/app-presentation/trunk@17 50e5f3cf-a9f2-0310-83d8-d11ec64cb5ab
parent 282a25b6
#----------------------------------------------------------------------
# specific rules for this package:
OBJECTS = to_html.cmo to_latex.cmo
OBJECTS = to_html.cmo to_latex.cmo dtd.cmo
XOBJECTS = $(OBJECTS:.cmo=.cmx)
ARCHIVE = presentation.cma
XARCHIVE = presentation.cmxa
......@@ -22,6 +22,11 @@ $(ARCHIVE): $(OBJECTS)
$(XARCHIVE): $(XOBJECTS)
$(OCAMLOPT) -a -o $(XARCHIVE) $(XOBJECTS)
dtd.ml: presentation.dtd
printf 'let dtd_1 = "' >dtd.ml
sed -e 's/["\]/\\\0/g' presentation.dtd >>dtd.ml
echo '";;' >>dtd.ml
#----------------------------------------------------------------------
# general rules:
......@@ -33,7 +38,7 @@ OCAMLFIND = ocamlfind
.PRECIOUS: depend
depend: *.ml
depend: *.ml dtd.ml
$(OCAMLDEP) *.ml *.mli >depend
.SUFFIXES: .cmo .cmi .cmx .ml .mli .mll .mly
......
......@@ -20,16 +20,31 @@ let run f x =
;;
let catalog =
[ "-//GERD STOLPMANN//DTD PRESENTATION 1.0//EN", Dtd.dtd_1 ] ;;
let parse_document idx tag_map filename =
let url = Pxp_reader.make_file_url filename in
let resolver =
new Pxp_reader.combine
[ Pxp_reader.lookup_public_id_as_string catalog;
new Pxp_reader.resolve_as_file();
]
in
parse_document_entity
~id_index: idx
{ default_config with encoding = `Enc_utf8 }
(ExtID (System (Neturl.string_of_url url), resolver))
tag_map
;;
let convert_to_html no_gifs remove_prefix filename =
(* read in style definition *)
let idx = (new hash_index :> To_html.shared index) in
let document =
parse_document_entity
~id_index: idx
{ default_config with encoding = `Enc_utf8 }
(from_file filename)
To_html.tag_map
in
let document = parse_document idx To_html.tag_map filename in
let root = document # root in
let store = new To_html.store remove_prefix in
if no_gifs then store # no_gifs;
......@@ -44,13 +59,7 @@ let convert_to_html no_gifs remove_prefix filename =
let convert_to_latex use_ocamldoc front_file filename =
(* read in style definition *)
let idx = (new hash_index :> To_latex.shared index) in
let document =
parse_document_entity
~id_index: idx
{ default_config with encoding = `Enc_utf8 }
(from_file filename)
To_latex.tag_map
in
let document = parse_document idx To_latex.tag_map filename in
let dirname = Filename.dirname filename in
let outname = Filename.chop_extension (Filename.basename filename) ^ ".tex" in
let out = open_out outname in
......
<!-- $Id$ -->
<!-- This DTD should be referred to as:
<!DOCTYPE presentation PUBLIC "-//GERD STOLPMANN//DTD PRESENTATION 1.0//EN" "">
-->
<!ENTITY % p.like "p|ul|picture">
<!ENTITY % text "br|code|c|em|footnote|a|numref|nameref|html|latex">
<!ENTITY % layout "layout|headline-layout">
......@@ -91,9 +96,11 @@
<!ELEMENT code (#PCDATA)>
<!-- Formatted as a new block -->
<!-- Layout customizable: CHILDREN -->
<!ELEMENT c (#PCDATA)>
<!-- Inline -->
<!-- Layout customizable: CHILDREN -->
<!ELEMENT em (#PCDATA|%text;)*>
......@@ -133,10 +140,15 @@
<!ATTLIST a
href CDATA #IMPLIED
idref IDREF #IMPLIED
type CDATA "default"
>
<!-- Generic hyperlink. Either href or idref must be specified.
The name "a" (anchor) is historical; you cannot define anchors
with this element.
The layout option is called "a.TYPE" where TYPE is the string
given in the "type" attribute. When the href is missing, TYPE
is always "emptyref". The layout has access to vars HREF and CHILDREN.
-->
......@@ -146,6 +158,9 @@
>
<!-- Expands to a hyperlink containing the number of the picture
(or page).
The layout option is "numref.emptyref" if the href is missing,
but normally "numref.default". Vars HREF and NUMBER.
-->
<!ELEMENT nameref EMPTY>
......@@ -155,6 +170,9 @@
<!-- Expands to a hyperlink containing the name of the object.
For pages: The title of the page.
For pictures: The caption of the picture.
The layout option is "nameref.emptyref" if the href is missing,
but normally "nameref.default". Vars HREF and TITLE.
-->
<!ELEMENT html (#PCDATA)*>
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE presentation SYSTEM "../presentation.dtd">
<!DOCTYPE presentation PUBLIC "-//GERD STOLPMANN//DTD PRESENTATION 1.0//EN" "">
<presentation>
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE presentation SYSTEM "../presentation.dtd">
<!DOCTYPE presentation PUBLIC "-//GERD STOLPMANN//DTD PRESENTATION 1.0//EN" "">
<presentation>
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE presentation SYSTEM "../presentation.dtd">
<!DOCTYPE presentation PUBLIC "-//GERD STOLPMANN//DTD PRESENTATION 1.0//EN" "">
<presentation>
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE presentation SYSTEM "../presentation.dtd">
<!DOCTYPE presentation PUBLIC "-//GERD STOLPMANN//DTD PRESENTATION 1.0//EN" "">
<presentation>
......
......@@ -125,8 +125,10 @@ type find_id =
;;
(* The default page layout does neither support navigation trees nor related links *)
let std_layout_decls = Hashtbl.create 21;;
Hashtbl.add std_layout_decls "page" "<html><body>@CHILDREN@</body></html>\n";
Hashtbl.add std_layout_decls "page" "<html><body>@CHILDREN@@FOOTER@</body></html>\n";
Hashtbl.add std_layout_decls "sect1" "<h1>@TITLE@</h1>\n@CHILDREN@";
Hashtbl.add std_layout_decls "sect2" "<h2>@TITLE@</h2>\n@CHILDREN@";
Hashtbl.add std_layout_decls "sect3" "<h3>@TITLE@</h3>\n@CHILDREN@";
......@@ -135,9 +137,18 @@ Hashtbl.add std_layout_decls "br" "<br>\n";
Hashtbl.add std_layout_decls "em" "<b>@CHILDREN@</b>";
Hashtbl.add std_layout_decls "ul" "<ul>@CHILDREN@</ul>";
Hashtbl.add std_layout_decls "li" "<li>@CHILDREN@</li>";
Hashtbl.add std_layout_decls "footnote.text" "";
Hashtbl.add std_layout_decls "footnote.foot" "";
Hashtbl.add std_layout_decls "code" "<p><pre>@CHILDREN@</pre></p>";
Hashtbl.add std_layout_decls "c" "<tt>@CHILDREN@</tt>";
Hashtbl.add std_layout_decls "a.emptyref" "@CHILDREN@";
Hashtbl.add std_layout_decls "a.default" "<a href=\"@HREF@\">@CHILDREN@</a>";
Hashtbl.add std_layout_decls "numref.emptyref" "@CHILDREN@";
Hashtbl.add std_layout_decls "numref.default" "<a href=\"@HREF@\">@NUMBER@</a>";
Hashtbl.add std_layout_decls "nameref.emptyref" "@CHILDREN@";
Hashtbl.add std_layout_decls "nameref.default" "<a href=\"@HREF@\">@TITLE@</a>";
Hashtbl.add std_layout_decls "footer" "<hr align=left noshade=noshade width='30%'><dl>@FOOTNOTES@</dl>";
Hashtbl.add std_layout_decls "footer.empty" "";
Hashtbl.add std_layout_decls "footnote.text" "<a name=\"@TEXTANCHOR@\" href=\"#@FOOTANCHOR\">[@SYMBOL@]</a>";
Hashtbl.add std_layout_decls "footnote.foot" "<dt><a name=\"@FOOTANCHOR@\" href=\"#@TEXTANCHOR\">[@SYMBOL@]</a></dt><dd>@CHILDREN@</dd>";
(* The following decls are for backward compatibility: *)
Hashtbl.add std_layout_decls "navigator.start" "@SUBLEVELS@";
Hashtbl.add std_layout_decls "navigator.onpath" "@navigator.level@"
......@@ -990,7 +1001,7 @@ class li = map_tag "li";;
class br = map_tag "br";;
class code = (* TODO: use layout *)
class code =
object (self)
inherit shared
......@@ -1012,14 +1023,13 @@ class code = (* TODO: use layout *)
else
""
in
"<p><pre>" ^
(escape_html (preprocess 0 0)) ^
"</pre></p>";
store # instantiate_layout "code"
[ "CHILDREN", lazy (escape_html (preprocess 0 0)) ]
end
;;
class c = (* TODO: use layout *)
class c =
object (self)
inherit shared
......@@ -1040,9 +1050,8 @@ class c = (* TODO: use layout *)
else
""
in
"<tt>" ^
(preprocess 0) ^
"</tt>";
store # instantiate_layout "c"
[ "CHILDREN", lazy (preprocess 0) ]
end
;;
......@@ -1072,14 +1081,15 @@ class a =
""
end
in
"<a " ^
(if href = "" then
""
else
"href=\"" ^ href ^ "\"") ^
">" ^
(escape_html (self # node # data)) ^
"</a>";
let a_type =
if href="" then
"a.emptyref"
else
"a." ^ self # node # required_string_attribute "type" in
store # instantiate_layout a_type
[ "HREF", lazy href;
"CHILDREN", lazy (escape_html (self # node # data))
]
end
;;
......@@ -1180,15 +1190,12 @@ class numref =
in
let href =
escape_html (store # url (pic # extension # url_of_object)) in
"<a " ^
(if href = "" then
""
else
"href=\"" ^ href ^ "\"") ^
">" ^
(escape_html (pic # extension # object_number)) ^
"</a>";
let numref_type =
if href="" then "numref.emptyref" else "numref.default" in
store # instantiate_layout numref_type
[ "HREF", lazy href;
"NUMBER", lazy (escape_html (pic # extension # object_number))
]
end
;;
......@@ -1207,14 +1214,12 @@ class nameref =
in
let href =
escape_html (store # url (pic # extension # url_of_object)) in
"<a " ^
(if href = "" then
""
else
"href=\"" ^ href ^ "\"") ^
">" ^
(escape_html (pic # extension # toc_title_of_object)) ^
"</a>";
let nameref_type =
if href="" then "nameref.emptyref" else "nameref.default" in
store # instantiate_layout nameref_type
[ "HREF", lazy href;
"TITLE", lazy (escape_html (pic # extension # toc_title_of_object))
]
end
;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment