to_html.anubis 52.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113

   
   


                                    The Anubis project. 
   
                               Producing HTML/Javascript code. 
   
                              Copyright (c) Alain Prouté 2004.
   

   
   
   
   
   *** 1. Managing Web Arguments.
   *** 2. HTML Structure
      *** 2.1 Body of a HTML page
      *** 2.2 HTML pages
         *** 2.2.1 Definition of HTML_Page
         *** 2.2.2 Convenience fuctions
      *** 2.3 HTML_Element & HTML_Form
   *** 3. Convenience functions
      *** 3.1 for HTML_Element & HTML Form
      *** 3.2 for HTML_Form
      *** 3.4 Empty cells & empty rows
      *** 3.5 Spacers
   
   
read tools/basis.anubis
   
   
   *** 1. Managing Web Arguments.
   ******************************
   
   
   When a client submits a form, he  sends informations to the server. This information is
   transformed by the server into a list of data of type 'Web_arg'. This is the reason why
   a 'web page' operation always has a unique argument of type 'List(Web_arg)'.

   The type 'Web_arg' is defined in 'web/common.anubis' as follows:
     
         public type Web_arg:
           web_arg(String name, 
                   String value),
           upload (String name, 
                   String value, 
                   String temp_file_path). 

read web/common.anubis   
   
   In other words, a  'web argument' is just a pair made of the  name of the argument, and
   the value of  the argument, and both are character strings.  'upload' will be explained
   later.

   Of course, within the body of a 'web page' operation, you may want to recover the value
   of a  particular web argument.  To that end,  use the operation  'web_arg_value', which
   takes 2 argument:
   
    - the list of all web arguments (the operand of the web page operation), 
    - the name of the argument whose value is wanted. 

   This operation has the following return type:

 public type Web_arg_value:
   not_found, 
   found(String value). 

   If  the   requested  argument  name   is  not  found   in  the  list,   'not_found'  is
   returned. Otherwise,  the value  returned by 'web_arg_value'  has the  form 'found(v)',
   where 'v' is the value of the argument.

   The operation 'web_arg_value' is defined below. 

public define Web_arg_value
   web_arg_value
     (
       List(Web_arg) l,
       String name
     ).
   
   


   *** 2. HTML Structure
   *********************
   
   HTML_Element are all  elements ou can find  in an HTML page :  text, table, image,form,
   link,... execept input and submit elements which are reserved for HTML_Form.
   
   HTML_Form has also as alternatives text, table,image,...
   
   Seperate those two kinds element gives  the opportunity to avoid to have several 'form'
   in  one HTML_Element,  links  into form,...  all  kinds of  things  that could  disturb
   browsers mind.
   
   
public type HTML_Item:
  HTML_Item & HTML_Item,...

public type HTML_Element:
  HTML_Element & HTML_Element,...

public type HTML_Form:
  HTML_Form & HTML_Form,...

   
      *** 2.1 Body of a HTML page
      ***************************

public type Body_Option:
   background_color                /* color for the background */
     (
       RGB
     ),
   background_image                /* name of image file for the background */ 
     (
       String file_name
     ),
   load_image                       /* load an image (for next page), which is not displayed */ 
     (
       String name,
     ),
   left_margin                      /* left margin for document */ 
     (
       Int32
     ), 
   top_margin                       /* top margin for document */ 
     (
       Int32
     ),
   margin_width
     (
      Int32
     ), 
   margin_height
     (
       Int32
     ), 
   reload_frame
     (
       String name,                /* name of target frame */
       String url                  /* url to load in this frame */ 
     ),
   onload
     (
       String function_name         /* nom de la fonction javascript (sans les '()') */
     ).
   
public type HTML_Body:  
   body
     (
       List(Body_Option),       /* list of body options */
       HTML_Item               /* the content of the page */ 
     ).
   
   

      *** 2.2 HTML pages
      ******************

         *** 2.2.1 Definition of HTML_Page
         *********************************    
   
   The following produces '<meta>' tags, which are put in the head of the document. 
   
public type HTML_Meta:
   keywords
     (
       List(String)
     ), 
   refresh
     ( 
       String     url,
       Int32    delay                // in seconds
     ),
   meta
     (
       String    name,
       String content
     ),
   http_equiv
     (
       String     name,
       String  content
     ). 
   
   
public type HTML_Page: 
   html_page
     (
       String                 title,         /* title appearing on top of browser */
       List(HTML_Meta)    meta_tags,
       Printable_tree  head_scripts,         /* scripts à placer dans la balise head */
       HTML_Body               body          /* body of page */ 
     ),
   standard_frameset
     (
       String                 title,
       List(HTML_Meta)    meta_tags, 
       Int32                 height,          /* height of 'top menu' (pixels) */ 
       Int32                  width,          /* width of 'left menu' (pixels) */ 
       Printable_tree          main           /* url for main */ 
     ).  
   
   +---------+--------------------------+
   |         |                ^         |
   |<-width->|      top     height      |
   |         |                v         |
   | left    +--------------------------+
   |         |                          |
   |         |     main                 |
   |         |                          |
   |         |                          |
   |         |                          |
   +---------+--------------------------+
   
   Note: top and left frames must be loaded through the Web_body_option 'reload_frame'. 

   
         *** 2.2.2 Convenience fuctions
         ******************************    
   
public define HTML_Page
   html_page
     (
       String        title, 
       HTML_Body      body
     ) =
   html_page(title,[],[], body). 

public define HTML_Page
   html_page
     (
       String                title,
       List(HTML_Meta)   meta_tags,
       HTML_Body              body
     ) =
   html_page(title, meta_tags, [], body).

   
public define HTML_Page
   standard_frameset
     (
       String           title,
       Int32           height, 
       Int32            width,  
       Printable_tree    main
     ) =
   standard_frameset(title, [], height, width, main).
   

   
   
   
      *** 2.3 HTML_Element & HTML_Form
      ********************************
   
public type HTML_Element:
  text(Printable_tree), 
  par(String),...
   
public type HTML_Form:
  text(Printable_tree), 
  par(String),...
   
   
   You may want to center a web standard in a page. Just enclose it into 'center(...)':

public type HTML_Item:
   center(HTML_Item),...
   
public type HTML_Element:
   center(HTML_Element),...
   
public type HTML_Form:
   center(HTML_Form),...
   
