Annotation of Amaya/amaya/HTML.trans.fr, revision 1.4

1.1       vatton      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: ! a) The NAME will appear in the transform menu.
                     23: !
                     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
                     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: ! c) RULES express transformations to be applied to the elements 
                     38: ! identified in the pattern.
                     39: ! Each rule end with a symbol ";"
                     40: !
                     41: ! - It could be performed by an action rule. In this case the rule
                     42: !   starts with a "$" followed by the menu action to be called.
                     43: !
                     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. 
                     62: !
                     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.
                     67: 
                     68: ! Transformation rules 
                     69: !!!!!!!!!!!!!!!!!!!!!!
                     70: 
                     71: Adresse:(p{*+})+;
                     72:        {
                     73:        * > address:*;
                     74:        }
                     75: 
                     76: Paragraphe:(address{*+});
                     77:        {
                     78:        * > p:*;
                     79:        }
                     80: 
                     81: !between lists
                     82: !!!!!!!!!!!!!!
                     83: 
                     84: Liste de définition:*{(li{(list:*{(li2:li)+}|other:*)+})+};
                     85:        {
                     86:        other > dl:dt;
                     87:        list > dl:dd;
                     88:        li2 > dl.dd:;
                     89:        }
                     90: 
                     91: Liste à puces:(dl{(dt|dd{(*)+})+})+;
                     92:        {
                     93:        dt > ul:li;
                     94:        * > ul.li.ul:li.*;
                     95:        }
                     96: 
                     97: Liste numérotée:(dl{(dt|dd{(*)+})+})+;
                     98:        {
                     99:        dt > ol:li;
                    100:        * > ol.li.ol:li.*;
                    101:        }
                    102: 
                    103: Liste à puces:(ol{(li{(*)+})+})+;
                    104:         {
                    105:         * > ul:li.*;
                    106:         }
                    107: 
                    108: Liste numérotée:(ul{(li{(*)+})+})+;
                    109:         {
                    110:        * > ol:li.*;
                    111:         }
                    112: 
                    113: Retirer la liste de définition: (dl{(dt{(dtc:*)+}|dd{(ddc:*)+})+})+;
                    114:        {
                    115:         dtc > :<* style="font-weight:bold">;
                    116:         ddc > :*;
                    117:        }
                    118: 
                    119: !flattering headings 
                    120: !!!!!!!!!!!!!!!!!!!!
                    121: 
                    122: Paragraphes: 
                    123: (h1|h2|h3|h4|h5|h6|*{(li{(il:*)+})+}),(h1|h2|h3|h4|h5|h6|p|*{(li{(il:*)+})+})+;
                    124:        { 
                    125:        h1 > :p;
                    126:        h2 > :p;
                    127:        h3 > :p;
                    128:        h4 > :p;
                    129:        h5 > :p;
                    130:        h6 > :p;
                    131:        p > :p;
                    132:        il > :p;
                    133:        }
                    134: 
                    135: ! Preformatted to/from paragraphs
                    136: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    137: 
1.2       vatton    138: Preformaté: (p{*+})+;
1.1       vatton    139:        {
1.2       vatton    140:        * > pre:*;
1.1       vatton    141:        }
                    142: 
