Annotation of Amaya/amaya/HTML.trans, revision 1.18

1.1       cvs         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
1.2       cvs         5: ! the editor. So new transformations can be added while editing.
1.1       cvs         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
1.2       cvs        14: ! the editor. So new transformations can be added while editing.
1.1       cvs        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
1.2       cvs        20: !           terminated by a semi-colon ";"
1.1       cvs        21: !
                     22: ! The name will appear in the transform menu.
                     23: !
                     24: ! The pattern gives of a specific organization of the elements
                     25: ! to be transformed: it contains HTML tags and SGML-like syntax
                     26: ! for the composition operators:
1.10      cvs        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
1.1       cvs        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: ! A rule expresses transformations to be applied to the elements 
1.10      cvs        38: ! identified in the pattern. They have two parts :
                     39: !        - a source identifier: a tag or a name which occurs in
                     40: !          the pattern and links the rule to the pattern nodes
                     41: !        -  a rule body: drives the transformation
                     42: !  Each rule end with a symbol ";"
                     43: !
                     44: ! there are two kinds of rule bodies:
                     45: ! - A discard rule body is slash and express that the correspoding
                     46: !    pattern node does not occurin the transformation result
                     47: !
                     48: ! - A generation rule begins with
                     49: !     - a symbol ">"
1.1       cvs        50: !     - and a target tag list. This list is itself divided into
                     51: !       two parts separated by a colon":": 
                     52: !         * the generation location path
                     53: !         * and the list of tags to be generated
                     54: ! The dot symbol "." is used for descending in the tree structure.
                     55: ! if the special token star "*" ends the list of tags to be 
                     56: ! generated, the source elment tag is not changed but this element
                     57: ! can be moved in a different place in the destination. 
1.10      cvs        58: !
                     59: ! The rules are applied in the order the identifeiers are met when
                     60: ! (depth first) traversing the source structure.
                     61: ! Several rules may have the same identifier, in that case, the rules
                     62: ! are applied in the order they are defined.
1.1       cvs        63: 
                     64: ! Transformation rules 
                     65: !!!!!!!!!!!!!!!!!!!!!!
                     66: 
1.9       cvs        67: Address:(P{*+})+;
                     68:        {
                     69:        * > ADDRESS:*;
                     70:        }
                     71: 
1.1       cvs        72: !between lists
                     73: !!!!!!!!!!!!!!
                     74: 
                     75: Definition list:*{(LI{(P|list:*{(li2:LI)+})+})+};
                     76:        {
                     77:        P > DL:DT;
                     78:        list > DL:DD;
                     79:        li2 > DL.DD:;
                     80:        }
                     81: 
                     82: Bulleted list:(DL{(DT|DD{(*)+})+})+;
                     83:        {
1.9       cvs        84:        DT > UL:LI;
1.1       cvs        85:        * > UL.LI.UL:LI.*;
                     86:        }
                     87: 
                     88: Numbered list:(DL{(DT|DD{(*)+})+})+;
                     89:        {
1.9       cvs        90:        DT > OL:LI;
1.1       cvs        91:        * > OL.LI.OL:LI.*;
                     92:        }
                     93: 
1.8       cvs        94: Remove DL: (DL{(DT|DD{*+})+})+;
1.1       cvs        95:        {
1.8       cvs        96:         DT > :P;
1.1       cvs        97:         * > :*;
                     98:        }
                     99: 
                    100: !flattering headings 
                    101: !!!!!!!!!!!!!!!!!!!!
                    102: 
                    103: Paragraphs: 
                    104: (H1|H2|H3|H4|H5|H6|*{(LI{(il:*)+})+}),(H1|H2|H3|H4|H5|H6|P|*{(LI{(il:*)+})+})+;
                    105:        { 
                    106:        H1 > :P;
                    107:        H2 > :P;
                    108:        H3 > :P;
                    109:        H4 > :P;
                    110:        H5 > :P;
                    111:        H6 > :P;
                    112:        P > :P;
                    113:        il > :P;
                    114:        }
                    115: 
                    116: ! Preformatted to/from paragraphs
                    117: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    118: 
                    119: Preformatted: P+;
                    120:        {
                    121:        P>:PRE;
                    122:        }
                    123: 
                    124: Paragraph: PRE+;
                    125:        {
                    126:        PRE>:P;
                    127:        }
                    128: 
                    129: 
                    130: 
                    131: 
                    132: !Tables to/from lists
                    133: !!!!!!!!!!!!!!!!!!!!
                    134: 
                    135: Table: *{(lev1:LI{?(*{(lev2:LI)+}|elem:*)+})+};
                    136:        {
                    137:        lev1 > <TABLE border=1>:TR;
                    138:        elem > TABLE.TR:TD.*;
                    139:        lev2 > TABLE.TR:TD;
                    140:        }
                    141: 
                    142: Table: DL{(DT|DD)+};
                    143:        {
                    144:        DT > <TABLE border=1>.TBODY:TR.TD;
                    145:        DD > TABLE.TBODY.TR:TD;
                    146:        }
                    147: 
