home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 September / PCWorld_2002-09_cd.bin / Komunik / amaya / 9x / amaya-Win98-6.2.exe / _SETUP.1 / HTML.trans < prev    next >
Encoding:
Text File  |  2001-06-13  |  9.9 KB  |  481 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. Bulleted list:(ol{(li{(*)+})+})+;
  95.         {
  96.         * > ul:li.*;
  97.         }
  98.  
  99. Numbered list:(ul{(li{(*)+})+})+;
  100.         {
  101.     * > ol:li.*;
  102.         }
  103.  
  104. Remove dl: (dl{(dt{(dtc:*)+}|dd{(ddc:*)+})+})+;
  105.     {
  106.      dtc > :<* style="font-weight:bold">;
  107.      ddc > :*;
  108.     }
  109.  
  110. !flattering headings 
  111. !!!!!!!!!!!!!!!!!!!!
  112.  
  113. Paragraphs: 
  114. (h1|h2|h3|h4|h5|h6|*{(li{(il:*)+})+}),(h1|h2|h3|h4|h5|h6|p|*{(li{(il:*)+})+})+;
  115.     { 
  116.     h1 > :p;
  117.     h2 > :p;
  118.     h3 > :p;
  119.     h4 > :p;
  120.     h5 > :p;
  121.     h6 > :p;
  122.     p > :p;
  123.     il > :p;
  124.     }
  125.  
  126. ! Preformatted to/from paragraphs
  127. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  128.  
  129. !Preformatted: p+;
  130. !    {
  131. !    p>:pre;
  132. !    }
  133.  
  134. !Paragraph: pre+;
  135. !    {
  136. !    pre>:p;
  137. !    }
  138.  
  139.  
  140. !Tables to/from lists
  141. !!!!!!!!!!!!!!!!!!!!
  142.  
  143. Table: *{(lev1:li{?(*{(lev2:li)+}|elem:*)+})+};
  144.     {
  145.     lev1 > <table border="1">:tr;
  146.     elem > table.tr:td.*;
  147.     lev2 > table.tr:td;
  148.     }
  149.  
  150. Table: dl{(dt|dd)+};
  151.     {
  152.     dt > <table border="1">.tbody:tr.td;
  153.     dd > table.tbody.tr:td;
  154.     }
  155.  
  156. Numbered List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  157.       {
  158.     caption > :ol.li.strong;
  159.     block > :ol;
  160.     tr > ol:li;
  161.     td > ol.li:;
  162.     th > ol.li:;
  163.     td2 >ol.li.ul:li;
  164.     th2 >ol.li.ul:li;
  165.     }
  166.  
  167. Bulleted List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  168.     {
  169.     caption > :ul.li.strong;
  170.     block > :ul;
  171.     tr > ul:li;
  172.     td > ul.li:;
  173.     th > ul.li:;
  174.     td2 >ul.li.ul:li;
  175.     th2 >ul.li.ul:li;
  176.     }
  177. Definition List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
  178.         {
  179.         caption > :dl.dt;
  180.         block   > :dl;
  181.         td      > dl:dt;
  182.         th      > dl:dt;
  183.         td2     > dl:dd;
  184.         th2     > dl:dd;
  185.         }
  186.  
  187. ! List transformations
  188. !!!!!!!!!!!!!!!!!!!!!!
  189.  
  190. Remove one level: *{(li{(cont:*)+})+};
  191.     {
  192.     cont > :*;
  193.     }
  194.  
  195. Remove two levels: *{(li{(*{?(li{(lev2:*)+})+})+})+};
  196.     {
  197.     lev2 > :*;
  198.     }
  199.  
  200. Merge Items: li,(li2:li)+;
  201.     {
  202.     li > li:;
  203.     li2 > li:;
  204.     }
  205. Remove Paragraph level: li{p{(cont:*)+},?(next:*)+};
  206.     {
  207.          li > li:;
  208.          cont > *;
  209.          next > *;
  210.          }
  211. Remove Underline: (u{*+})+;
  212.         {
  213.         * > :*;
  214.         }
  215.  
  216. Split Items: (li{a:*,(b:*)+})+;
  217.     {
  218.     a > :li.*;
  219.     b > :li.*;
  220.     }
  221.  
  222. Merge Lists: ul{li+},(ul{li+})+;
  223.     {
  224.     li > ul:li;
  225.     }
  226.  
  227. Merge Lists: ol{li+},(ol{li+})+;
  228.     {
  229.     li > ol:li;
  230.     }
  231.  
  232. Merge Lists: dl{(dt|dd)+},(dl{(dt|dd)+})+;
  233.     {
  234.     dt > dl:dt;
  235.     dd > dl:dd;
  236.     }
  237.  
  238. ! Forms to/from elements
  239. !!!!!!!!!!!!!!!!!!!!!!!!
  240.  
  241. Form: *+;
  242.     {
  243.     *>Form:*;
  244.     }
  245.  
  246. Remove Form: form{*+};
  247.     {
  248.     *>:*;
  249.     }
  250.  
  251. Remove submenu: (optgroup{*+})+;
  252.     {
  253.         * > :*;
  254.     }
  255.  
  256. ! Lists to/from elements
  257. !!!!!!!!!!!!!!!!!!!!!!!!
  258.  
  259. Bulleted list: (p|ol|menu|dir|pre|form)+;
  260.        {
  261.         p > ul:<li style=p.style>;
  262.         ol> ul;
  263.         pre> ul:li.pre;
  264.         form> ul:li.form;
  265.         }
  266.  
  267. Numbered list:(p|ul|menu|dir|pre|form)+;
  268.        {
  269.         p > ol:li;
  270.         ul> ol;
  271.         pre> ol:li.pre;
  272.         form> ol:li.form;
  273.         }
  274.  
  275. ! Tables to/from elements
  276. !!!!!!!!!!!!!!!!!!!!!!!!!
  277.  
  278. !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|*)+;
  279. !    {
  280. !    p> <table border="1">.tr.td:p;
  281. !    h> <table border="1">:tr.td.*;
  282. !    *> <table border="1">.tr:td.*;
  283. !    }
  284.  
  285.  
  286. Vertical Table: *+;
  287.     {
  288.     *><table border="1">:tr.td.*;
  289.     }
  290.  
  291. Horizontal Table : *+;
  292.     {
  293.     *><table border="1">.tr:td.*;
  294.     }
  295.  
  296. Remove Table:table{?caption,?(body:*{(tr{(*{(?cell_content:*)+})+})+})+};
  297.     {
  298.     caption>h3;
  299.     cell_content>:*;
  300.     }
  301.  
  302. Transpose Table:table{tbody{tr{(td|th)+}|(tr{td2:td|th2:th})+}};
  303.     {
  304.     td><table border=table.border>:tr.td;
  305.     th>table:tr.td;
  306.     td2><table border=table.border>.tr:td;
  307.     th2>table.tr:td;
  308.     }
  309.  
  310. Heading Cell :?(td|th)+,td,?(td|th)+;
  311.     {
  312.     td>:th;
  313.     }
  314.  
  315. Data Cell :?(td|th)+,th,?(td|th)+;
  316.     {
  317.     th>:td;
  318.     }
  319.  
  320. !headings to/from definitions
  321. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  322.  
  323. Definition list:((h1|h2|h3|h4|h5|h6),*+)+;
  324.     {
  325.     h1 > dl:dt;
  326.     h2 > dl:dt;
  327.     h2 > dl:dt;
  328.     h3 > dl:dt;
  329.     h4 > dl:dt;
  330.     h5 > dl:dt;
  331.     h6 > dl:dt;
  332.     * > dl.dd:*;
  333.     }
  334.  
  335.  
  336. Definition list:(h1,?hr,?(level1:*)+,?(h2,?(level2:*)+,?((h3|h4|h5|h6),(level3:*)+)+)+)+;
  337.     {
  338.     h1 > dl:dt;
  339.     level1>dl.dd:*;
  340.     h2 > dl.dd:dl.dt ;
  341.     level2 > dl.dd.dl.dd:*;
  342.     h3 > dl.dd.dl.dd:dl.dt ;
  343.     h4 > dl.dd.dl.dd:dl.dt ;
  344.     h5 > dl.dd.dl.dd:dl.dt ;
  345.     h6 > dl.dd.dl.dd:dl.dt ;
  346.     level3 > dl.dd.dl.dd.dl.dd:*;
  347.     }
  348.  
  349. Definition list:(h2,?hr,?(level1:*)+,(h3,?(level2:*)+,((h4|h5|h6),(level3:*)+)+)+)+;
  350.     {
  351.     h2 > dl:dt;
  352.     level1>dl.dd:*;
  353.     h3 > dl.dd:dl.dt ;
  354.     level2 > dl.dd.dl.dd:*;
  355.     h4 > dl.dd.dl.dd:dl.dt ;
  356.     h5 > dl.dd.dl.dd:dl.dt ;
  357.     h6 > dl.dd.dl.dd:dl.dt ;
  358.     level3 > dl.dd.dl.dd.dl.dd:*;
  359.     }
  360.  
  361.  
  362.  
  363. Definition list:(h3,?hr,?(level1:*)+,?(h4,?(level2:*)+,((h5|h6),(level3:*)+)+)+)+;
  364.     {
  365.     h3 > dl:dt;
  366.     level1>dl.dd:*;
  367.     h4 > dl.dd:dl.dt ;
  368.     level2 > dl.dd.dl.dd:*;
  369.     h5 > dl.dd.dl.dd:dl.dt ;
  370.     h6 > dl.dd.dl.dd:dl.dt ;
  371.     level3 > dl.dd.dl.dd.dl.dd:*;
  372.     }
  373.  
  374. Multi level Definition list:(h4,?hr,?(level1:*)+,(h5,?(level2:*)+,((h6)+,(level3:*)+)+)+)+;
  375.     {
  376.     h4 > dl:dt;
  377.     level1>dl.dd:*;
  378.     h5 > dl.dd:dl.dt ;
  379.     level2 > dl.dd.dl.dd:*;
  380.     h6 > dl.dd.dl.dd:dl.dt ;
  381.     level3 > dl.dd.dl.dd.dl.dd:*;
  382.     }
  383.  
  384.  
  385.  
  386. Headings h1:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  387.     {
  388.     dt1 > :h1;
  389.     dt2 > :h2;
  390.     dt3 > :h3;
  391.     content > :*;
  392.     }
  393.  
  394. Headings h2:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  395.     {
  396.     dt1 > :h2;
  397.     dt2 > :h3;
  398.     dt3 > :h4;
  399.     content > :*;
  400.     }
  401.  
  402.  
  403. Headings h3:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
  404.     {
  405.     dt1 > :h3;
  406.     dt2 > :h4;
  407.     dt3 > :h5;
  408.     content > :*;
  409.     }
  410.  
  411. Definition list: p,*+;
  412.     {
  413.     p > dl:dt;
  414.     * > dl.dd:*;
  415.     }
  416.  
  417. Remove Div: (div{*+})+;
  418.     {
  419.         * > :*;
  420.     }
  421.  
  422. Remove Center: (center{*+})+;
  423.     {
  424.         * > :*;
  425.     }
  426.  
  427. Remove Paragraph level: p{img};
  428.          {
  429.         img > :*;
  430.          }
  431.  
  432. Remove BlockQuote: blockquote{*+};
  433.     {
  434.     * > :*;
  435.     }
  436.  
  437. Remove font: font{*+};
  438.     {
  439.     * > :*;
  440.     }
  441.  
  442. Remove span: span{*+};
  443.     {
  444.     *>:*;
  445.     }
  446.  
  447. Remove Subscript: sub{*+};
  448.     {
  449.     * > :*;
  450.     }
  451.     
  452. Remove Superscript: sup{*+};
  453.     {
  454.     * > :*;
  455.     }
  456.     
  457. Remove Quotation: q{*+};
  458.     {
  459.         * > :*;
  460.     }
  461.  
  462. Remove BiDi: bdo{*+};
  463.     {
  464.         * > :*;
  465.     }
  466.  
  467. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  468. ! Global Document transformation tests !
  469. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  470.  
  471. DistrThot: body{*+}
  472.     {
  473.     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">;
  474.     body > table.tbody.tr.td:<a href="http://opera.inrialpes.fr">.<img src="opera.gif" alt="Opera project" border="0" align="middle">;
  475.     body > table.tbody.tr:td.<img src="guide.gif" alt="Documentation" border="0" align="middle">;
  476.     body > table.tbody.tr.td:h1."Title of the page";
  477.     body > :<table border="0" with="100%">.tbody.tr.<td with="30%">.h2.<a href="Index.html">."Home";
  478.     * > table.tbody.tr:td.*;
  479.     }
  480.  
  481.