1.2       vatton    143: Paragraphe: (pre{*+})+;
1.1       vatton    144:        {
1.2       vatton    145:        *   > p:*;
1.1       vatton    146:        }
                    147: 
                    148: !Tables to/from lists
                    149: !!!!!!!!!!!!!!!!!!!!
                    150: 
                    151: Table: *{(lev1:li{?(*{(lev2:li)+}|elem:*)+})+};
                    152:        {
                    153:        lev1 > <table border="1">:tr;
                    154:        elem > table.tr:td.*;
                    155:        lev2 > table.tr:td;
                    156:        }
                    157: 
                    158: Table: dl{(dt|dd)+};
                    159:        {
                    160:        dt > <table border="1">.tbody:tr.td;
                    161:        dd > table.tbody.tr:td;
                    162:        }
                    163: 
                    164: Liste numérotée:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
                    165:        {
                    166:        caption > :ol.li.strong;
                    167:        block > :ol;
                    168:        tr > ol:li;
                    169:        td > ol.li:;
                    170:        th > ol.li:;
                    171:        td2 > ol.li.ul:li;
                    172:        th2 > ol.li.ul:li;
                    173:        }
                    174: 
                    175: Liste à puces:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
                    176:        {
                    177:        caption > :ul.li.strong;
                    178:        block > :ul;
                    179:        tr > ul:li;
                    180:        td > ul.li:;
                    181:        th > ul.li:;
                    182:        td2 > ul.li.ul:li;
                    183:        th2 > ul.li.ul:li;
                    184:        }
                    185: 
                    186: Liste de définition:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
                    187:         {
                    188:         caption > :dl.dt;
                    189:         block   > :dl;
                    190:         td      > dl:dt;
                    191:         th      > dl:dt;
                    192:         td2     > dl:dd;
                    193:         th2     > dl:dd;
                    194:         }
                    195: 
                    196: ! Other transformations
                    197: !!!!!!!!!!!!!!!!!!!!!!
                    198: 
                    199: Réunin les items: li,(li2:li)+;
                    200:        {
                    201:        li > li:;
                    202:        li2 > li:;
                    203:        }
                    204: Retirer le niveau paragraphe: li{p{(cont:*)+},?(next:*)+};
                    205:        {
                    206:        li > li:;
                    207:        cont > *;
                    208:        next > *;
                    209:        }
                    210: Retirer le souligné: (u{*+})+;
                    211:         {
                    212:         * > :*;
                    213:         }
                    214: 
                    215: Couper l'item de liste: (li{a:*,(b:*)+})+;
                    216:        {
                    217:        a > :li.*;
                    218:        b > :li.*;
                    219:        }
                    220: 
                    221: Réunir les listes: ul{li+},(ul{li+})+;
                    222:        {
                    223:        li > ul:li;
                    224:        }
                    225: 
                    226: Réunir les listes: ol{li+},(ol{li+})+;
                    227:        {
                    228:        li > ol:li;
                    229:        }
                    230: 
                    231: Réunir les listes: dl{(dt|dd)+},(dl{(dt|dd)+})+;
                    232:        {
                    233:        dt > dl:dt;
                    234:        dd > dl:dd;
                    235:        }
                    236: 
                    237: !Paragraphe: *{(li{(cont:*)+})+};
                    238: !      {
                    239: !      cont > :*;
                    240: !      }
                    241: 
                    242: Paragraphe: *{(li{(*{?(li{(lev2:*)+})+})+})+};
                    243:        {
                    244:        lev2 > :*;
                    245:        }
                    246: 
                    247: Paragraphes: (ol{(li{(h1|h2|h3|h4|h5|h6|p|*)+})+})+;
                    248:        {
                    249:        h1 > :h1;
                    250:        h2 > :h2;
                    251:        h3 > :h3;
                    252:        h4 > :h4;
                    253:        h5 > :h5;
                    254:        h6 > :h6;
                    255:        p > :p;
                    256:        * > :p.*;
                    257:        }
                    258: 
                    259: Paragraphes: (ul{(li{(h1|h2|h3|h4|h5|h6|p|*)+})+})+;
                    260:        {
                    261:        h1 > :h1;
                    262:        h2 > :h2;
                    263:        h3 > :h3;
                    264:        h4 > :h4;
                    265:        h5 > :h5;
                    266:        h6 > :h6;
                    267:        p > :p;
                    268:        * > :p.*;
                    269:        }
                    270: 
                    271: Retirer 2 niveaux de liste: *{(li{(*{?(li{(lev2:*)+})+})+})+};
                    272:        {
                    273:        lev2 > :*;
                    274:        }
                    275: 
                    276: ! Forms to/from elements
                    277: !!!!!!!!!!!!!!!!!!!!!!!!
                    278: 