public type WebStyle:
   background_image(String file_name),
   background_color(RGB color), 
   background_transparent, 
   background_repeat_horizontal,    // repeat the background image only horizontally
   background_repeat_vertical,
   background_no_repeat, 
   color(RGB color), 
   float_to_left,      // the web item will float to the left and text will wrap around 
   float_to_right,
   font_family(String font_name),   // "verdana" "helvetica" "times" etc...
   font_size(Int32 size), 
   italic,
   oblique,
   small_capitals, 
   bold, 
   bolder,
   lighter,
   line_height(Int32 height),
   text_center,
   text_left,
   text_right,
   text_justify,
   text_underline,
   text_blink,
   text_line_through,
   width(Int32 n).
   
  
   
public type HTML_Element:
   style(List(WebStyle) styles, HTML_Element content),...
   
public type HTML_Form:
   style(List(WebStyle) styles, HTML_Form content),...
   
   
public type HTML_Element:
   image
     (
       String file_name,
       String description
     ),...

public type HTML_Form:
   image
     (
       String file_name,
       String description
     ),...

   
   
   A HTML_Element  and HTML_Form may be  a table. A  table is produced by  the constructor
   'table' from the type 'Web_item'. This constructor takes 2 arguments:

    - a list of 'table options', 
    - a list of 'rows'. 

   Of course, you use as many options as  you want, including none (if you do not want any
   option, put the empty  list '[ ]' as this argument). Some  options have precedence over
   others. For example a background image will hide the background color.

   Table options are defined below:

public type Table_Option:

      /* use a color as a background for the table, if you want it to
      be different from the background of the page */ 
   background_color(RGB),   

      /* or use an image as the background of the table */
   background_image(String file_name),

      /* draw a border line around the table (and around each cell in
      the table). You may also specify a geometry (in pixels) for the
      border. This makes the 'in relief' part of the border appear
      more or less wide. You may also specify a color for the border. */
   border(Int32,   /* width of exterior (pixels) */ 
          Int32,   /* width of top */
          Int32),  /* width of interior */
   border_color(RGB),
   absolute_width(Int32). 

   
   
public define Table_Option nude = border(0,0,0).   
   
   
   A 'table  row' is made  of a  list of 'row  options', and a  list of 'cells'.  A 'cell'
   itself has a list of 'cell options', and  a web item, which is its content. We begin by
   the description of options.
   
public type Row_Option:
     /* following concerns the horizontal positions of items within the
     cells of the row */
   left,
   h_center,
   right, 
     /* the following concerns the vertical positions of items, within
     the cells of the row */
   top,
   v_center,
   bottom,
   absolute_height(Int32), 
   base_line,
     /* set the background color of all cells in the row */ 
   background_color(RGB).
   
   
   
public type Cell_Option:
     /* all row options are available for individual cells, and apply
     here only to one cell. */ 
   left,   
   h_center,
   right, 
   top,
   v_center,
   bottom,
   base_line,
   background_color(RGB),  
     /* you can set the width of the cell either absolutely (in pixels)
     or as a percentage of the width of the table. */ 
   background_image(String file_name),
   absolute_width(Int32),
   relative_width(Int32),
   absolute_height(Int32),
   relative_height(Int32),
     /* a cell may span over several columns or rows in the table */
   columns(Int32),
   rows(Int32),
   nowrap.

   
public type Element_Cell:
   cell
     ( 
       List(Cell_Option),
       HTML_Element
     ).
   
public type Form_Cell:
   cell
     ( 
       List(Cell_Option),
       HTML_Form
     ).

public type Item_Cell:
   cell
     (
       List(Cell_Option),
       HTML_Item
     ).
   
public type Element_Row:
   row
     (
       List(Row_Option),
       List(Element_Cell)
     ). 
   
public type Form_Row:
   row
     (
       List(Row_Option),
       List(Form_Cell)
     ). 
   
public type Item_Row:
   row
     (
       List(Row_Option),
       List(Item_Cell)
     ).
   row
     (
       List(Row_Option),
       List(Form_Cell)
     ).

public type HTML_Element:
   table
     (
       List(Table_Option),
       List(Element_Row)
     ),...
   
public type HTML_Form:
   table
     (
       List(Table_Option),
       List(Form_Row)
     ),...
   
public type HTML_Item:
   table
     (
       List(Table_Option),
       List(Item_Row)
     ),...
   
   
      Special link for jumping to a label
   
public type HTML_Element:
   label
     (
       String  lable_name
     ),...
   
public type HTML_Element:
   go_to_label
     (
       String         label_name,
       HTML_Element       content
     ).

   
public type HTML_Form:
   label
     (
       String  lable_name
     ),...

public type HTML_Form:
   go_to_label
     (
       String         label_name,
       HTML_Form         content
     ),
   vscroller
     (
       Int32        height,
       HTML_Form    content
     ),...
   

   
   A form could contain a link. But the content of a link will be only a text or an image.
   
public type HTML_Link:
   text(Printable_tree), 
   image
     (
       String file_name,
       String description
     ),
   style(List(WebStyle) styles, HTML_Link content).
   
   
public type HTML_Form:
   text_input
     (
       String            name,           /* text field to be documented by user */
       Int32             size,
       String   initial_value
     ),
   password_input
     (
       String name,
       Int32  size
     ),
   upload
     (
       String   name,
       Int32    size
     ),
   submit
     (
       String name,
       String text
     ),
   image_submit
     (
       String            name,
       String image_file_name,
       String     description
     ),
   rollover_submit
     (
       String         name,
       String     image_on,
       String    image_off
     ),
   link_to_window
     (
       String                 name,
       String           label_name,
       String             web_args,
       String          window_name,
       HTML_Link           content,
       Int32                 width,
       Int32                height
     ),
   radio_button           
     (
       Printable_tree   name,
       String          value
     ),
   checked_radio_button
     (
       Printable_tree   name,
       String          value
     ),
   check_box
     (
       Printable_tree    name,
       String           value
     ),
   checked_box
     (
       Printable_tree    name,
       String           value
     ).
   
   
   
