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

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

Webmaster