Commit bd5109a2 authored by gerd's avatar gerd

New: to_latex


git-svn-id: https://godirepo.camlcity.org/svn/app-presentation/trunk@7 50e5f3cf-a9f2-0310-83d8-d11ec64cb5ab
parent 3d0ffebf
......@@ -42,3 +42,7 @@ install:
echo 'exec $(LIB)/presentation "$$@"' >>$(BIN)/presentation
chmod 775 $(BIN)/presentation
.PHONY: install.opt
install.opt:
$(MAKE) install
cp presentation.bin.opt $(LIB)/presentation.bin
#----------------------------------------------------------------------
# specific rules for this package:
OBJECTS = to_html.cmo
OBJECTS = to_html.cmo to_latex.cmo
XOBJECTS = $(OBJECTS:.cmo=.cmx)
ARCHIVE = presentation.cma
XARCHIVE = presentation.cmxa
......
(* $Id: main.ml,v 1.4 2002/02/14 16:46:33 gerd Exp $
(* $Id: main.ml,v 1.5 2003/02/24 01:24:47 gerd Exp $
* ----------------------------------------------------------------------
*
*)
......@@ -20,7 +20,7 @@ let run f x =
;;
let convert_to_html filename no_gifs remove_prefix =
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 =
......@@ -41,22 +41,59 @@ let convert_to_html filename no_gifs remove_prefix =
;;
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 dirname = Filename.dirname filename in
let outname = Filename.chop_extension (Filename.basename filename) ^ ".tex" in
let out = open_out outname in
let root = document # root in
root # extension # enumerate_pages 0;
ignore(root # extension # enumerate_pictures 1);
root # extension # set_dirname dirname;
root # extension # set_option "use_ocamldoc" (string_of_bool use_ocamldoc);
( match front_file with
Some f -> root # extension # set_option "front_file" f
| None -> ()
);
let hier = root # extension # collect_hierarchy idx "" in
root # extension # print_pages out idx hier
;;
let main() =
let no_gifs = ref false in
let remove = ref "" in
let ocamldoc = ref false in
let front_file = ref None in
let filename = ref None in
let action = ref (fun filename -> convert_to_html !no_gifs !remove filename) in
Arg.parse
[ "-nogifs", Arg.Set no_gifs,
" do not invoke THE GIMP to create icons";
"-remove", Arg.String (fun s -> remove := s),
" remove this prefix from all URLs";
"<prefix> remove this prefix from all URLs";
"-latex", Arg.Unit (fun _ -> action :=
(fun fn -> convert_to_latex !ocamldoc !front_file fn)),
" output LateX code instead of HTML";
"-ocamldoc", Arg.Set ocamldoc,
" [Latex:] include the ocamldoc package";
"-front", Arg.String (fun s -> front_file := Some s),
"<file> [Latex:] include this file first";
]
(fun s ->
match !filename with
None -> filename := Some s
| Some _ ->
raise (Arg.Bad "Multiple arguments not allowed."))
"usage: presentation [ -nogifs ] [ -remove <prefix> ] input.xml";
"usage: presentation [options] input.xml";
let fn =
match !filename with
None ->
......@@ -64,7 +101,7 @@ let main() =
exit 1
| Some s -> s
in
run (convert_to_html fn !no_gifs) !remove
run !action fn
;;
main();;
......@@ -73,6 +110,9 @@ main();;
* History:
*
* $Log: main.ml,v $
* Revision 1.5 2003/02/24 01:24:47 gerd
* New: to_latex
*
* Revision 1.4 2002/02/14 16:46:33 gerd
* Updates
*
......
......@@ -16,7 +16,7 @@ echo "*** Creating $2"
rm -f "$2"
test -f "$2" && exit 1 # If I can't write in this directory, exit now
gimp -n -b "(begin (load \"$PRESENTATION/make-headline.scm\") (make-headline \"$1\" \"$2\" \"$3\" $4 \"$5\" \"$6\" \"$7\" \"$8\" \"$9\" ))" '(gimp-quit 0)'
gimp --no-interface --batch "(begin (load \"$PRESENTATION/make-headline.scm\") (make-headline \"$1\" \"$2\" \"$3\" $4 \"$5\" \"$6\" \"$7\" \"$8\" \"$9\" ))" '(gimp-quit 0)'
# The exit code of this script is the code of the following test:
test -f "$2"
<!-- $Id: presentation.dtd,v 1.3 2002/02/14 16:46:33 gerd Exp $ -->
<!-- $Id: presentation.dtd,v 1.4 2003/02/24 01:24:47 gerd Exp $ -->
<!ENTITY % p.like "p|ul|picture">
<!ENTITY % text "br|code|c|em|footnote|a|numref|nameref|html">
<!ENTITY % text "br|code|c|em|footnote|a|numref|nameref|html|latex">
<!ENTITY % layout "layout|headline-layout">
<!ELEMENT presentation ((%layout;)*,hierarchy,page+)>
......@@ -44,6 +44,7 @@
title CDATA #REQUIRED
id ID #IMPLIED
file CDATA #IMPLIED
for-latex (yes|no) "yes"
>
<!-- Layout customizable:
"page":
......@@ -155,3 +156,6 @@
<!ELEMENT html (#PCDATA)*>
<!-- Includes the text as it is -->
<!ELEMENT latex (#PCDATA)*>
<!-- Includes the text as it is -->
(* $Id: to_html.ml,v 1.5 2002/02/14 16:46:33 gerd Exp $
(* $Id: to_html.ml,v 1.6 2003/02/24 01:24:47 gerd Exp $
* ----------------------------------------------------------------------
*
*)
......@@ -383,6 +383,16 @@ class html =
;;
class latex =
object (self)
inherit shared
method to_html store idx =
""
end
;;
class no_markup =
object (self)
inherit shared
......@@ -650,12 +660,13 @@ class page =
Not_found -> assert false
in
let sublevels l =
let sublevels p l =
map'n'concat
(fun h ->
store # instantiate_layout "navigator.child"
[ "LEVELTITLE", lazy (escape_html h.title);
"LEVELURL", lazy (escape_html (store # url h.pagelink));
"UPURL", lazy (escape_html (store # url p.pagelink));
])
l
in
......@@ -670,7 +681,8 @@ class page =
store # instantiate_layout lname
[ "LEVELTITLE", lazy (escape_html h.title);
"LEVELURL", lazy (escape_html (store # url h.pagelink));
"SUBLEVELS", lazy (sublevels h.children );
"SUBLEVELS", lazy (sublevels h h.children );
"UPURL", lazy (escape_html (store # url hier_parent.pagelink));
])
hier_parent.children
in
......@@ -1110,6 +1122,7 @@ let tag_map =
"numref", (new element_impl (new numref));
"nameref", (new element_impl (new nameref));
"html", (new element_impl (new html));
"latex", (new element_impl (new latex));
]
()
;;
......@@ -1119,6 +1132,9 @@ let tag_map =
* History:
*
* $Log: to_html.ml,v $
* Revision 1.6 2003/02/24 01:24:47 gerd
* New: to_latex
*
* Revision 1.5 2002/02/14 16:46:33 gerd
* Updates
*
......
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