public type HTML_Item:
   element
     (
       HTML_Element
     ),
   form
     (
       Printable_tree         name,  // actually the URI
       String           label_name,
       HTML_Form              form
     ),
   named_form
     (
       Printable_tree         name,
       String            form_name, 
       String           label_name,
       HTML_Form              form
     ),
   link_to_window
     (
       String                 name,
       String           label_name,
       String             web_args,
       String          window_name,
       HTML_Element        content,
       Int32                 width,
       Int32                height
     ),...
   
   

   
   
   A 'rollover' has  the same role as a submit  button or link, but it  is prettier. It is
   made of two images.  The first one  'image_on' determines the aspect of the button when
   the mouse  cursor is on  it.  The  other one 'image_off'  determines the aspect  of the
   button when  the mouse cursor is  anywhere else. The two  images should be  of the same
   size, otherwise bad  effects may occur. The last operand 'description'  is a small text
   which describes the role of the button. It appears in a bubble in the browser's window.

public type HTML_Item:
   rollover
     (
       List(String)   preload_images,
       String                    url,
       String                 target, 
       String               image_on,
       String              image_off, 
       String            description
     ),...
   
   
   Special link to email :
   
public type HTML_Item:
   mail_to
     (
       String             addr,
       HTML_Element    content
     ).
       
   
   *** 3. Convenience functions
   ****************************
   
      *** 3.1  for HTML_Element & HTML Form
      *************************************
   
public define HTML_Element
   text
     (
       String s
     ) =
   text([s]).
   
public define HTML_Form
   text
     (
       String s
     ) =
   text([s]).

public define HTML_Link
   text
     (
       String s
     ) =
   text([s]).

   
public define HTML_Element
   integer
     (
       Int32 n
     ) =
   text([integer_to_string(n)]).
   
public define HTML_Form
   integer
     (
       Int32 n
     ) =
   text([integer_to_string(n)]).

   
public define HTML_Element
   float
     (
       Float  f,
       Int32  n
     ) =
   text([float_to_string(f,n)]).

public define HTML_Form
   float
     (
       Float  f,
       Int32  n
     ) =
   text([float_to_string(f,n)]).

   
public define HTML_Element
   image
     (
       String   file_name
     ) =
   image(file_name,"").
   
public define HTML_Form
   image
     (
       String   file_name
     ) =
   image(file_name,"").

public define HTML_Link
   image
     (
       String   file_name
     ) =
   image(file_name,"").

   
      *** 3.2 for HTML_Form
      *********************
   
public define HTML_Form
   submit
     (
        String text
     ) = 
   submit("sub",text).

   
public define HTML_Form
   image_submit
     (
       String            name,
       String image_file_name
     ) =
   image_submit(name,image_file_name,"").

   
public define HTML_Form
   image_submit
     (
       String image_file_name
     ) =
   image_submit("sub",image_file_name,"").
   
public define HTML_Form
   link_to_window
     (
       String                 name,
       String             web_args,
       String          window_name,
       HTML_Link           content,
       Int32                 width,
       Int32                height
     ) = 
   link_to_window(name,"",web_args,window_name,content,width,height).

      *** 3.3 For HTML_Item (-> element)
      **********************************
   
public define HTML_Item
   text
     (
       String s
     ) =
   element(text([s])).
   
public define HTML_Item
   par
     (
       String  s
     ) =
   element(par(s)).
   
   
public define HTML_Item
   center
     (
       HTML_Element he
     ) =
   element(center(he)).
   
public define HTML_Item
   style
     (
       List(WebStyle)    lws,
       HTML_Element       he
     ) =
   element(style(lws,he)).

   
   
public define HTML_Item
   link_to_window
     (
       String                 name,
       String             web_args,
       String          window_name,
       HTML_Element        content,
       Int32                 width,
       Int32                height
     ) = 
   link_to_window(name,"",web_args,window_name,content,width,height).

   
define Item_Cell
   cell
     (
       List(Cell_Option)   lco,
       HTML_Element         he
     ) =
   cell([],element(he)).
   
   
 public define HTML_Item
   table
     (
       List(Table_Option)   lto,
       List(Element_Row)   rows
     ) =
   element(table(lto,rows)).
   
   
   
   
public define HTML_Item
   label
     (
       String  label_name
     ) =
   element(label(label_name)).
   
public define HTML_Item
   go_to_label
     (
       String        label_name,
       HTML_Element          he
     ) =
   element(go_to_label(label_name,he)).
   
   
public define HTML_Item
   integer
     (
       Int32 n
     ) =
   element(text([integer_to_string(n)])).
   
public define HTML_Item
   float
     (
       Float f,
       Int32 n
     ) =
   element(text([float_to_string(f,n)])).

public define HTML_Item
   image
     (
       String file_name
     ) =
   element(image(file_name,"")).
   

public define HTML_Item
   form
     (
       Printable_tree  name,
       HTML_Form          f
     ) =
    form(name,"",f).
   
public define HTML_Item
   named_form
     (
       Printable_tree  name,
       String     form_name, 
       HTML_Form          f
     ) =
    named_form(name,form_name,"",f).
   
   

public define HTML_Item empty_item = element(text((Printable_tree)[])).
   
      *** 3.4 Empty cells & empty rows
      ********************************
   
public define Element_Cell 
   empty_cell = 
   cell([],text([])).
   
 public define Element_row
    empty_row =
   
   
public define Form_Cell
   empty_cell =
   cell([],text([])).
   
public define Item_Cell
   empty_cell =
   cell([],element(text([]))).
   
public define Item_Row
   empty_row =
   row([],(List(Item_Cell))[]).
   
   
   
      *** 3.5 Spacers
      ***************

 public define HTML_Element spacer = image(anubis_directory+"/library/web/spacer.gif").
 public define HTML_Form    spacer = image(anubis_directory+"/library/web/spacer.gif").
   
public define HTML_Element spacer = image("spacer.gif").
public define HTML_Form    spacer = image("spacer.gif").
   
public define Element_Cell
   h_spacer
     (
       Int32  n
     ) =
   cell([absolute_width(n)],spacer).

public define Element_Row
   h_spacer
     (
       Int32 n
     ) =
   row([],[h_spacer(n)]).

public define Form_Cell
   h_spacer
     (
       Int32  n
     ) =
   cell([absolute_width(n)],spacer).
   
public define Form_Row
   h_spacer
     (
       Int32 n
     ) =
   row([],[h_spacer(n)]).
   
public define Item_Cell
   h_spacer
     (
       Int32  n
     ) =
   cell([absolute_width(n)],spacer).
   
public define Item_Row
   h_spacer
     (
       Int32 n
     ) =
   row([],(List(Item_Cell))[h_spacer(n)]).
   
