| 13 |
|
|
| 14 |
(** Input types **) |
(** Input types **) |
| 15 |
|
|
| 16 |
type Page = <page name=String new=?Any>[ <title>String <banner>[InlineText*]? Item* ] |
type Page = <page name=String new=?"">[ <title>String <banner>[InlineText*]? Item* ] |
| 17 |
type External = <external {|href=String; title=String; name=String |}>[] |
type External = <external {|href=String; title=String; name=String |}>[] |
| 18 |
|
|
| 19 |
type Item = |
type Item = |
| 20 |
<box noindex=?String title=String link=String>Content |
<box noindex=?String title=String link=String>Content |
| 21 |
| <meta>Content |
| <meta>Content |
| 22 |
| <left>Content |
| <left>Content |
| 23 |
|
| <footnotes>[] |
| 24 |
| Page |
| Page |
| 25 |
| External |
| External |
| 26 |
|
|
| 27 |
type Author = <author>String |
type Author = <author>String |
| 28 |
type Paper = |
type Paper = |
| 29 |
<paper file=?String old=?String>[ |
<paper file=?String old=?"">[ |
| 30 |
<title>String Author+ <comment>[InlineText*] <abstract>Content ] |
<title>String Author+ <comment>[InlineText*] <abstract>Content ] |
| 31 |
|
|
| 32 |
type Slides = |
type Slides = |
| 37 |
|
|
| 38 |
type Content = |
type Content = |
| 39 |
[ ( <p {|style=?String|}>[InlineText*] |
[ ( <p {|style=?String|}>[InlineText*] |
| 40 |
| <ul {||}>[<li {||}>Content +] |
| <ul {||}>[<li {||}>Content *] |
| 41 |
| <section title=String>Content |
| <section title=String>Content |
| 42 |
| <sample highlight=?"true"|"false">String |
| <sample highlight=?"true"|"false">String |
| 43 |
| <xmlsample highlight=?"true"|"false">String |
| <xmlsample highlight=?"true"|"false">String |
| 44 |
| <sessionsample highlight=?"true"|"false">String |
| <sessionsample highlight=?"true"|"false">String |
| 45 |
| H:Xtable |
| H:Xtable |
| 46 |
| Paper | Slides | Link |
| Paper | Slides | Link |
| 47 |
| <boxes-toc sections=?"">[] (* the presence optional "section" attr produces *) |
| <boxes-toc sections=?"">[] (* the optional "section" produces *) |
| 48 |
| <pages-toc sections=?"">[] (* a two-level depth toc to include also sections *) |
| <pages-toc sections=?"">[] (* a two-level toc *) |
| 49 |
| <site-toc>[] |
| <site-toc>[] |
| 50 |
| <local-links href=String>[] |
| <local-links href=String>[] |
| 51 |
| <two-columns>[ <left>Content <right>Content ] |
| <two-columns>[ <left>Content <right>Content ] |
| 52 |
| <note> Content |
| <note> Content |
| 53 |
|
| <footnotes>[] |
| 54 |
| InlineText |
| InlineText |
| 55 |
)* ] |
)* ] |
| 56 |
|
|
| 103 |
children = [Tree*]; boxes = [H:Xul?] } |
children = [Tree*]; boxes = [H:Xul?] } |
| 104 |
|
|
| 105 |
let url_of_name (String -> String) |
let url_of_name (String -> String) |
| 106 |
"index" -> "/" |
| "index" -> "/" |
| 107 |
| s -> s @ ".html" |
| s -> s @ ".html" |
| 108 |
|
|
| 109 |
let authors ([Author+] -> String) |
let authors ([Author+] -> String) |
| 128 |
with `Not_found -> raise [ 'Local link not found: ' !l ] |
with `Not_found -> raise [ 'Local link not found: ' !l ] |
| 129 |
|
|
| 130 |
let compute_sitemap ((Page|External) -> Tree) |
let compute_sitemap ((Page|External) -> Tree) |
| 131 |
<page name=name>[ <title>title (c::(Page|External) | _)* ] & p -> |
| <page name=name>[ <title>title (c::(Page|External) | _)* ] & p -> |
| 132 |
let children = map c with p -> compute_sitemap p in |
let children = map c with p -> compute_sitemap p in |
| 133 |
{ name = name; url = (url_of_name name); title = title; |
{ name = name; url = (url_of_name name); title = title; |
| 134 |
children = children; boxes = (boxes_of p) } |
children = children; boxes = (boxes_of p) } |
| 135 |
|<external name=name href=h title=t>[] -> |
|<external name=name href=h title=t>[] -> |
| 136 |
{ name = name; url = h; title = t; children = []; boxes = [] } |
{ name = name; url = h; title = t; children = []; boxes = [] } |
| 137 |
|
|
| 138 |
|
let ul([H:Xli*] -> [H:Xul?]) [] -> [] | l -> [ <ul>l ] |
| 139 |
|
|
| 140 |
let display_sitemap (h : Tree) : H:Xli = |
let display_sitemap (h : Tree) : H:Xli = |
| 141 |
let ch = map h . children with x -> display_sitemap x in |
let ch = map h . children with x -> display_sitemap x in |
| 142 |
let ch = match ch with [] -> [] | l -> [ <ul>l ] in |
<li>[ <a href=(h . url)>[ '[' !(h . title) ']' ] !(h . boxes); (ul ch) ] |
|
<li>[ <a href=(h . url)>[ '[' !(h . title) ']' ] !(h . boxes); ch ] |
|
| 143 |
|
|
| 144 |
|
|
| 145 |
let boxes_of (Page -> [H:Xul?]) |
let boxes_of (Page -> [H:Xul?]) |
| 146 |
<page name=n>[ (items::Item | _)*] -> |
<page name=n>[ (items::Item | _)*] -> |
| 147 |
let toc = |
let toc = transform items with |
| 148 |
transform items with |
| <box noindex="">_ -> [] |
| 149 |
| <box noindex=_>_ -> [] |
| <box title=t link=l>_ -> [ <li>[ <a href=[ !(url_of_name n) '#' !l ]>t ] ] |
| 150 |
| <box title=t link=l>_ -> [ <li>[ <a href=((url_of_name n)@('#',l))>t ] ] in |
in |
| 151 |
(match toc with [] -> [] | lis -> [ <ul>lis ]) |
ul toc |
| 152 |
|
|
| 153 |
let link_to (Page -> H:Xa) |
let link_to (<page name=n>[<title>t ; _ ] & p : Page) : H:Xa = |
| 154 |
<page name=n new=_>[<title>t ; _ ] -> |
let t = match p with |
| 155 |
<a href=(url_of_name n)>[!t |
| <_ new="">_ -> t @ [ <img src="img/new.gif" alt="(new)" style="border:0">[]] |
| 156 |
<img src="img/new.gif" alt="(new)" style="border:0">[]] |
| _ -> t in |
| 157 |
| <page name=n>[<title>t ; _ ] -> <a href=(url_of_name n)>t |
<a href=(url_of_name n)>t |
| 158 |
|
|
| 159 |
let box (x : H:Flow) : H:Block = |
let box (x : H:Flow) : H:Block = |
| 160 |
<table cellpadding="2" |
<table cellpadding="2" |
| 182 |
background: #FFFFD0; |
background: #FFFFD0; |
| 183 |
color: #FF0000; |
color: #FF0000; |
| 184 |
} |
} |
| 185 |
a.old, a.old:hover, a.old:visited:hover { |
a.old, a.old:hover, a.old:visited:hover { text-decoration: line-through; } |
| 186 |
text-decoration: line-through; |
p { text-align: justify; margin: 1ex 1em 0 1em; } |
| 187 |
} |
pre { margin: 1ex 1em 0 1em; } |
| 188 |
p { |
strong.ocaml{ color: #333b8e; } |
| 189 |
text-align: justify; |
strong.highlight { color: #FF0000; } |
| 190 |
margin: 1ex 1em 0 1em; |
img.icon { border: 0; } |
| 191 |
} |
div.code { background: #E0E0E0; margin: 0.5ex 0.5em 0 0.5em; padding: 0.2ex; } |
| 192 |
pre { |
div.xmlcode { background:#ebefa2; margin: 0.5ex 0.5em 0 0.5em; padding: 0.2ex;} |
|
margin: 1ex 1em 0 1em; |
|
|
} |
|
|
strong.ocaml{ |
|
|
color: #333b8e; |
|
|
} |
|
|
strong.highlight { |
|
|
color: #FF0000; |
|
|
} |
|
|
img.icon { |
|
|
border: 0; |
|
|
} |
|
|
div.code { |
|
|
background: #E0E0E0; |
|
|
margin: 0.5ex 0.5em 0 0.5em; |
|
|
padding: 0.2ex; |
|
|
} |
|
|
|
|
|
div.xmlcode { |
|
|
background: #ebefa2; |
|
|
margin: 0.5ex 0.5em 0 0.5em; |
|
|
padding: 0.2ex; |
|
|
} |
|
| 193 |
|
|
| 194 |
div.abstract { |
div.abstract { |
| 195 |
font: bold helvetica; |
font: bold helvetica; |
| 206 |
background: #D0E2D2; |
background: #D0E2D2; |
| 207 |
} |
} |
| 208 |
|
|
|
|
|
| 209 |
div.session |
div.session |
| 210 |
{ |
{ |
| 211 |
font: bold 80% helvetica; |
font: bold 80% helvetica; |
| 214 |
border: solid .5px grey; |
border: solid .5px grey; |
| 215 |
} |
} |
| 216 |
|
|
| 217 |
div.abstract p { |
div.abstract p { font: sans-serif; } |
|
font: sans-serif; |
|
|
} |
|
| 218 |
" |
" |
| 219 |
|
|
| 220 |
|
type PageO = Page | [] |
| 221 |
|
|
| 222 |
(* Main transformation function *) |
(* Main transformation function *) |
| 223 |
|
|
| 224 |
(* returns the last page of the descendance *) |
(* returns the last page of the descendance *) |
| 225 |
let gen_page (prev : Page|[], page : Page, next : Page|[], |
let gen_page (prev : PageO, page : Page, next : PageO, |
| 226 |
path : Path, sitemap : Tree) : (Page|[]) = |
path : Path, sitemap : Tree) : PageO = |
| 227 |
match page with |
match page with |
| 228 |
<page name=name>[ |
<page name=name>[ |
| 229 |
<title>title <banner>banner | <title>(title & banner); items ] -> |
<title>title <banner>banner | <title>(title & banner); items ] -> |
| 236 |
| <code>x -> [ <b>[ <tt>(highlight x) ] ] |
| <code>x -> [ <b>[ <tt>(highlight x) ] ] |
| 237 |
| <local href=l>txt -> [ (local_link (sitemap,l,txt)) ] |
| <local href=l>txt -> [ (local_link (sitemap,l,txt)) ] |
| 238 |
| <(tag & (`b|`i|`tt|`em)) (attr)>x -> [ <(tag) (attr)>(text x) ] |
| <(tag & (`b|`i|`tt|`em)) (attr)>x -> [ <(tag) (attr)>(text x) ] |
|
(* | <a href=url>_ & z -> let [] = print [ 'Link: ' !url '\n'] in [z] *) |
|
| 239 |
| <footnote>c -> |
| <footnote>c -> |
| 240 |
footnote_counter := !footnote_counter + 1; |
footnote_counter := !footnote_counter + 1; |
| 241 |
let n = string_of !footnote_counter in |
let n = string_of !footnote_counter in |
| 256 |
[ <p>[ <b style="color: #008000">title ] !(content c) ] |
[ <p>[ <b style="color: #008000">title ] !(content c) ] |
| 257 |
| <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab ] -> |
| <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab ] -> |
| 258 |
[ (match r with |
[ (match r with |
| 259 |
| { file = f; old = "true" } -> <a class="old" href=f>tit |
| { file = f; old = "" } -> <a class="old" href=f>tit |
| 260 |
| { file = f } -> <a href=f>tit |
| { file = f } -> <a href=f>tit |
| 261 |
| _ -> <b>tit) '. ' |
| _ -> <b>tit) '. ' |
| 262 |
!(authors aut) '. ' |
!(authors aut) '. ' |
| 280 |
| <link url=url title=title>com -> |
| <link url=url title=title>com -> |
| 281 |
[ <a href=url>title '. ' !(text com) ] |
[ <a href=url>title '. ' !(text com) ] |
| 282 |
| <ul>lis -> |
| <ul>lis -> |
| 283 |
[ <ul>(map lis with <li>x -> <li>(content x)) ] |
ul (map lis with <li>x -> <li>(content x)) |
| 284 |
| H:Xtable & x -> |
| H:Xtable & x -> |
| 285 |
[ x ] |
[ x ] |
| 286 |
| <p (attr)>x -> [ <p (attr)>(text x) ] |
| <p (attr)>x -> [ <p (attr)>(text x) ] |
| 287 |
| <pages-toc (a)>[] -> |
| <pages-toc (a)>[] -> |
| 288 |
let toc = |
let toc = transform items with |
| 289 |
transform items with |
| Page & p -> |
| 290 |
| Page & p -> [ <li>[ (link_to p) |
let sects = match a with {|sections=_|} -> boxes_of p | _ -> [] in |
| 291 |
!(match a with {|sections=_|} -> (boxes_of p) | _ -> [])] ] |
[ <li>[ (link_to p) ; sects ] ] |
| 292 |
| <external href=l title=t>[] -> [ <li>[ <a href=l>t ] ] in |
| <external href=l title=t>[] -> [ <li>[ <a href=l>t ] ] in |
| 293 |
(match toc with [] -> [] | lis -> [ <ul>lis ]) |
ul toc |
| 294 |
| <boxes-toc (a)>[] -> |
| <boxes-toc (a)>[] -> |
| 295 |
let toc = |
let toc = transform items with |
|
transform items with |
|
| 296 |
| <box noindex=_>_ -> [] |
| <box noindex=_>_ -> [] |
| 297 |
| <box title=t link=l>b -> [ <li>[ <a href=('#',l)>t |
| <box title=t link=l>b -> |
| 298 |
!(match a with |
let sects = match a with |
| 299 |
| {|sections=_|} -> |
| {|sections=_|} -> |
| 300 |
(transform b with <section title=t>_ -> [<br>[] '-' !t]) |
(transform b with <section title=t>_ -> [<br>[] '-' !t]) |
| 301 |
| _ ->[])]] |
| _ -> [] in |
| 302 |
in (match toc with [] -> [] | lis -> [ <ul>lis ]) |
[ <li>[ <a href=('#',l)>t !sects ]] in |
| 303 |
|
ul toc |
| 304 |
| <site-toc>[] -> |
| <site-toc>[] -> |
| 305 |
[ <ul>[ (display_sitemap sitemap) ] ] |
[ <ul>[ (display_sitemap sitemap) ] ] |
| 306 |
| <local-links href=s>[] -> |
| <local-links href=s>[] -> |
| 307 |
(match (split_comma s) with |
ul (map (split_comma s) with x -> <li>[ (local_link(sitemap,x,"")) ]) |
|
| [] -> [] |
|
|
| l -> let l = map l with x -> <li>[ (local_link(sitemap,x,"")) ] |
|
|
in [ <ul>l ]) |
|
| 308 |
| <two-columns>[ <left>x <right>y ] -> |
| <two-columns>[ <left>x <right>y ] -> |
| 309 |
[ <table width="100%">[ |
[ <table width="100%">[ |
| 310 |
<tr>[ |
<tr>[ |
| 311 |
<td valign="top">(content x) |
<td valign="top">(content x) |
| 312 |
<td valign="top">(content y) ] ] ] |
<td valign="top">(content y) ] ] ] |
| 313 |
| <note> c -> [ <div class="note">[ <b>"Note: " !(content c) ]] |
| <note> c -> [ <div class="note">[ <b>"Note: " !(content c) ]] |
| 314 |
|
| <footnotes>[] -> |
| 315 |
|
(match !footnotes with |
| 316 |
|
| [] -> [] |
| 317 |
|
| n -> footnotes := []; [ <br>[] (meta n) ] ) |
| 318 |
| t -> text [ t ] |
| t -> text [ t ] |
| 319 |
in |
in |
| 320 |
|
|
| 359 |
(* Preparing main panel *) |
(* Preparing main panel *) |
| 360 |
let main = transform items with |
let main = transform items with |
| 361 |
| <box (r)>c -> [ (box_title (content c, r . link, r . title)) ] |
| <box (r)>c -> [ (box_title (content c, r . link, r . title)) ] |
| 362 |
|
| <footnotes>[] -> |
| 363 |
|
(match !footnotes with |
| 364 |
|
| [] -> [] |
| 365 |
|
| n -> footnotes := []; [ (meta n) ] ) |
| 366 |
| <meta>c -> [ (meta (content c)) ] |
| <meta>c -> [ (meta (content c)) ] |
| 367 |
in |
in |
| 368 |
let notes = match !footnotes with |
let notes = match !footnotes with |
| 413 |
|
|
| 414 |
|
|
| 415 |
let gen_page_seq |
let gen_page_seq |
| 416 |
(prev : Page|[], pages : [Page*], next : Page|[], |
(prev : PageO, pages : [Page*], next : PageO, |
| 417 |
path : Path, sitemap : Tree) : (Page|[], Page|[]) = |
path : Path, sitemap : Tree) : (PageO, PageO) = |
| 418 |
match pages with |
match pages with |
| 419 |
| [ p1 p2 ; _ ] & [ _; rest ] -> |
| [ p1 p2 ; _ ] & [ _; rest ] -> |
| 420 |
let last = gen_page (prev,p1,p2, path, sitemap) in |
let last = gen_page (prev,p1,p2, path, sitemap) in |