1.4     ! vatton    279: Englober dans Formulaire: *+;
1.1       vatton    280:        {
                    281:        * > Form:*;
                    282:        }
                    283: 
                    284: Retirer Formulaire: form{?*+};
                    285:        {
                    286:        * > :*;
                    287:        }
                    288: 
                    289: Retirer le sous-menu: (optgroup{*+})+;
                    290:        {
                    291:         * > :*;
                    292:        }
                    293: 
                    294: ! Lists to/from elements
                    295: !!!!!!!!!!!!!!!!!!!!!!!!
                    296: 
                    297: Liste à puces: (p|ol|menu|dir|pre|form)+;
                    298:        {
                    299:         p > ul:<li style=p.style>;
                    300:         ol > ul;
                    301:         pre > ul:li.pre;
                    302:         form > ul:li.form;
                    303:         }
                    304: 
                    305: Liste numérotée:(p|ul|menu|dir|pre|form)+;
                    306:           {
                    307:         p > ol:li;
                    308:         ul > ol;
                    309:         pre > ol:li.pre;
                    310:         form > ol:li.form;
                    311:         }
                    312: 
                    313: ! Tables to/from elements
                    314: !!!!!!!!!!!!!!!!!!!!!!!!!
                    315: 
                    316: Table verticale: *+;
                    317:        {
                    318:        * > <table border="1">:tr.td.*;
                    319:        }
                    320: 
                    321: Table horizontale: *+;
                    322:        {
                    323:        * > <table border="1">.tr:td.*;
                    324:        }
                    325: 
                    326: 
                    327: Retirer la table:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
                    328:         {
                    329:         caption > :div.p;
                    330:         block   > :div;
                    331:         td      > :div;
                    332:         th      > :div;
                    333:         td2     > :div;
                    334:         th2     > :div;
                    335:         }
                    336: 
                    337: !Remove Table:table{?caption,?(body:*{(tr{(*{(?cell_content:*)+})+})+})+};
                    338: !      {
                    339: !      caption > h3;
                    340: !      cell_content > :*;
                    341: !      }
                    342: 
                    343: Transposer la table:table{tbody{tr{(td|th)+}|(tr{td2:td|th2:th})+}};
                    344:        {
                    345:        td > <table border=table.border>:tr.td;
                    346:        th > table:tr.td;
                    347:        td2 > <table border=table.border>.tr:td;
                    348:        th2 > table.tr:td;
                    349:        }
                    350: 
                    351: Cellule titre :?(td|th)+,td,?(td|th)+;
                    352:        {
1.3       vatton    353:        $ChangeToHeadingCell;
1.1       vatton    354:        }
                    355: 
                    356: Cellule :?(td|th)+,th,?(td|th)+;
                    357:        {
1.3       vatton    358:        $ChangeToDataCell;
1.1       vatton    359:        }
                    360: 
                    361: !headings to/from definitions
                    362: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    363: 
                    364: Liste de définition:((h1|h2|h3|h4|h5|h6),*+)+;
                    365:        {
                    366:        h1 > dl:dt;
                    367:        h2 > dl:dt;
                    368:        h2 > dl:dt;
                    369:        h3 > dl:dt;
                    370:        h4 > dl:dt;
                    371:        h5 > dl:dt;
                    372:        h6 > dl:dt;
                    373:        * > dl.dd:*;
                    374:        }
                    375: 
                    376: Liste de définition:(h1,?hr,?(level1:*)+,?(h2,?(level2:*)+,?((h3|h4|h5|h6),(level3:*)+)+)+)+;
                    377:        {
                    378:        h1 > dl:dt;
                    379:        level1>dl.dd:*;
                    380:        h2 > dl.dd:dl.dt ;
                    381:        level2 > dl.dd.dl.dd:*;
                    382:        h3 > dl.dd.dl.dd:dl.dt ;
                    383:        h4 > dl.dd.dl.dd:dl.dt ;
                    384:        h5 > dl.dd.dl.dd:dl.dt ;
                    385:        h6 > dl.dd.dl.dd:dl.dt ;
                    386:        level3 > dl.dd.dl.dd.dl.dd:*;
                    387:        }
                    388: 
                    389: Liste de définition:(h2,?hr,?(level1:*)+,(h3,?(level2:*)+,((h4|h5|h6),(level3:*)+)+)+)+;
                    390:        {
                    391:        h2 > dl:dt;
                    392:        level1 > dl.dd:*;
                    393:        h3 > dl.dd:dl.dt ;
                    394:        level2 > dl.dd.dl.dd:*;
                    395:        h4 > dl.dd.dl.dd:dl.dt ;
                    396:        h5 > dl.dd.dl.dd:dl.dt ;
                    397:        h6 > dl.dd.dl.dd:dl.dt ;
                    398:        level3 > dl.dd.dl.dd.dl.dd:*;
                    399:        }
                    400: 
                    401: Liste de définition:(h3,?hr,?(level1:*)+,?(h4,?(level2:*)+,((h5|h6),(level3:*)+)+)+)+;
                    402:        {
                    403:        h3 > dl:dt;
                    404:        level1 > dl.dd:*;
                    405:        h4 > dl.dd:dl.dt ;
                    406:        level2 > dl.dd.dl.dd:*;
                    407:        h5 > dl.dd.dl.dd:dl.dt ;
                    408:        h6 > dl.dd.dl.dd:dl.dt ;
                    409:        level3 > dl.dd.dl.dd.dl.dd:*;
                    410:        }
                    411: 
                    412: Liste de définition multi-niveaux:(h4,?hr,?(level1:*)+,(h5,?(level2:*)+,((h6)+,(level3:*)+)+)+)+;
                    413:        {
                    414:        h4 > dl:dt;
                    415:        level1 > dl.dd:*;
                    416:        h5 > dl.dd:dl.dt ;
                    417:        level2 > dl.dd.dl.dd:*;
                    418:        h6 > dl.dd.dl.dd:dl.dt ;
                    419:        level3 > dl.dd.dl.dd.dl.dd:*;
                    420:        }
                    421: 
                    422: Titre h1:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
                    423:        {
                    424:        dt1 > :h1;
                    425:        dt2 > :h2;
                    426:        dt3 > :h3;
                    427:        content > :*;
                    428:        }
                    429: 
                    430: Titre h2:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
                    431:        {
                    432:        dt1 > :h2;
                    433:        dt2 > :h3;
                    434:        dt3 > :h4;
                    435:        content > :*;
                    436:        }
                    437: 
                    438: Titre h3:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+;
                    439:        {
                    440:        dt1 > :h3;
                    441:        dt2 > :h4;
                    442:        dt3 > :h5;
                    443:        content > :*;
                    444:        }
                    445: 
                    446: Liste de définition: p,*+;
                    447:        {
                    448:        p > dl:dt;
                    449:        * > dl.dd:*;
                    450:        }
                    451: 
                    452: Retirer la division: (div{*+})+;
                    453:        {
                    454:         * > :*;
                    455:        }
                    456: 
                    457: Retirer le Centrer: (center{*+})+;
                    458:        {
                    459:         * > :*;
                    460:        }
                    461: 
                    462: Retirer le niveau paragraphe: p{img};
                    463:        {
                    464:         img > :*;
                    465:        }
                    466: 
                    467: Retirer le BlockQuote: blockquote{*+};
                    468:        {
                    469:        * > :*;
                    470:        }
                    471: 
                    472: Retirer l'élément font: font{*+};
                    473:        {
                    474:        * > :*;
                    475:        }
                    476: 
                    477: Retirer l'élément span: span{*+};
                    478:        {
                    479:        * > :*;
                    480:        }
                    481: 
                    482: Retirer le Subscript: sub{*+};
                    483:        {
                    484:        * > :*;
                    485:        }
                    486:        
                    487: Retirer le Superscript: sup{*+};
                    488:        {
                    489:        * > :*;
                    490:        }
                    491:        
                    492: Retirer la Quotation: q{*+};
                    493:        {
                    494:         * > :*;
                    495:        }
                    496: 
                    497: Retirer le BiDi: bdo{*+};
                    498:        {
                    499:         * > :*;
                    500:        }
                    501: 
                    502: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    503: ! Global Document transformation tests !
                    504: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    505: 
                    506: DistrThot: body{*+}
                    507:        {
                    508:        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">;
                    509:        body > table.tbody.tr.td:<a href="http://opera.inrialpes.fr">.<img src="opera.gif" alt="Opera project" border="0" align="middle">;
                    510:        body > table.tbody.tr:td.<img src="guide.gif" alt="Documentation" border="0" align="middle">;
                    511:        body > table.tbody.tr.td:h1."Title of the page";
                    512:        body > :<table border="0" with="100%">.tbody.tr.<td with="30%">.h2.<a href="Index.html">."Home";
                    513:        * > table.tbody.tr:td.*;
                    514:        }

Webmaster