public define Element_Row
   v_spacer
     (
       Int32  n
     ) =
   row([absolute_height(n)],[cell([],spacer)]).
   
public define Form_Row
   v_spacer
     (
       Int32  n
     ) =
   row([absolute_height(n)],[cell([],spacer)]).

public define Item_Row
   v_spacer
     (
       Int32  n
     ) =
   row([absolute_height(n)],(List(Item_Cell)) [cell([],spacer)]).

   
   
public define HTML_Element
   spacer
     (
       Int32    w,
       Int32    h
     ) =
   table([],[row([absolute_height(h)],[cell([absolute_width(w)],spacer)])]).
   
public define HTML_Form
   spacer
     (
       Int32    w,
       Int32    h
     ) =
   table([],[row([absolute_height(h)],[cell([absolute_width(w)],spacer)])])
   .
public define HTML_Item
   spacer
     (
       Int32    w,
       Int32    h
     ) =
   element(table([],[row([absolute_height(h)],[cell([absolute_width(w)],spacer)])])).
   
   
   
    --- That's all for the public part ! --------------------------------------------------

   
   
   *** 1. Managing Web Arguments.
   *** 2. Formating operations (Anubis --> HTML/Javascript)
      *** 2.1 Formating a rgb color. 
      *** 2.2 Formating body options
      *** 2.3 Formating table options
      *** 2.4 Formating row options
      *** 2.5 Formating cell options
      *** 2.6 Formating cells
      *** 2.7 Formating rows
      *** 2.8 Formating selector
      *** 2.9 Formating web-styles
      *** 2.10 Formating common alternatives from HTML_Form et HTML_Element
      *** 2.11 Formating HTML_Form
      *** 2.12 Formating HTML_Element
      *** 2.13 Formating HTML_Item
   *** 3. Printing the HTML_Page
   
   
   
variable Printable_tree scripts = [ ]. 
   
define One
  add_script
    (
      Printable_tree script
    ) =
  scripts <- [*scripts . script]. 

   
define Printable_tree
   format
     (
       String       c_ticket,
       String       s_ticket,
       HTML_Element        e
     ).
   
define Printable_tree
   format
     (
       String       c_ticket,
       String       s_ticket,
       HTML_Form           f 
     ).
   
define Printable_tree
   format
     (
       String       c_ticket,
       String       s_ticket,
       HTML_Item           i
     ).
   

   *** 1. Managing Web Arguments.
   ******************************
  
 public define Web_arg_value
   web_arg_value
     (
       List(Web_arg) l,
       String name
     ) =
   if l is
     {
       [ ]     then not_found,
       [h . t] then if h is 
        {
          web_arg(n,v) then 
            if     name=n 
             then   found(v)
             else   web_arg_value(t,name),
   
          upload(n,v,tfn) then 
            if     name=n 
            then   found(v)
            else   web_arg_value(t,name)
        }
     }. 

   
   *** 2. Formating operations (Anubis --> HTML/Javascript)
   ********************************************************
   
      *** 2.1 Formating a rgb color. 
      ******************************
   
define String
  format
    (
      RGB color
    ) =
  if color is rgb(r,g,b) then 
     "#" + hexadecimal(word8_to_Word32(r),2) 
           + hexadecimal(word8_to_Word32(g),2) 
           + hexadecimal(word8_to_Word32(b),2) 
           + "".  

   
      *** 2.2 Formating body options
      ******************************
   
type BodyOnload:
  reload_frame(String name, String url). 
   
variable List(BodyOnload) body_onloads = [ ]. 
   
   
define One
  add_body_onload
    (
      BodyOnload item
    ) =
  body_onloads <- [item . *body_onloads]. 
   
define Printable_tree
  format
    (
      BodyOnload item
    ) =
  if item is 
    {
      reload_frame(name,url) then (Printable_tree)
        [ " window.open('",url,"','",name,"');" ]
    }.
   
define Printable_tree
  format
    (
      List(BodyOnload) l
    ) =
  if l is 
    {
      [ ] then (Printable_tree)[ ], 
      [h . t] then (Printable_tree)
        [format(h) . format(t)]
    }.
   
   
type ImageToLoad:
   simple
     (
       String image_name
     ),
   with_rollover
     (
       String image_name,
       String rollover_name
     ). 
   
variable List(ImageToLoad) images_to_load = [].    
  
   
define Printable_tree
   preload_list
     (
       List(ImageToLoad) images,
       Int32 n, 
     ) =
   if images is 
    {
      [ ] then [ ], 
      [h . t] then 
        ["   preloaded_images[",n,"].src = '",image_name(h),"';",
         if h is 
           {
             simple(_) then [],
             with_rollover(n1,r) then 
               ["   preloaded_images[",n1,"].onload = 'allow_rollover(\"",r,"\")';"]
           }
         . preload_list(t,n-1)]
    }.

define Printable_tree 
   load_image_script
     (
       List(ImageToLoad) images
     ) =
  if images is 
    {
      [ ] then [ ], 
      [_ . _] then 
        [
          "<script>",
          "  var preloaded_images = new Array(",length(images),");", 
          "  var pi_i = 0;", 
          "  for(pi_i = 0; pi_i < ",length(images),"; pi_i++) {", 
          "    preloaded_images[pi_i] = new Image(); }",
          "  function preload_images() {",
          preload_list(images,length(images)-1), 
          "     }</script>"
        ]
    }.


   
define Printable_tree
  format
    (
      Body_Option o
    ) =
  if o is
    {
      background_color(c)                then [" bgcolor=" , (String)format(c)],
      background_image(n)                then [" background=", n],
      load_image(n)                      then images_to_load <- [simple(n) . *images_to_load]; [ ], 
      left_margin(n)                     then [" leftmargin=", n],
      top_margin(n)                      then [" topmargin=", n],
      margin_width(n)                    then [" marginwidth=", n],
      margin_height(n)                   then [" marginheight=", n],
      reload_frame(n,url)                then add_body_onload(reload_frame(n,url)); [ ],
      onload(n)                          then [" onLoad=\"", n, "()\""] 
    }.

define Printable_tree
   format
     (
       List(Body_Option) l
     ) =
   if l is 
     {
       [ ]     then [ ], 
       [h . t] then [format(h) . format(t)]
     }.  

   
      *** 2.3 Formating table options
      *******************************
   
