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

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.7       vatton    330:        h1 > form:h1;
                    331:        h2 > form:h2;
                    332:        h3 > form:h3;
                    333:        h4 > form:h4;
                    334:        h5 > form:h5;
                    335:        h6 > form:h6;
                    336:        p > form:p;
1.1       vatton    337:        }
                    338: 
                    339: Retirer Formulaire: form{?*+};
                    340:        {
                    341:        * > :*;
                    342:        }
                    343: 
                    344: Retirer le sous-menu: (optgroup{*+})+;
                    345:        {
                    346:         * > :*;
                    347:        }
                    348: 
                    349: ! Lists to/from elements
                    350: !!!!!!!!!!!!!!!!!!!!!!!!
                    351: 
                    352: Liste à puces: (p|ol|menu|dir|pre|form)+;
                    353:        {
1.8     ! vatton    354:         p > <ul class=p.class>:<li style=p.style>;
        !           355:         ol > <ul class=ol.class>;
1.1       vatton    356:         pre > ul:li.pre;
                    357:         form > ul:li.form;
                    358:         }
                    359: 
                    360: Liste numérotée:(p|ul|menu|dir|pre|form)+;
                    361:           {
1.8     ! vatton    362:         p > <ol class=p.class>:<li style=p.style>;
        !           363:         ul > <ol class=ul.class>;
1.1       vatton    364:         pre > ol:li.pre;
                    365:         form > ol:li.form;
                    366:         }
                    367: 
                    368: 
1.6       vatton    369: !Tables to/from lists
                    370: !!!!!!!!!!!!!!!!!!!!
                    371: 
                    372: Table: *{(lev1:li{?(*{(lev2:li)+}|elem:*)+})+};
1.1       vatton    373:        {
1.6       vatton    374:        lev1 > <table border="1">:tr;
                    375:        elem > table.tr:td.*;
                    376:        lev2 > table.tr:td;
1.1       vatton    377:        }
                    378: 
1.6       vatton    379: Table: dl{(dt|dd)+};
1.1       vatton    380:        {
1.6       vatton    381:        dt > <table border="1">.tbody:tr.td;
                    382:        dd > table.tbody.tr:td;
1.1       vatton    383:        }
                    384: 
1.6       vatton    385: Liste numérotée:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
                    386:        {
                    387:        caption > :ol.li.strong;
                    388:        block > :ol;
                    389:        tr > ol:li;
                    390:        td > ol.li:;
                    391:        th > ol.li:;
                    392:        td2 > ol.li.ul:li;
                    393:        th2 > ol.li.ul:li;
1.1       vatton    394:        }
                    395: 
1.6       vatton    396: Liste à puces:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
1.1       vatton    397:        {
1.6       vatton    398:        caption > :ul.li.strong;
                    399:        block > :ul;
                    400:        tr > ul:li;
                    401:        td > ul.li:;
                    402:        th > ul.li:;
                    403:        td2 > ul.li.ul:li;
                    404:        th2 > ul.li.ul:li;
1.1       vatton    405:        }
                    406: 
1.6       vatton    407: Liste de définition:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
                    408:         {
                    409:         caption > :dl.dt;
                    410:         block   > :dl;
                    411:         td      > dl:dt;
                    412:         th      > dl:dt;
                    413:         td2     > dl:dd;
                    414:         th2     > dl:dd;
                    415:         }
1.1       vatton    416: 
1.6       vatton    417: ! Remove elements
                    418: !!!!!!!!!!!!!!!!!!!!!!!!!
1.1       vatton    419: 
                    420: Retirer la division: (div{*+})+;
                    421:        {
                    422:         * > :*;
                    423:        }
                    424: 
                    425: Retirer le Centrer: (center{*+})+;
                    426:        {
                    427:         * > :*;
                    428:        }
                    429: 
                    430: Retirer le niveau paragraphe: p{img};
                    431:        {
                    432:         img > :*;
                    433:        }
                    434: 
                    435: Retirer le BlockQuote: blockquote{*+};
                    436:        {
                    437:        * > :*;
                    438:        }
                    439: 
                    440: Retirer l'élément font: font{*+};
                    441:        {
                    442:        * > :*;
                    443:        }
                    444: 
                    445: Retirer l'élément span: span{*+};
                    446:        {
                    447:        * > :*;
                    448:        }
                    449: 
                    450: Retirer le Subscript: sub{*+};
                    451:        {
                    452:        * > :*;
                    453:        }
                    454:        
                    455: Retirer le Superscript: sup{*+};
                    456:        {
                    457:        * > :*;
                    458:        }
                    459:        
                    460: Retirer la Quotation: q{*+};
                    461:        {
                    462:         * > :*;
                    463:        }
                    464: 
                    465: Retirer le BiDi: bdo{*+};
                    466:        {
                    467:         * > :*;
                    468:        }
                    469: 
1.6       vatton    470: ! Tables to/from elements
                    471: !!!!!!!!!!!!!!!!!!!!!!!!!
                    472: 
                    473: Table verticale: *+;
                    474:        {
                    475:        * > <table border="1">:tr.td.*;
                    476:        }
                    477: 
                    478: Table horizontale: *+;
                    479:        {
                    480:        * > <table border="1">.tr:td.*;
                    481:        }
                    482: 
                    483: 
                    484: Retirer la table:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+};
                    485:         {
                    486:         caption > :div.p;
                    487:         block   > :div;
                    488:         td      > :div;
                    489:         th      > :div;
                    490:         td2     > :div;
                    491:         th2     > :div;
                    492:         }
                    493: 
                    494: Transposer la table:table{tbody{tr{(td|th)+}|(tr{td2:td|th2:th})+}};
                    495:        {
                    496:        td > <table border=table.border>:tr.td;
                    497:        th > table:tr.td;
                    498:        td2 > <table border=table.border>.tr:td;
                    499:        th2 > table.tr:td;
                    500:        }
                    501: 
                    502: Cellule titre:?(td|th)+,td,?(td|th)+;
                    503:        {
                    504:        $ChangeToHeadingCell;
                    505:        }
                    506: 
                    507: Cellule:?(td|th)+,th,?(td|th)+;
                    508:        {
                    509:        $ChangeToDataCell;
                    510:        }
                    511: 
1.1       vatton    512: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    513: ! Global Document transformation tests !
                    514: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    515: 
                    516: DistrThot: body{*+}
                    517:        {
                    518:        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">;
                    519:        body > table.tbody.tr.td:<a href="http://opera.inrialpes.fr">.<img src="opera.gif" alt="Opera project" border="0" align="middle">;
                    520:        body > table.tbody.tr:td.<img src="guide.gif" alt="Documentation" border="0" align="middle">;
                    521:        body > table.tbody.tr.td:h1."Title of the page";
                    522:        body > :<table border="0" with="100%">.tbody.tr.<td with="30%">.h2.<a href="Index.html">."Home";
                    523:        * > table.tbody.tr:td.*;
                    524:        }

Webmaster