home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 May / PCWorld_2000-05_cd.bin / Komunik / amaya / amaya25.exe / _SETUP.1 / HTML.trans < prev    next >
Encoding:
Text File  |  1999-12-23  |  9.8 KB  |  471 lines

  1. ! Use of the file HTML.trans
  2. !!!!!!!!!!!!!!!!!!!!!!!!!!!!
  3. ! This file can be edited during an Amaya session. It will be 
  4. ! dynamically parsed when the transformation tool is required by
  5. ! the editor. So new transformations can be added while editing.
  6. !
  7. ! Syntax of the transformation language for Amaya
  8. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  9. !
  10. ! comments begin with !
  11. !
  12. ! This file can be edited during an Amaya session. It will be 
  13. ! dynamically parsed when the transformation tool is required by
  14. ! the editor. So new transformations can be added while editing.
  15. !
  16. ! A tranformation rule has three parts : 
  17. !     - a name terminated by a colon ":"
  18. !     - a source pattern terminated by a semi-colon ";"
  19. !     - and a list of rules between braces "{" "}", each one
  20. !           terminated by a semi-colon ";"
  21. !
  22. ! The name will appear in the transform menu.
  23. !
  24. ! The pattern gives of a specific organization of the elements
  25. ! to be transformed: it contains HTML tags and SGML-like syntax
  26. ! for the composition operators:
  27. !     e1 | e2   for a choice between elements e1 and e2
  28. !     e1 , e2   for a sequence e1 followed by e2
  29. !     e+        for a sequence of one or more elements e
  30. !     ?e        for an optional element e
  31. !     ( )       for grouping nodes
  32. ! The braces "{" "}" define the content of a node.
  33. ! The symbol "*" is a token that matches any element type
  34. ! It is possible to rename a tag by preceeding it with a name
  35. ! followed by a colon ":"
  36. !
  37. ! A rule expresses transformations to be applied to the elements 
  38. ! identified in the pattern. They have two parts :
  39. !        - a source identifier: a tag or a name which occurs in
  40. !          the pattern and links the rule to the pattern nodes
  41. !        -  a rule body: drives the transformation
  42. !  Each rule end with a symbol ";"
  43. !
  44. ! there are two kinds of rule bodies:
  45. ! - A discard rule body is slash and express that the correspoding
  46. !    pattern node does not occurin the transformation result
  47. !
  48. ! - A generation rule begins with
  49. !     - a symbol ">"
  50. !     - and a target tag list. This list is itself divided into
  51. !       two parts separated by a colon":": 
  52. !         * the generation location path
  53. !         * and the list of tags to be generated
  54. ! The dot symbol "." is used for descending in the tree structure.
  55. ! if the special token star "*" ends the list of tags to be 
  56. ! generated, the source elment tag is not changed but this element
  57. ! can be moved in a different place in the destination. 
  58. !
  59. ! The rules are applied in the order the identifiers are met when
  60. ! (depth first) traversing the source structure.
  61. ! Several rules may have the same identifier, in that case, the rules
  62. ! are applied in the order they are defined.
  63.  
  64. ! Transformation rules 
  65. !!!!!!!!!!!!!!!!!!!!!!
  66.  
  67. Address:(p{*+})+;
  68.     {
  69.     * > address:*;
  70.     }
  71.  
  72. !between lists
  73. !!!!!!!!!!!!!!
  74.  
  75. Definition list:*{(li{(list:*{(li2:li)+}|other:*)+})+};
  76.     {
  77.     other > dl:dt;
  78.     list > dl:dd;
  79.     li2 > dl.dd:;
  80.     }
  81.  
  82. Bulleted list:(dl{(dt|dd{(*)+})+})+;
  83.     {
  84.     dt > ul:li;
  85.     * > ul.li.ul:li.*;
  86.     }
  87.  
  88. Numbered list:(dl{(dt|dd{(*)+})+})+;
  89.     {
  90.     dt > ol:li;
  91.     * > ol.li.ol:li.*;
  92.     }
  93.  
  94. Remove dl: (dl{(dt{(dtc:*)+}|dd{(ddc:*)+})+})+;
  95.     {
  96.      dtc > :<* style="font-weight:bold">;
  97.      ddc > :*;
  98.     }
  99.  
  100. !flattering headings 
  101. !!!!!!!!!!!!!!!!!!!!
  102.  
  103. Paragraphs: 
  104. (h1|h2|h3|h4|h5|h6|*{(li{(il:*)+})+}),(h1|h2|h3|h4|h5|h6|p|*{(li{(il:*)+})+})+;
  105.     { 
  106.     h1 > :p;
  107.     h2 > :p;
  108.     h3 > :p;
  109.     h4 > :p;
  110.     h5 > :p;
  111.     h6 > :p;
  112.     p > :p;
  113.     il > :p;
  114.     }
  115.  
  116. ! Preformatted to/from paragraphs
  117. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  118.  
  119. !Preformatted: p+;
  120. !    {
  121. !    p>:pre;
  122. !    }
  123.  
  124. !Paragraph: pre+;
  125. !    {
  126. !    pre>:p;
  127. !    }
  128.  
  129.  
  130. !Tables to/from lists
  131. !!!!!!!!!!!!!!!!!!!!
  132.  
  133. Table: *{(lev1:li{?(*{(lev2:li)+}|elem:*)+})+};
  134.     {
  135.     lev1 > <table border="1">:tr;
  136.     elem > table.tr:td.*;
  137.     lev2 > table.tr:td;
  138.     }
  139.  
  140. Table: dl{(dt|dd)+};
  141.     {
  142.     dt > <table border="1">.tbody:tr.td;
  143.     dd > table.tbody.tr:td;
  144.     }
  145.  
  146. Numbered List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  147.       {
  148.     caption > :ol.li.strong;
  149.     block > :ol;
  150.     tr > ol:li;
  151.     td > ol.li:;
  152.     th > ol.li:;
  153.     td2 >ol.li.ul:li;
  154.     th2 >ol.li.ul:li;
  155.     }
  156.  
  157. Bulleted List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  158.     {
  159.     caption > :ul.li.strong;
  160.     block > :ul;
  161.     tr > ul:li;
  162.     td > ul.li:;
  163.     th > ul.li:;
  164.     td2 >ul.li.ul:li;
  165.     th2 >ul.li.ul:li;
  166.     }
  167. Definition List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  168.         {
  169.         caption > :dl.dt;
  170.         block   > :dl;
  171.         td      > dl:dt;
  172.         th      > dl:dt;
  173.         td2     > dl:dd;
  174.         th2     > dl:dd;
  175.         }
  176.  
  177. ! List transformations
  178. !!!!!!!!!!!!!!!!!!!!!!
  179.  
  180. Remove one level: *{(li{(cont:*)+})+};
  181.     {
  182.     cont > :*;
  183.     }
  184.  
  185. Remove two levels: *{(li{(*{?(li{(lev2:*)+})+})+})+};
  186.     {
  187.     lev2 > :*;
  188.     }
  189.  
  190. Merge Items: li,(li2:li)+;
  191.     {
  192.     li > li:;
  193.     li2 > li:;
  194.     }
  195. Remove Paragraph level: li{p{(cont:*)+},?(next:*)+};
  196.     {
  197.          li > li:;
  198.          cont > *;
  199.          next > *;
  200.          }
  201.  
  202. Split Items: (li{a:*,(b:*)+})+;
  203.     {
  204.     a > :li.*;
  205.     b > :li.*;
  206.     }
  207.  
  208. Merge Lists: ul{li+},(ul{li+})+;
  209.     {
  210.     li > ul:li;
  211.     }
  212.  
  213. Merge Lists: ol{li+},(ol{li+})+;
  214.     {
  215.     li > ol:li;
  216.     }
  217.  
  218. Merge Lists: dl{(dt|dd)+},(dl{(dt|dd)+})+;
  219.     {
  220.     dt > dl:dt;
  221.     dd > dl:dd;
  222.     }
  223.  
  224. ! Forms to/from elements
  225. !!!!!!!!!!!!!!!!!!!!!!!!
  226.  
  227. Form: *+;
  228.     {
  229.     *>Form:*;
  230.     }
  231.  
  232. Remove Form: form{*+};
  233.     {
  234.     *>:*;
  235.     }
  236.  
  237. Remove submenu: (optgroup{*+})+;
  238.     {
  239.         * > :*;
  240.     }
  241.  
  242. ! Lists to/from elements
  243. !!!!!!!!!!!!!!!!!!!!!!!!
  244.  
  245. Bulleted list: (p|ol|menu|dir|pre|form)+;
  246.        {
  247.         p > ul:<li style=p.style>;
  248.         ol> ul;
  249.         menu> ul:li.menu;
  250.         dir> ul:li.dir;
  251.         pre> ul:li.pre;
  252.         form> ul:li.form;
  253.         }
  254.  
  255. Numbered list:(p|ul|menu|dir|pre|form)+;
  256.        {
  257.         p > ol:li;
  258.         ul> ol;
  259.         menu> ol:li.menu;
  260.         dir> ol:li.dir;
  261.         pre> ol:li.pre;
  262.         form> ol:li.form;
  263.         }
  264.  
  265. ! Tables to/from elements
  266. !!!!!!!!!!!!!!!!!!!!!!!!!
  267.  
  268. !Table: (h:h1|h:h2|h:h3|h:h4|h:h5|h:h6|p),(h:h1|h:h2|h:h3|h:h4|h:h5|h:h6|*)+;
  269. !    {
  270. !    p> <table border="1">.tr.td:p;
  271. !    h> <table border="1">:tr.td.*;
  272. !    *> <table border="1">.tr:td.*;
  273. !    }
  274.  
  275.  
  276. Vertical Table: *+;
  277.     {
  278.     *><table border="1">:tr.td.*;
  279.     }
  280.  
  281. Horizontal Table : *+;
  282.     {
  283.     *><table border="1">.tr:td.*;
  284.     }
  285.  
  286. Remove Table:table{?caption,?(body:*{(tr{(*{(?cell_content:*)+})+})+})+};
  287.     {
  288.     caption>h3;
  289.     cell_content>:*;
  290.     }
  291.  
  292. Transpose Table:table{tbody{tr{(td|th)+}|(tr{td2:td|th2:th})+}};
  293.     {
  294.     td><table border=table.border>:tr.td;
  295.     th>table:tr.td;
  296.     td2><table border=table.border>.tr:td;
  297.     th2>table.tr:td;
  298.     }
  299.  
  300. Heading Cell :?(td|th)+,td,?(td|th)+;
  301.     {
  302.     td>:th;
  303.     }
  304.  
  305. Data Cell :?(td|th)+,th,?(td|th)+;
  306.     {
  307.     th>:td;
  308.     }
  309.  
  310. !headings to/from definitions
  311. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  312.  
  313. Definition list:((h1|h2|h3|h4|h5|h6),*+)+;
  314.     {
  315.     h1 > dl:dt;
  316.     h2 > dl:dt;
  317.     h2 > dl:dt;
  318.     h3 > dl:dt;
  319.     h4 > dl:dt;
  320.     h5 > dl:dt;
  321.     h6 > dl:dt;
  322.     * > dl.dd:*;
  323.     }
  324.  
  325.  
  326. Definition list:(h1,?hr,?(level1:*)+,?(h2,?(level2:*)+,?((h3|h4|h5|h6),(level3:*)+)+)+)+;
  327.     {
  328.     h1 > dl:dt;
  329.     level1>dl.dd:*;
  330.     h2 > dl.dd:dl.dt ;
  331.     level2 > dl.dd.dl.dd:*;
  332.     h3 > dl.dd.dl.dd:dl.dt ;
  333.     h4 > dl.dd.dl.dd:dl.dt ;
  334.     h5 > dl.dd.dl.dd:dl.dt ;
  335.     h6 > dl.dd.dl.dd:dl.dt ;
  336.     level3 > dl.dd.dl.dd.dl.dd:*;
  337.     }
  338.  
  339. Definition list:(h2,?hr,?(level1:*)+,(h3,?(level2:*)+,((h4|h5|h6),(level3:*)+)+)+)+;
  340.     {
  341.     h2 > dl:dt;
  342.     level1>dl.dd:*;
  343.     h3 > dl.dd:dl.dt ;
  344.     level2 > dl.dd.dl.dd:*;
  345.     h4 > dl.dd.dl.dd:dl.dt ;
  346.     h5 > dl.dd.dl.dd:dl.dt ;
  347.     h6 > dl.dd.dl.dd:dl.dt ;
  348.     level3 > dl.dd.dl.dd.dl.dd:*;
  349.     }
  350.  
  351.  
  352.  
  353. Definition list:(h3,?hr,?(level1:*)+,?(h4,?(level2:*)+,((h5|h6),(level3:*)+)+)+)+;
  354.     {
  355.     h3 > dl:dt;
  356.     level1>dl.dd:*;
  357.     h4 > dl.dd:dl.dt ;
  358.     level2 > dl.dd.dl.dd:*;
  359.     h5 > dl.dd.dl.dd:dl.dt ;
  360.     h6 > dl.dd.dl.dd:dl.dt ;
  361.     level3 > dl.dd.dl.dd.dl.dd:*;
  362.     }
  363.  
  364. Multi level Definition list:(h4,?hr,?(level1:*)+,(h5,?(level2:*)+,((h6)+,(level3:*)+)+)+)+;
  365.     {
  366.     h4 > dl:dt;
  367.     level1>dl.dd:*;
  368.     h5 > dl.dd:dl.dt ;
  369.     level2 > dl.dd.dl.dd:*;
  370.     h6 > dl.dd.dl.dd:dl.dt ;
  371.     level3 > dl.dd.dl.dd.dl.dd:*;
  372.     }
  373.  
  374.  
  375.  
  376. Headings h1:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  377.     {
  378.     dt1 > :h1;
  379.     dt2 > :h2;
  380.     dt3 > :h3;
  381.     content > :*;
  382.     }
  383.  
  384. Headings h2:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  385.     {
  386.     dt1 > :h2;
  387.     dt2 > :h3;
  388.     dt3 > :h4;
  389.     content > :*;
  390.     }
  391.  
  392.  
  393. Headings h3:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  394.     {
  395.     dt1 > :h3;
  396.     dt2 > :h4;
  397.     dt3 > :h5;
  398.     content > :*;
  399.     }
  400.  
  401. Definition list: p,*+;
  402.     {
  403.     p > dl:dt;
  404.     * > dl.dd:*;
  405.     }
  406.  
  407. Remove Div: (div{*+})+;
  408.     {
  409.         * > :*;
  410.     }
  411.  
  412. Remove Center: (center{*+})+;
  413.     {
  414.         * > :*;
  415.     }
  416.  
  417. Remove Paragraph level: p{img};
  418.          {
  419.         img > :*;
  420.          }
  421.  
  422. Remove BlockQuote: blockquote{*+};
  423.     {
  424.     * > :*;
  425.     }
  426.  
  427. Remove font: font{*+};
  428.     {
  429.     * > :*;
  430.     }
  431.  
  432. Remove span: span{*+};
  433.     {
  434.     *>:*;
  435.     }
  436.  
  437. Remove Subscript: sub{*+};
  438.     {
  439.     * > :*;
  440.     }
  441.     
  442. Remove Superscript: sup{*+};
  443.     {
  444.     * > :*;
  445.     }
  446.     
  447. Remove Quotation: q{*+};
  448.     {
  449.         * > :*;
  450.     }
  451.  
  452. Remove BiDi: bdo{*+};
  453.     {
  454.         * > :*;
  455.     }
  456.  
  457. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  458. ! Global Document transformation tests !
  459. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  460.  
  461. DistrThot: body{*+}
  462.     {
  463.     body >     <table border="0" with="100%">.tbody.tr.<td with="30%">.<a href="http://opera.inrialpes.fr/OPERA/Thot.en.html"><img src="thot.gif" alt="Thot Editor" border="0" align="middle">;
  464.     body > table.tbody.tr.td:<a href="http://opera.inrialpes.fr">.<img src="opera.gif" alt="Opera project" border="0" align="middle">;
  465.     body > table.tbody.tr:td.<img src="guide.gif" alt="Documentation" border="0" align="middle">;
  466.     body > table.tbody.tr.td:h1."Title of the page";
  467.     body > :<table border="0" with="100%">.tbody.tr.<td with="30%">.h2.<a href="Index.html">."Home";
  468.     * > table.tbody.tr:td.*;
  469.     }
  470.  
  471.