Commit 300679a7 authored by Pietro Abate's avatar Pietro Abate

[r2005-04-21 15:14:18 by mburelle] Add numbering of sections and pages, add...

[r2005-04-21 15:14:18 by mburelle] Add numbering of sections and pages, add table of contents. Add also
the CDuce logo in front of the manual ...  Marwan.

Original author: mburelle
Date: 2005-04-21 15:14:18+00:00
parent ba1e2687
......@@ -4,6 +4,66 @@ include "../../web/siteTypes.cd";;
(* Output Types *)
include "fo_dtd.cd";;
(* Heading numbering *)
type heading = <heading>[Int heading?]
let heading2string
(heading -> [PCDATA])
| <heading>[x] -> string_of x
| <heading>[x h] ->
[!(string_of x) '.' ;(heading2string h)]
let incHeading
(heading -> heading)
| <heading>[x] -> <heading>[(x + 1)]
| <heading>[x h] -> <heading>[x (incHeading h)]
let newHLevel
(heading -> heading)
| <heading>[x] -> <heading>[x <heading>[0]]
| <heading>[x h] -> <heading>[x (newHLevel h)]
(* Table of contents *)
type Entry =
<entry toc_id=String toc_title=String toc_head=heading>[Entry*]
| <entry_page toc_id=String toc_title=String toc_head=heading>[Entry*]
let local_toc = ref [Entry?] []
let new_entry_toc (nid : String , ntitle : String , nhead : heading) : Entry =
<entry toc_id=nid toc_title=ntitle toc_head=nhead>[]
let new_entry_page_toc (nid : String , ntitle : String , nhead : heading) : Entry =
<entry_page toc_id=nid toc_title=ntitle toc_head=nhead>[]
let add_entry_toc (toc : [Entry?] , new : [Entry?]) : [Entry?] =
match toc with
| [] -> new
| [<entry (attr)>l] -> [<entry (attr)>[!l !new]]
| [<entry_page (attr)>l] -> [<entry_page (attr)>[!l !new]]
let toc_entry2fo ([Entry*] -> [block*]) x ->
transform x with
| <entry toc_id=tid toc_title=tt toc_head=thead>le ->
[<fo:block font-size="12pt" space-before="10pt" space-after="7pt" font-weight="bold">[
!(heading2string thead) ' ' !tt ' '
<fo:page-number-citation ref-id=tid>[]
]
!(toc_entry2fo le)
]
| <entry_page toc_id=tid toc_title=tt toc_head=thead>le ->
[<fo:block font-size="18pt" font-weight="bold" space-after="7pt" space-before="10pt">[
!(heading2string thead) ' ' !tt ' '
<fo:page-number-citation ref-id=tid>[]
]
!(toc_entry2fo le)
]
let out_global_toc (toc : [Entry?]) : [block*] = [
<fo:block break-before="page">[]
<fo:block font-size="22pt" font-weight="bold" space-before="18pt">"Table of Contents"
!(toc_entry2fo toc)
]
(** Command line **)
......@@ -219,6 +279,50 @@ let readItem (it : [Item+]): [block*] =
]]
| _ -> raise "ERROR"
(* adding heading numbering ... *)
let readItemHead (([Item+],heading) -> [block*]) (it,head) ->
let href = ref heading head in
transform it with
| <box title=t link=x>c ->
let _ = href := incHeading !href in
let box_entry = new_entry_toc (x,t,!href) in
let saved_toc = !local_toc in let _ = local_toc := [box_entry] in
let result = [<fo:block id=x>[
<fo:block font-size="22pt" space-before="15pt">[
<fo:block space-after="7pt" font-weight="bold">[!(heading2string !href) ' ' !t]] !(content c)
]
] in
let new_toc = add_entry_toc (saved_toc,!local_toc) in
local_toc := new_toc ;
result
| <box>c -> [<fo:block>[!(content c)]]
| <meta>c -> (* non utilise pour manuel et tutoriel*)
[<fo:block>[!(content c)]]
| <left>_ -> [<fo:block>[]]
| <footnotes>[] -> [<fo:block>[ ]]
| <page .. > [(<title>_) (<banner>_)? ] -> [<fo:block>['box vide!!!!!!!!!!!!!']]
| <page name=x >[(<title>title1 (<banner>_)? litem::Item+)] ->
let _ = href := incHeading !href in
let box_entry = new_entry_page_toc (x,title1,!href) in
let saved_toc = !local_toc in let _ = local_toc := [box_entry] in
let result = [<fo:block id=x break-before="page" text-align-last="justify">[
<fo:block text-align="left">[
<fo:block font-size="32pt"
font-weight="bold"
space-after="40pt"
space-before="85pt"
color="black" >[
!(heading2string !href) ' ' !title1
]
] !(readItemHead (litem,newHLevel !href))
]
] in
let new_toc = add_entry_toc (saved_toc,!local_toc) in
local_toc := new_toc ;
result
| _ -> raise "ERROR"
let gen_page (page : Page, cduce_version : Latin1) : [block+] =
match page with
(* le cas sans item*)
......@@ -237,6 +341,28 @@ let gen_page (page : Page, cduce_version : Latin1) : [block+] =
!(readItem litem)]
in sortie)
(* adding heading numbering *)
let gen_pageHead (page : Page, cduce_version : Latin1) : [block+] =
match page with
(* le cas sans item*)
<page ..>[(<title>_) (<banner>_)?] -> [<fo:block text-align="center" font-size="35pt" color="green" space-after="30pt">
(raise "error") ]
(* la cas de base *)
|<page ..>[(<title>title1 (<banner>_)? litem::Item+)] -> (
let head = <heading>[0] in
let rIH = (readItemHead (litem, head)) in
let sortie : [block+]= [
<fo:block text-align="center" space-before="80pt">[
<fo:external-graphic src="url(img/cduce_logo.jpg)">[]
<fo:block font-size="35pt" font-weight="bold" space-before="30pt">"CDuce Programming Language"
<fo:block font-size="35pt" font-weight="bold" space-after="20pt">[!title1]
<fo:block font-size="18pt" font-weight="bold">("Language Version "@cduce_version)
]
!(out_global_toc !local_toc)
!rIH
]
in sortie)
let load_include (Latin1 -> [Any*])
......@@ -259,7 +385,7 @@ match argv [] with
margin-bottom="3.5cm"
margin-left="2.5cm"
margin-right="2.5cm">[]
<fo:region-after extent="15mm">[]
<fo:region-after region-name="footer" extent="15mm">[]
]
]
<fo:page-sequence initial-page-number="auto" master-reference="essai" >[
......@@ -269,11 +395,15 @@ match argv [] with
leader-length="100%"
rule-style="solid"
rule-thickness="0.5pt">[]]]
<fo:static-content flow-name="footer">[
<fo:block text-align="center">[<fo:page-number>[]]
]
<fo:flow
flow-name="xsl-region-body"
font-size="12pt"
text-align="justify"> [!(gen_page(main_page,cduce_version))] ]] in
dump_to_file ("../doc/fomanual/"@out_file)
text-align="justify"> [!(gen_pageHead(main_page,cduce_version))] ]] in
(* dump_to_file ("../doc/fomanual/"@out_file) *)
dump_to_file (out_file)
['<?xml version="1.0" encoding="ISO-8859-1"?>' !(print_xml DebutFo)]
(*print(print_xml(main_page));*)
(* print (gen_page main_page)*)
......
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