1.11      cvs       148: Numbered List:TABLE{?CAPTION,(block:*{(TR{(TD|TH),?(TD2:TD|TH2:TH)+})+})+};
1.1       cvs       149:        {
1.12      cvs       150:        CAPTION > :OL.LI.STRONG;
1.11      cvs       151:        block > :OL;
1.1       cvs       152:        TR > OL:LI;
                    153:        TD > OL.LI:;
1.11      cvs       154:        TH > OL.LI:;
1.1       cvs       155:        TD2 >OL.LI.UL:LI;
1.11      cvs       156:        TH2 >OL.LI.UL:LI;
1.1       cvs       157:        }
                    158: 
1.11      cvs       159: Bulleted List:TABLE{?CAPTION,(block:*{(TR{(TD|TH),?(TD2:TD|TH2:TH)+})+})+};
1.1       cvs       160:        {
1.12      cvs       161:        CAPTION > :UL.LI.STRONG;
1.11      cvs       162:        block > :UL;
1.1       cvs       163:        TR > UL:LI;
                    164:        TD > UL.LI:;
1.11      cvs       165:        TH > UL.LI:;
1.1       cvs       166:        TD2 >UL.LI.UL:LI;
1.11      cvs       167:        TH2 >UL.LI.UL:LI;
1.1       cvs       168:        }
                    169: 
                    170: ! List transformations
                    171: !!!!!!!!!!!!!!!!!!!!!!
                    172: 
                    173: Remove one level: *{(LI{(cont:*)+})+};
                    174:        {
                    175:        cont > :*;
                    176:        }
                    177: 
                    178: Remove two levels: *{(LI{(*{?(LI{(Lev2:*)+})+})+})+};
                    179:        {
                    180:        Lev2 > :*;
                    181:        }
                    182: 
                    183: Merge Items: LI,(LI2:LI)+;
                    184:        {
                    185:        LI > LI:;
                    186:        LI2 > LI:;
                    187:        }
                    188: 
                    189: Split Items: (LI{a:*,(b:*)+})+;
                    190:        {
                    191:        a > :LI.*;
                    192:        b > :LI.*;
                    193:        }
                    194: 
                    195: Merge Lists: UL{LI+},(UL{LI+})+;
                    196:        {
                    197:        LI > UL:LI;
                    198:        }
                    199: 
                    200: Merge Lists: OL{LI+},(OL{LI+})+;
                    201:        {
                    202:        LI > OL:LI;
                    203:        }
                    204: 
                    205: Merge Lists: DL{(DT|DD)+},(DL{(DT|DD)+})+;
                    206:        {
                    207:        DT > DL:DT;
                    208:        DD > DL:DD;
                    209:        }
                    210: 
                    211: ! Forms to/from elements
                    212: !!!!!!!!!!!!!!!!!!!!!!!!
                    213: 
                    214: Form: *+;
                    215:        {
                    216:        *>Form:*;
                    217:        }
                    218: 
                    219: Remove Form: FORM{*+};
                    220:        {
                    221:        *>:*;
                    222:        }
                    223: 
1.16      cvs       224: Remove submenu: (OPTGROUP{*+})+;
                    225:        {
                    226:         * > :*;
                    227:        }
                    228: 
1.1       cvs       229: ! Lists to/from elements
                    230: !!!!!!!!!!!!!!!!!!!!!!!!
                    231: 
1.9       cvs       232: Bulleted list: (P|OL|MENU|DIR|PRE|FORM)+;
1.1       cvs       233:        {
1.9       cvs       234:         P > UL:LI;
                    235:         OL> UL;
1.1       cvs       236:         MENU> UL:LI.MENU;
                    237:         DIR> UL:LI.DIR;
                    238:         PRE> UL:LI.PRE;
                    239:         FORM> UL:LI.FORM;
                    240:         }
                    241: 