define Printable_tree
   format
     (
       List(Table_Option) l
     ) =
   if l is 
     {
      [ ]     then [ ],
      [h . t] then 
        [if h is 
          {
            background_color(c) then [" bgcolor=", (String)format(c)],
            background_image(f) then [" background=",f],
            border(e,top,i)     then [" border=",e," cellspacing=",top," cellpadding=",i],
            border_color(c)     then [" bordercolor=", (String)format(c)],
            absolute_width(n)   then [" width=",n]
         }, format(t)]
    }. 
   
   
   
   
      *** 2.4 Formating row options
      *****************************

define Printable_tree
   format
     (
       List(Row_Option) l
     ) =
   if l is
     {
       [ ]              then [ ], 
       [first . others] then 
         [if first is
            {
             left                 then [" align=left"],
             h_center             then [" align=center"],
             right                then [" align=right"],
             top                  then [" valign=top"],
             v_center             then [" valign=center"],
             bottom               then [" valign=bottom"],
             absolute_height(n)   then [" height=\"",n,"\""], 
             base_line            then [" valign=baseline"],
             background_color(c)  then [" bgcolor=",(String)format(c)]
            },
         format(others)]
      }.

   
      *** 2.5 Formating cell options
      ******************************

define Int32
  percentage
    (
      Int32 n
    ) =
         if n < 0 then 0 
    else if n > 100 then 100
    else n. 
   
define Printable_tree
   format
     (
       List(Cell_Option) l
     ) =
   if l is
     {
       [ ]              then [ ],
       [first . others] then 
         [if first is
            {
              left                then (Printable_tree)[" align=left"],
              h_center            then (Printable_tree)[" align=center"],
              right               then (Printable_tree)[" align=right"],
              top                 then (Printable_tree)[" valign=top"],
              v_center            then (Printable_tree)[" valign=center"],
              bottom              then (Printable_tree)[" valign=bottom"],
              base_line           then (Printable_tree)[" valign=baseline"],
              background_color(c) then (Printable_tree)[" bgcolor=",(String)format(c)],
              background_image(n) then (Printable_tree)[" style=\"background: url(",n,")\""],
              absolute_width(w)   then (Printable_tree)[" width=",w],
              relative_width(r)   then (Printable_tree)[" width=",percentage(r),""],
              absolute_height(h)  then (Printable_tree)[" height=",h],
              relative_height(r)  then (Printable_tree)[" height=",percentage(r),""],
              columns(n)          then (Printable_tree)[" colspan=",n],
              rows(n)             then (Printable_tree)[" rowspan=",n],
              nowrap              then (Printable_tree)[" nowrap"]           
            }
          . format(others)]
      }.


   
      *** 2.6 Formating cells
      ***********************
   
define Printable_tree
   format
     (
       String              c_ticket, 
       String              s_ticket, 
       List(Element_Cell)         l
    ) =
   if l is
     {
       [ ]              then [ ], 
       [first . others] then 
        [
         if first is  cell(options,e) then 
               [
                 "<td",format(options),">",
                 format(c_ticket,s_ticket,e),"</td>"
               ],
          format(c_ticket,s_ticket,others)
         ]
     }.
   
define Printable_tree
   format
     (
       String              c_ticket, 
       String              s_ticket, 
       List(Form_Cell)            l
    ) =
   if l is
     {
       [ ]              then [ ], 
       [first . others] then 
        [
         if first is  cell(options,e) then 
               [
                 "<td",format(options),">",
                 format(c_ticket,s_ticket,e),"</td>"
               ],
          format(c_ticket,s_ticket,others)
         ]
     }.
   
define Printable_tree
   format
     (
       String              c_ticket, 
       String              s_ticket, 
       List(Item_Cell)            l
    ) =
   if l is
     {
       [ ]              then [ ], 
       [first . others] then 
        [
         if first is  cell(options,e) then 
               [
                 "<td",format(options),">",
                 format(c_ticket,s_ticket,e),"</td>"
               ],
          format(c_ticket,s_ticket,others)
         ]
     }.
   
   

      *** 2.7 Formating rows
      **********************
   
define Printable_tree
   format
     (
       String        c_ticket, 
       String        s_ticket, 
       Element_Row         er
     ) =
    if er is row(options,cells) then
      [ "<tr",format(options),">",
        format(c_ticket,s_ticket,cells),"</tr>"
      ].
   
define Printable_tree
   format
     (
       String             c_ticket, 
       String             s_ticket, 
       List(Element_Row)         l
     ) =
   if l is
     {
       [ ]                      then [ ], 
       [first_row . other_rows] then (Printable_tree)
          [format(c_ticket,s_ticket,first_row), format(c_ticket,s_ticket,other_rows)]
    }. 
   
define Printable_tree
   format
     (
       String      c_ticket, 
       String      s_ticket, 
       Form_Row          fr
     ) =
    if fr is row(options,cells) then
      [ "<tr",format(options),">",
        format(c_ticket,s_ticket,cells),"</tr>"
      ].
   
define Printable_tree
   format
     (
       String             c_ticket, 
       String             s_ticket, 
       List(Form_Row)            l
     ) =
   if l is
     {
       [ ]                      then [ ], 
       [first_row . other_rows] then (Printable_tree)
          [format(c_ticket,s_ticket,first_row), format(c_ticket,s_ticket,other_rows)]
    }. 
   
define Printable_tree
   format
     (
       String             c_ticket, 
       String             s_ticket, 
       List(Item_Row)         rows
     ) =
   if rows is
     {
       []      then [],
       [h . t] then 
         if h is row(options,cells) then
               [ "<tr",format(options),">",
                 format(c_ticket,s_ticket,cells),"</tr>",
                 format(c_ticket,s_ticket,t)
               ]
     }.
   if rows is
    {
      a & b              then (Printable_tree)[format(c_ticket,s_ticket,a),format(c_ticket,s_ticket,b)],
      ir & er            then (Printable_tree)[format(c_ticket,s_ticket,ir),format(c_ticket,s_ticket,er)],
      er & ir            then (Printable_tree)[format(c_ticket,s_ticket,er),format(c_ticket,s_ticket,ir)],
      ir & fr            then (Printable_tree)[format(c_ticket,s_ticket,ir),format(c_ticket,s_ticket,fr)],
      row(options,cells) then (Printable_tree)
            [ "<tr",format(options),">",
             format(c_ticket,s_ticket,cells),"</tr>"
            ],
    }.


      *** 2.8 Formating selector
      **************************
   
