Commit 32dc25c5 authored by Pietro Abate's avatar Pietro Abate

[r2005-03-26 15:35:40 by beppe] Added file to produce pdf documentation

Original author: beppe
Date: 2005-03-26 15:35:40+00:00
parent 41dce045
(** Input types **)
type Page = <page name=Latin1 url=?String new=?"" leftbar=?("true"|"false")>[<title>String Item* ]
type Item =
<box ({| title=String; link=String; short=?String |} | {| |})>Content
| <meta>Content
| <left>Content
| <footnotes>[]
| Page
type Author = <author presenter=?("yes"|"no")>String
type Paper =
<paper file=?String old=?"">[
<title>String Author+ <comment>[InlineText*] <abstract>Content ]
type Slides =
<slides file=String>[ <title>String Author+ <comment>[InlineText*] ]
type Link =
<link url=String title=String>[ InlineText* ]
type Table=
<table {|border=?String; style=?String|}>[Tr*]
type Tr =
<tr>[(Td|Th)*]
type Td =
<td>[InlineText*]
type Th =
<th>[InlineText*]
type Content =
[ ( <p {|style=?String|}>[InlineText*]
| <ul {||}>[<li {||}>Content *]
| <ol {|style=?String|}>[<li {||}>Content *]
| <br>[]
| <section title=String>Content
| <sample highlight=?"true"|"false">String
| <xmlsample highlight=?"true"|"false">String
| <sessionsample highlight=?"true"|"false">String
| Paper | Slides | Link
| <boxes-toc short=?"" sections=?"">[]
| <pages-toc sections=?"">[]
| <site-toc>[]
| <local-links href=String>[]
| <two-columns>[ <left>Content <right>Content ]
| <note title=?String> Content
| <footnotes>[]
| <demo label=?String prefix=?String>String
| InlineText
| Table
)* ]
type InlineText =
Char
| <(`b|`i|`tt|`em) {| style=?String |}>[InlineText*]
| <code>String
| <local href=String>String
|<a href=String>String
| <footnote>[InlineText*]
|<br>[]
(* This type has been automatically generated from DTD_XSLFO.dtd by dtd2cduce *)
namespace fo = "http://www.w3.org/1999/XSL/Format"
type declarations = <fo:declarations {|fo:color-profile=?String|}>[ Any* ];;
type block =
<fo:block {|space-after=?String;
space-before=?String;
font-weight=?String;
text-align=?String;
text-align-last=?String;
font-size=?String;
font-family=?("Helvetica" | "TimesNewRoman" | "Courier");
color=?String;
background-color=?String;
border-style=?String;
font-style=?String ;
linefeed-treatment=?("preserve"|"ignore");
margin-bottom=?String;
margin-left=?String;
white-space-collapse=?("false"|"true");
white-space-treatment=?("preserve"|"ignore")|}>[
Any* ];;
type line = <fo:inline {|text-decoration=?String; color=?String; font-weight=?String; font-style=?String|}>[Any*];;
type flow = <fo:flow {|flow-name=String; font-size=String|}>[ block* ];;
type static-content = <fo:static-content {||}>[ block* ];;
type page-sequence =
<fo:page-sequence {|master-reference=String|}>[ ( static-content? flow?) ];;
type repeatable-page-master-alternatives =
<fo:repeatable-page-master-alternatives {|conditional-page-master-reference=?String|}>[
Any* ];;
type page-sequence-master =
<fo:page-sequence-master {|repeatable-page-master-reference=?String; single-page-master-reference=?String|}>[
repeatable-page-master-alternatives ];;
type region-body=
<fo:region-body {|margin-top=?String; margin-bottom=?String; margin-left=?String; margin-right=?String|}>[Any*];;
type simple-page-master =
<fo:simple-page-master {|master-name=String; page-height=String; page-width=String; region-end=?String; region-after=?String; region-start=?String; region-body=?String; fo:region-before=?String|}>[
(region-body Any*) ];;
type layout-master-set =
<fo:layout-master-set {||}>[
(simple-page-master page-sequence-master?) ];;
type root =
<fo:root {|font-size=?String|}>[
(layout-master-set declarations? page-sequence) ];;
include "inputType.cd";;
include "typeFO.cd";;
(** Command line **)
(* Highlighting text between {{...}} *)
let highlight (String -> [ (Char)* ] )
| [ '{{%%' h ::(Char ) '%%}}' ; rest ] ->
h @ highlight rest
| [ '{{' h ::(Char *?) '}}' ; rest ] ->
h @ highlight rest
| [ '$$%%' h ::(Char *?) '%%$$' ; rest ] ->
h @ highlight rest
| [ '$$' h ::(Char *?) '$$' ; rest ] ->
h @ highlight rest
| [ '%%' h ::(Char *?) '%%' ; rest ] ->
h @ highlight rest
| [ c ; rest ] -> [c ; highlight rest]
| [] -> []
let text (t : [InlineText*]) : [(block|Char|line)*] =
transform t with
|<b style=_>s2 ->[<fo:block text-align="left" (*color="blue"*) font-weight="bold">[!(text s2)]]
|<b>s2 -> [<fo:block text-align="left" (*color="blue"*) font-weight="bold">[!(text s2)]]
|<i style=_>s2 -> [<fo:block text-align="left" (*color="yellow"*) font-style="italic">[!(text s2)]]
|<i>s2 -> [<fo:block text-align="left" color="yellow" font-style="italic">[!(text s2)]]
|<tt style=_>s2 -> [<fo:block text-align="left" font-family="Courier" color="green" >[!(text s2)]]
|<tt>s2 -> [<fo:block text-align="left" font-family="Courier" color="green">[!(text s2)]]
|<em style=_>s2 -> [<fo:block text-align="center" color="pink" font-style="italic">[!(text s2)]]
|<em>s2 -> [<fo:inline color="blue" font-weight="bold" font-style="italic">[!(text s2)]]
| z & Char -> [z]
| <code>x -> (*[<fo:block text-align="center" color="blue">*)[<fo:inline color="red" font-weight="bold" font-style="italic" >[ !(highlight x)] ](*]*)
| <local href=_>s2 -> [<fo:inline color="pink" font-weight="bold" font-style="italic">[!(text s2)]](*['lien non encore implemente local href']*)
| <a href=_>s2 ->[<fo:inline color="pink" font-weight="bold" font-style="italic">[!(text s2)]] (*['lien non encore implemente a href']*)
|<footnote>t -> [<fo:block>[!(text t)]]
let content (t : Content) : [(block|Char|line)*] =
transform t with
| <section title=title1>c -> [<fo:block>[<fo:block>[title1] !(content c) ]]
| ((<sample >s) | <sample highlight="false">s)
-> [<fo:block font-family="Courier"
font-size="10pt"
linefeed-treatment="preserve"
white-space-collapse="false"
white-space-treatment="preserve"
background-color="lightgray"
border-style="dashed"
margin-bottom="3pt"
margin-left="3pt"
space-after="10pt">[!(highlight s)]]
| <p>x -> [<fo:block space-after="15pt">[!(text x)]]
| <ul>u -> ( transform u with
<li>c -> [<fo:block>[ !(content c) ]])
| <ol>o -> ( transform o with
<li>c -> [<fo:block>[ !(content c) ]])
|((<xmlsample >s) | <xmlsample highlight="false">s) -> [<fo:block>[!(highlight s)]]
|((<sessionsample >s) | <sessionsample highlight="false">s) -> [<fo:block>[!(highlight s)]]
| p & Paper -> (paper p)
| l & Link -> (link l)
| s & Slides -> (slides s)
| i & InlineText -> (text [i])
| <boxes-toc>_ -> [<fo:block>['A FAIRE BOX TOC']]
| <pages-toc>_ ->[<fo:block>['A FAIRE PAGES TOC']]
| <site-toc>_ -> [<fo:block>['A FAIRE SITE TOC']]
| <local-links>_ -> [<fo:block>['A FAIRE LOCAL LINKS']]
| <two-columns>_ -> [<fo:block>['A FAIRE TWO COLUMNS']]
| <note>_ -> [<fo:block>['A FAIRE NOTE']]
| <footnotes>_ -> [<fo:block>['A FAIRE FOOTNOTE']]
| <demo>_ -> [<fo:block>['A FAIRE DEMO LABEL']]
| _ -> [<fo:block>['A FAIREEEEEEEEEEEEEEEEEEE COntent']]
let paper (p : Paper) : [block*] =
match p with
_ -> [<fo:block>['A FAIRE PAPER']]
let link (l : Link) : [block*] =
match l with
_ -> [<fo:block>['A FAIRE LINK']]
let slides (s : Slides) : [block*] =
match s with
_ -> [<fo:block>['A FAIRE SLIDE']]
let ma (it : [Item]) : block =
match it with
| [<box title=t link=_>c] -> <fo:block>[<fo:block font-size="22pt" space-after="15pt" color="blue">[<fo:inline text-decoration="underline" font-weight="bold">[t]] !(content c)]
| [<box {||}>c] -> <fo:block>[!(content c)]
| [<meta>c] -> (* non utilise pour manuel et tutoriel*)<fo:block>[!(content c)]
| [<left>c] -> <fo:block>[!(content c)]
| [<footnotes>[]] -> <fo:block>[ ]
| [<page name=_ > [(<title>_)]] -> <fo:block>['box vide!!!!!!!!!!!!!']
| [<page name=_ >[(<title>title1 litem::Item+)]] ->
<fo:block text-align-last="justify">[<fo:block text-align="center">[
<fo:block font-size="30pt" space-after="15pt" space-before="15pt" color="indigo" >[
<fo:inline text-decoration="underline">[title1]]
] !(lireItem litem)
]
(*lireItem lit une sequence de bloc et applique*)
(*la fonction "ma" sur chaque item*)
let lireItem ([Item+] -> [block*])
|[it::Item]-> [(ma it)]
| [it::Item ; it2 ] -> [(ma it)] @ (lireItem it2)
let gen_page (page : Page) : [block*] =
match page with
(* le cas sans item*)
<page name=_>[(<title>_)] -> [<fo:block text-align="center" font-size="35pt" color="green" space-after="30pt">
["err"] ]
(* la cas de base *)
|<page name=_ >[(<title>title1 litem::Item+)] ->(
let sortie : [block+]=
[
<fo:block text-align="center" font-size="35pt" color="orange" space-after="30pt">[
<fo:inline text-decoration="underline">[title1]
]
!(lireItem litem)]
in sortie)
let load_include (Latin1 -> [Any*])
name ->
(* let _ = print [ 'Loading ' !name '... \n' ] in *)
xtransform [ (load_xml name) ] with
| <include file=(s & Latin1)>[] -> load_include s
| <include-verbatim file=(s & Latin1)>[] -> load_file s
in
match argv [] with
| [a & Latin1 ] -> (
try
let ([ main_page ]) =
(load_include a :? [ Page ])
in
let DebutFo : root = <fo:root >[<fo:layout-master-set>[
<fo:simple-page-master master-name="essai" page-height="29.7cm" page-width="21cm">[<fo:region-body margin-top="2cm" margin-bottom="2.5cm"
margin-left="2.5cm" margin-right="2.5cm">[]
]
]
<fo:page-sequence master-reference="essai" >[
<fo:flow flow-name="xsl-region-body" font-size="12pt"> [!(gen_page main_page)] ]] in
print (print_xml DebutFo)
(*print_utf8 (['<?xml version="1.0" encoding="iso-8859-1"?>'] @ print(!(print_xml DebutFo))) *)
(*print(print_xml(main_page));*)
(* print (gen_page main_page)*)
with err & Latin1 ->
print ['Invalide input document\n' !err '\n'];
exit 2
)
| _ -> print_utf8 ("a pa trouve:");raise "erreur arg ";;
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