Annotation of Amaya/amaya/HTML.trans, revision 1.35

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

Webmaster