define Printable_tree
   format_choices
     (
       List(String) l
     ) =
   if l is 
     {
       [ ] then [ ], 
       [h . t] then ["<option>",h . format_choices(t)]
     }.


define Printable_tree
   format_choices
    (
      List(String) l,
      String selected
    ) =
   if l is 
     {
       [ ] then [ ], 
       [h . t] then if h = selected 
        then ["<option selected>",h . format_choices(t)]
        else ["<option>",h . format_choices(t,selected)]
     }.

   
      *** 2.9 Formating web-styles
      ****************************
   
define String
   format
     (
       WebStyle ws
     ) =
   if ws is 
     {
       background_image(fn)          then "background: url("+fn+")",
       background_color(c)           then "background: "+format(c),
       background_transparent        then "background: transparent",
       background_repeat_horizontal  then "background: repeat-x",
       background_repeat_vertical    then "background: repeat-y",
       background_no_repeat          then "background: no-repeat",
       color(c)                      then "color: "+format(c),
       float_to_left                 then "float: left",
       float_to_right                then "float: right",
       font_family(n)                then "font-family: "+n,
       font_size(n)                  then "font-size: "+integer_to_string(n)+"pt",
       italic                        then "font-style: italic",
       oblique                       then "font-style: oblique",
       small_capitals                then "font-variant: small-caps",
       bold                          then "font-weight: bold",
       bolder                        then "font-weight: bolder",
       lighter                       then "font-weight: lighter",
       line_height(h)                then "line-height: "+integer_to_string(h),
       text_center                   then "text-align: center",
       text_left                     then "text-align: left",
       text_right                    then "text-align: right",
       text_justify                  then "text-align: justify",
       text_underline                then "text-decoration: underline",
       text_blink                    then "text-decoration: blink",
       text_line_through             then "text-decoration: line-through",
       width(n)                      then "width: "+integer_to_string(n),
    }. 
   
   
define Printable_tree
   format
     (
       List(WebStyle) l
     ) =
   if l is 
     {
       [ ]     then [ ], 
       [h . t] then 
        if t is 
          {
            [ ]     then [format(h)], 
            [_ . _] then [format(h), "; " . format(t)]
          }
    }.

   
      *** 2.10 Formating common alternatives from HTML_Form et HTML_Element
      *********************************************************************
   
define Printable_tree
   format_par
     (
       String  s
     ) =
    ["<p align=justify>", s, " </p>"].
   
define Printable_tree
   format_image
     (
       String     fn,
       String   desc,
     ) =
     ["<img src=\"", fn, (if desc="" then [] else ["\" alt=\"",desc]), "\" border=0>"].
   
   
      *** 2.11 Formating HTML_Form
      ****************************

define Printable_tree
   format
     (
       String         c_ticket, 
       String         s_ticket,
       HTML_Link            hl
    ) = 
   if hl is
     {
      text(Printable_tree p)           then (Printable_tree)p,
      image(fn,desc) then (Printable_tree)format_image(fn,desc),
      style(l,lk)     then 
        (Printable_tree)["<span style=\"", format(l), "\">", format(c_ticket,s_ticket,lk), "</span>"],
     }.
   