1.9       cvs       242: Numbered list:(P|UL|MENU|DIR|PRE|FORM)+;
1.1       cvs       243:           {
1.9       cvs       244:         P > OL:LI;
                    245:         UL> OL;
1.1       cvs       246:         MENU> OL:LI.MENU;
                    247:         DIR> OL:LI.DIR;
                    248:         PRE> OL:LI.PRE;
                    249:         FORM> OL:LI.FORM;
                    250:         }
                    251: 
                    252: ! Tables to/from elements
                    253: !!!!!!!!!!!!!!!!!!!!!!!!!
                    254: 
                    255: !Table: (H:H1|H:H2|H:H3|H:H4|H:H5|H:H6|P),(H:H1|H:H2|H:H3|H:H4|H:H5|H:H6|*)+;
                    256: !      {
                    257: !      P> <TABLE border=1>.TR.TD:P;
                    258: !      H> <TABLE border=1>:TR.TD.*;
                    259: !      *> <TABLE border=1>.TR:TD.*;
                    260: !      }
                    261: 
                    262: 
1.15      cvs       263: Vertical Table: *+;
1.1       cvs       264:        {
                    265:        *><TABLE border=1>:TR.TD.*;
                    266:        }
                    267: 
1.15      cvs       268: Horizontal Table : *+;
1.1       cvs       269:        {
                    270:        *><TABLE border=1>.TR:TD.*;
                    271:        }
                    272: 
1.11      cvs       273: Remove Table:TABLE{?CAPTION,?(body:*{(TR{(*{(?cell_content:*)+})+})+})+};
1.1       cvs       274:        {
                    275:        CAPTION>H3;
                    276:        cell_content>:*;
                    277:        }
                    278: 
1.11      cvs       279: Transpose Table:TABLE{TBODY{TR{(TD|TH)+}|(TR{td2:TD|th2:TH})+}};
1.1       cvs       280:        {
1.11      cvs       281:        TD><TABLE BORDER=TABLE.BORDER>:TR.TD;
                    282:        TH>TABLE:TR.TD;
                    283:        td2><TABLE BORDER=TABLE.BORDER>.TR:TD;
                    284:        th2>TABLE.TR:TD;
1.1       cvs       285:        }
                    286: 
1.11      cvs       287: Heading Cell :?(TD|TH)+,TD,?(TD|TH)+;
                    288:        {
                    289:        TD>:TH;
                    290:        }
                    291: 
                    292: Data Cell :?(TD|TH)+,TH,?(TD|TH)+;
                    293:        {
                    294:        TH>:TD;
                    295:        }
1.1       cvs       296: 
                    297: !headings to/from definitions
                    298: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    299: 
1.9       cvs       300: Definition list:((H1|H2|H3|H4|H5|H6),*+)+;
                    301:        {
                    302:        H1 > DL:DT;
                    303:        H2 > DL:DT;
                    304:        H2 > DL:DT;
                    305:        H3 > DL:DT;
                    306:        H4 > DL:DT;
                    307:        H5 > DL:DT;
                    308:        H6 > DL:DT;
                    309:        * > DL.DD:*;
                    310:        }
                    311: 
                    312: 
1.1       cvs       313: Definition list:(H1,?HR,?(level1:*)+,?(H2,?(level2:*)+,?((H3|H4|H5|H6),(level3:*)+)+)+)+;
                    314:        {
                    315:        H1 > DL:DT;
                    316:        level1>DL.DD:*;
                    317:        H2 > DL.DD:DL.DT ;
                    318:        level2 > DL.DD.DL.DD:*;
                    319:        H3 > DL.DD.DL.DD:DL.DT ;
                    320:        H4 > DL.DD.DL.DD:DL.DT ;
                    321:        H5 > DL.DD.DL.DD:DL.DT ;
                    322:        H6 > DL.DD.DL.DD:DL.DT ;
                    323:        level3 > DL.DD.DL.DD.DL.DD:*;
                    324:        }
                    325: 
                    326: Definition list:(H2,?HR,?(level1:*)+,(H3,?(level2:*)+,((H4|H5|H6),(level3:*)+)+)+)+;
                    327:        {
                    328:        H2 > DL:DT;
                    329:        level1>DL.DD:*;
                    330:        H3 > DL.DD:DL.DT ;
                    331:        level2 > DL.DD.DL.DD:*;
                    332:        H4 > DL.DD.DL.DD:DL.DT ;
                    333:        H5 > DL.DD.DL.DD:DL.DT ;
                    334:        H6 > DL.DD.DL.DD:DL.DT ;
                    335:        level3 > DL.DD.DL.DD.DL.DD:*;
                    336:        }
                    337: 
                    338: 
                    339: 
                    340: Definition list:(H3,?HR,?(level1:*)+,?(H4,?(level2:*)+,((H5|H6),(level3:*)+)+)+)+;
                    341:        {
                    342:        H3 > DL:DT;
                    343:        level1>DL.DD:*;
                    344:        H4 > DL.DD:DL.DT ;
                    345:        level2 > DL.DD.DL.DD:*;
                    346:        H5 > DL.DD.DL.DD:DL.DT ;
                    347:        H6 > DL.DD.DL.DD:DL.DT ;
                    348:        level3 > DL.DD.DL.DD.DL.DD:*;
                    349:        }
                    350: 
                    351: Multi level Definition list:(H4,?HR,?(level1:*)+,(H5,?(level2:*)+,((H6)+,(level3:*)+)+)+)+;
                    352:        {
                    353:        H4 > DL:DT;
                    354:        level1>DL.DD:*;
                    355:        H5 > DL.DD:DL.DT ;
                    356:        level2 > DL.DD.DL.DD:*;
                    357:        H6 > DL.DD.DL.DD:DL.DT ;
                    358:        level3 > DL.DD.DL.DD.DL.DD:*;
                    359:        }
                    360: 
                    361: 
