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

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