define Printable_tree
   format
     (
       String         c_ticket, 
       String         s_ticket,
       HTML_Form             f
    ) = 
   if f is
     {
       a & b         then (Printable_tree)[format(c_ticket,s_ticket,a), " ", 
                                           format(c_ticket,s_ticket,b)],
   
      text(Printable_tree p)           then (Printable_tree)p,

      par(s)                        then (Printable_tree)format_par(s),
   
      center(elm)   then (Printable_tree)["<center>", format(c_ticket,s_ticket,elm),"</center>"],
   
      style(l,elm)     then 
        (Printable_tree)["<span style=\"", format(l), "\">", format(c_ticket,s_ticket,elm), "</span>"],

   
      image(fn,desc) then (Printable_tree)format_image(fn,desc),
      
      table(ops,rows) then (Printable_tree)
           ["<table ",format(ops), ">",format(c_ticket,s_ticket,rows),"</table>"],

   
      label(name) then (Printable_tree)["<a name=\"",name,"\">"],
   
      go_to_label(name,content) then (Printable_tree)["<a href=#",name,">",
            format(c_ticket,s_ticket,content),"</a>"], 
      
   
      vscroller(height,content) then (Printable_tree)
        [
        "<script language=\"JavaScript\">",
           "var up = true;\n", 
           "function myscroll() {\n",
 "if (document.layers) { var myobj = eval(document.zozoza); } else\n",
 "if (document.getElementById) { var myobj = eval(\"document.getElementById('zozoza').style\"); } else\n",
 "if (document.all) { var myobj = eval(document.all.zozoza.style); };\n", 
   "var i = 0;\n", 
 "for (i = 0; i < document.anchors.length; i++) {\n",
   "if (document.anchors[i].name == \"gluglu\") { var ch = document.anchors[i].y; }}\n",
             "var y_pos = parseInt(myobj.top);\n",
 //            "var glupos = gluobj.y;\n",
 //            "var ch = glupos;\n", 
//             "var zizi = typeof(glupos);\n", 
//             "var zizo = glupos.toString();\n", 
//   "alert(\"type of glupos = \"+zizi+\"  val: \"+zizo); return; \n",
             " if (up) { myobj.top = (y_pos - (2)); } else { myobj.top = (y_pos + (2)); };\n", 
             " if (y_pos < ",height," - ch) { up=false; };\n", 
             " if (y_pos > 0) {up = true;};\n", 
             "setTimeout(\"myscroll()\",100)}\n",
         "</script>",
         "<div id=\"tagada\" style=\"position:absolute; width:500px; height:",height,
                                      "px; clip: rect(0px 500px ",height,"px 0px)\">",
           "<div id=\"zozoza\" style=\"position:absolute; width:500px; z-index:1; top:0px\">",
           "<table><tr><td>\n", 
             format(c_ticket,s_ticket,content),
           "</td></tr><tr><td>",
           "<a name=\"gluglu\"> a </a></td></tr></table></div>\n",
         "</div>",
         format(c_ticket,s_ticket,(HTML_Element)s pacer(500,height)),   
        ],
   
   
      text_input(n,s,v) then (Printable_tree)
        ["&nbsp; <input type=text name=\"", n, "\" size=", s, " value=\"", v,"\">"],
   
      password_input(n,s) then (Printable_tree)
        ["&nbsp; <input type=password name=\"", n, "\" size=", s,">"],
   
      upload(n,size) then (Printable_tree)
       ["<input type=file size=",size," multiple name=",n,">"],
      
      submit(n,t) then (Printable_tree)["<input type=submit name=",n," value=\"",t,"\">"],
   
      image_submit(n,fn,desc) then (Printable_tree)
        ["<input type=image name=",n," src=\"",fn,"\"alt=\"",desc,"\" border=0>"],
   
      rollover_submit(n,ion,ioff) then (Printable_tree)
        ["<input type=image name=",n," src=\"",ioff,"\" border=0",
         " onMouseOver=\"this.src='",ion,"'\"",
         " onMouseOut=\"this.src='",ioff,"';\"",">"],
   
      link_to_window(n,lab,args,wn,e,w,h) then (Printable_tree)
         ["<a href=\"javascript:void window.open('",n,
           (if member('?',n) then "&" else "?"), 
          "c_ticket=",c_ticket,
          (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
          "&target=",wn,
          if args="" then "" else "&",args,
           (if lab="" then [] else ["&#",lab]), "','",
            wn,"','width=",w,",height=",h,", resizable,scrollbars');\">",
            format(c_ticket,s_ticket,e),"</a>"],
   
       radio_button(n,v)           then (Printable_tree)
         ["<input type=radio name=", n, " value=\"", v, "\">"],
    
       checked_radio_button(n,v)   then (Printable_tree)
         ["<input type=radio checked name=", n, " value=\"", v, "\">"],
   
       check_box(n,v)              then (Printable_tree)
         ["<input type=checkbox name=", n, " value=\"", v, "\">"],
   
       checked_box(n,v)            then (Printable_tree)
         ["<input type=checkbox checked name=", n, " value=\"", v, "\">"] 
   }.   

   
   
      *** 2.12 Formating HTML_Element
      *******************************
   
define Printable_tree
   format
     (
       String         c_ticket, 
       String         s_ticket,
       HTML_Element          e
    ) = 
   if e is
     {
       a & b         then (Printable_tree)[format(c_ticket,s_ticket,a), " ", 
                                           format(c_ticket,s_ticket,b)],
   
      text(Printable_tree p)           then (Printable_tree)p,

      par(s)                        then (Printable_tree)format_par(s),
   
      center(elm)   then (Printable_tree)["<center>", format(c_ticket,s_ticket,elm),"</center>"],
   
      style(l,elm)     then 
        (Printable_tree)["<span style=\"", format(l), "\">", format(c_ticket,s_ticket,elm), "</span>"],

   
      image(fn,desc) then (Printable_tree)format_image(fn,desc),
      
      table(ops,rows) then (Printable_tree)
           ["<table ",format(ops), ">",format(c_ticket,s_ticket,rows),"</table>"],

   
      label(name) then (Printable_tree)["<a name=\"",name,"\">"],
   
      go_to_label(name,content) then (Printable_tree)["<a href=#",name,">",
            format(c_ticket,s_ticket,content),"</a>"]
   }.

   
   
      *** 2.13 Formating HTML_Item
      ****************************


   The next variable is a multipurpose counter (used to generate unique names). 
   
variable Int32 web_count = 0.

define Int32
  new_web_count 
    =
  web_count <- *web_count+1; 
  *web_count. 
     
   
   
define Bool find_upload(HTML_Form f).

define Bool
   find_upload
     (
       List(Form_Cell) l
     ) =
   if l is
     {
       []      then false,
       [h . t] then if h is cell(_,f) then if find_upload(f) then true else find_upload(t)
     }.

define Bool
   find_upload
     (
       List(Form_Row) l
     ) =
   if l is
     {
       []       then false,
       [h . t]  then 
         if h is row(_,lfc) then 
         if find_upload(lfc) then true else find_upload(t)
     }.

define Bool
   find_upload
     (
       HTML_Form  f
     ) =
   if f is
     {
       a & b                          then (Bool)if find_upload(a) then true else find_upload(b),
       text(_)                        then (Bool)false,
       par(_)                         then (Bool)true,
       center(hf)                     then (Bool)find_upload(hf),
       style(_,hf)                    then (Bool)find_upload(hf),
       image(_,_)                     then (Bool)false,
       table(_,fr)                    then (Bool)find_upload(fr),
       label(_)                       then (Bool)false,
       go_to_label(_,hf)              then (Bool)find_upload(hf),
       vscroller(h,c)                 then (Bool)find_upload(c), 
       text_input(_,_,_)              then (Bool)false,
       password_input(_,_)            then (Bool)false,
       upload(_,_)                    then (Bool)true,
       submit(_,_)                    then (Bool)false,
       image_submit(_,_,_)            then (Bool)false,
       rollover_submit(_,_,_)         then (Bool)false,
       link_to_window(_,_,_,_,_,_,_)  then (Bool)false,
       radio_button(_,_)              then (Bool)false,
       checked_radio_button(_,_)      then (Bool)false,
       check_box(_,_)                 then (Bool)false,
       checked_box(_,_)               then (Bool)false
     }.
   
define String
  enctype
    (
      HTML_Form  f
    ) =
  if find_upload(f)
    then "enctype=multipart/form-data"
    else "". 
   
   
   
define Printable_tree
   format
     (
       String         c_ticket, 
       String         s_ticket,
       HTML_Item             i
    ) = 
   if i is
     { 
       a & b            then (Printable_tree) [format(c_ticket,s_ticket,a),format(c_ticket,s_ticket,b)],
   
       center(hi)       then (Printable_tree) ["<center>",format(c_ticket,s_ticket,hi),"</center>"],
   
       table(ops,rows)  then (Printable_tree)
           ["<table ",format(ops), ">",format(c_ticket,s_ticket,rows),"</table>"],
   
       element(e)       then (Printable_tree) format(c_ticket,s_ticket,e),
   
       form(n,lab,f)      then (Printable_tree)
         ["<form ",enctype(f)," method=POST action=\"", n,
            (if lab="" then [] else ["#", lab]), "\">", 
          "<input type=hidden name=s_ticket value=\"",s_ticket,"\">",
          "<input type=hidden name=c_ticket value=\"",c_ticket,"\">",
          format(c_ticket,s_ticket,f),"</form>"],
   
       named_form(n,fn,lab,f)      then (Printable_tree)
         ["<form ",enctype(f)," name=\"",fn,"\" method=POST action=\"", n,
            (if lab="" then [] else ["#", lab]), "\">", 
          "<input type=hidden name=s_ticket value=\"",s_ticket,"\">",
          "<input type=hidden name=c_ticket value=\"",c_ticket,"\">",
          format(c_ticket,s_ticket,f),"</form>"],
   
       link_to_window(n,lab,args,wn,e,w,h) then (Printable_tree)
         ["<a href=\"javascript:void window.open('",n,
           (if member('?',n) then "&" else "?"), 
          "c_ticket=",c_ticket,
          (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
          "&target=",wn,
          if args="" then "" else "&", args,
           (if lab="" then [] else ["&#",lab]), "','",
            wn,"','width=",w,",height=",h,", resizable,scrollbars');\">",
            format(c_ticket,s_ticket,e),"</a>"],
   
       rollover(prlim,url,target,ion,ioff,descr) then (Printable_tree)
        (images_to_load <- [simple(ion) . *images_to_load]; 
         with name = "ron_"+integer_to_string(new_web_count), 
         ["<a target=\"",target,"\" href=\"",url,
         (if (c_ticket = "" & s_ticket = "") then "" else (if member('?',url) then "&" else "?")),
         (if c_ticket = "" then [ ] else ["c_ticket=",c_ticket]),
         (if s_ticket = "" then [ ] else [(if c_ticket="" then "" else "&")+"s_ticket=",s_ticket]),
          "\" onMouseOut=\"",name,".src='",ioff,
          "';\" onMouseOver=\"",name,".src='",ion,"';\">
         <img src=\"",ioff, "\" name=\"",name,"\" alt=\"",descr,"\" border=0></a>"]), 
   
       mail_to(adr,f) then (Printable_tree) ["<a href=#",adr,">",format(c_ticket,s_ticket,f),"</a>"]
     }.
   
   
   
   *** 3. Printing the HTML_Page
   *****************************
   
   
public type HeaderSort:
   empty,
   anubis, 
   apache. 

   
define Printable_tree
   format_keywords
     (
       List(String) l
     ) =
   if l is 
     {
       []      then [ ], 
       [h . t] then if t is []
         then [h]
         else [h , ", " . format_keywords(t)]
     }. 
   
define Printable_tree
   format
     (
       HTML_Meta m
     ) =
   if m is 
     {
       keywords(l)        then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\">"],
       refresh(url,delay) then ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\">"], 
       meta(n,c)          then ["<meta name=\"",n,"\" content=\"",c,"\">"], 
       http_equiv(n,c)    then ["<meta http-equiv=\"",n,"\" content=\"",c,"\">"]
     }.
   