1.8       cvs       362: 
1.1       cvs       363: Headings H1:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
                    364:        {
                    365:        dt1 > :H1;
                    366:        dt2 > :H2;
                    367:        dt3 > :H3;
                    368:        content > :*;
                    369:        }
                    370: 
                    371: Headings H2:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
                    372:        {
                    373:        dt1 > :H2;
                    374:        dt2 > :H3;
                    375:        dt3 > :H4;
                    376:        content > :*;
                    377:        }
                    378: 
                    379: 
                    380: Headings H3:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
                    381:        {
                    382:        dt1 > :H3;
                    383:        dt2 > :H4;
                    384:        dt3 > :H5;
                    385:        content > :*;
                    386:        }
                    387: 
1.8       cvs       388: Definition list: P,*+;
1.1       cvs       389:        {
1.8       cvs       390:        P > DL:DT;
                    391:        * > DL.DD:*;
1.1       cvs       392:        }
                    393: 
                    394: Remove Div: (DIV{*+})+;
                    395:        {
1.3       cvs       396:         * > :*;
                    397:        }
                    398: 
1.14      cvs       399: Remove Center: (CENTER{*+})+;
                    400:        {
                    401:         * > :*;
                    402:        }
                    403: 
1.3       cvs       404: Remove P level: P{IMG};
                    405:        {
                    406:         IMG > :*;
1.1       cvs       407:        }
                    408: 
                    409: Remove BlockQuote: (BLOCKQUOTE{*+})+;
                    410:        {
                    411:        * > :*;
                    412:        }
                    413: 
                    414: Remove tag FONT: FONT{*+};
                    415:        {
                    416:        * > :*;
                    417:        }
1.4       cvs       418: 
1.9       cvs       419: Remove SPAN: SPAN{*+};
                    420:        {
                    421:        *>:*;
                    422:        }
1.13      cvs       423: 
                    424: Remove Subscript: SUB{*+};
                    425:        {
                    426:        * > :*;
                    427:        }
1.9       cvs       428:        
1.13      cvs       429: Remove Superscript: SUP{*+};
                    430:        {
                    431:        * > :*;
                    432:        }
                    433:        
                    434: Remove Quotation: Q{*+};
                    435:        {
                    436:         * > :*;
                    437:        }
                    438: 
                    439: Remove BiDi: BDO{*+};
                    440:        {
                    441:         * > :*;
                    442:        }
                    443: 
1.9       cvs       444: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    445: ! Global Document transformation tests !
                    446: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    447: 
                    448: DistrThot: BODY{*+}
                    449:        {
                    450:        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">;
                    451:        BODY > TABLE.TBODY.TR.TD:<A href = "http://opera.inrialpes.fr">.<IMG src="opera.gif" alt="Opera project" border=0 align="middle">;
                    452:        BODY > TABLE.TBODY.TR:TD.<IMG src="guide.gif" alt="Documentation" border=0 align="middle">;
                    453:        BODY > TABLE.TBODY.TR.TD:H1."Title of the page";
                    454:        BODY > :<TABLE border=0 with="100%">.TBODY.TR.<TD with="30%">.H2.<A href="Index.html">."Home";
                    455:        * > TABLE.TBODY.TR:TD.*;
                    456:        }
1.10      cvs       457: 

Webmaster