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

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

Webmaster