define Printable_tree
   format
     (
       List(HTML_Meta) metas
     ) =
   if metas is 
     {
       []      then [],
       [h . t] then [format(h) . format(t)]
     }. 
   
   
define Printable_tree
  standard_headers 
    (
      Int32 size
    ) =
  [
    "HTTP/1.0 200 OK" + crlf +
    "Server: Anubis" + crlf +
    "Content-Type: text/html" + crlf +
    "Content-Length: "+integer_to_string(size)+crlf+
    crlf
  ].
   
define Printable_tree
  apache_headers
    = 
  [
    "Content-type: text/html" + crlf + 
    crlf
  ]. 
   
define String
  empty_javascript_source
    =
  "javascript:'<html><head></head><body></body></html>';".
   
   
   (for frames)
define Printable_tree
  add_tickets
    (
      String c_ticket, 
      String s_ticket,
      Printable_tree url
    ) =
  if member('?',url)
  then [url , "&c_ticket=", c_ticket, "&s_ticket=", s_ticket ]
  else [url , "?c_ticket=", c_ticket, "&s_ticket=", s_ticket ]. 
   
   
   
public define Printable_tree
   format
     (
       HeaderSort        hs, 
       String      c_ticket, 
       String      s_ticket, 
       HTML_Page          p
     ) =
   if p is 
     {
       html_page(title,metas,head_scripts,body) then
       with body =
         [
           "<html>",
           "<head>",
           "<title>", title, "</title>",
           format(metas), 
           head_scripts, 
           "</head>",
           "<body ",
           if body is body(options,item) then 
              with b_options = format(options),  //  layers : format(prepare(options)),
                [b_options, " onLoad='body_onloads(); myscroll();", 
                  if *images_to_load is [] then "" else " preload_images();",
                       "'>", 
                 load_image_script(*images_to_load), 
                 "<script language=\"JavaScript\">",
                 (*scripts),
                 "  function body_onloads() {",
                    format(*body_onloads),
                   "}</script>",
                 format(c_ticket,s_ticket,item)
               ],
        "</body>",
        "</html>"
       ],
      [
        if hs is 
           {
              empty  then [ ], 
              anubis then standard_headers(length(body)), 
              apache then apache_headers
           } 
        . body
      ],
  standard_frameset(title,metas,height,width,main) then
    with body =
      [
        "<html>",
        "<head>",
        "<title>", title, "</title>",
        format(metas), 
        "</head>",
        "<frameset frameborder=no border=0 framespacing=0",
        "    marginwidth=0 marginheight=0 cols=\"",width,",*\" rows=\"*\">",
        "    <frame src=\"",empty_javascript_source,"\" name=\"left\" frameborder=no",
        "        marginwidth=0 marginheight=0 scrolling=no>",
        "  <frameset frameborder=no border=0 framespacing=0 rows=\"",height,",*\" cols=\"*\">",
        "    <frame src=\"",empty_javascript_source,"\" name=\"top\"",
                " marginwidth=0 marginheight=0 frameborder=no scrolling=no>",
        "    <frame src =\"", add_tickets(c_ticket,s_ticket,main), 
              "\" name=\"main\" marginwidth=0 marginheight=0 frameborder=no>",
        "  </frameset>",
        "</frameset>",
        "</html>"
      ],
      [
        if hs is 
           {
              empty then [ ], 
              anubis then standard_headers(length(body)), 
              apache then apache_headers
           }
        . body
      ]
   
    }.
   
   
   
   
   *** for kernel.anubis
   
public define Bool
  print_with_headers
    (
      HeaderSort hs,
      String c_ticket, 
      String s_ticket, 
      HTML_Page p
    ) =
  print(format(hs,c_ticket,s_ticket,p)).