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

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: 
1.20    ! cvs        75: Definition list:*{(LI{(list:*{(li2:LI)+}|other:*)+})+};
1.1       cvs        76:        {
1.20    ! cvs        77:        other > DL:DT;
1.1       cvs        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.20    ! cvs        94: Remove DL: (DL{(DT{(dtc:*)+}|DD{(ddc:*)+})+})+;
1.1       cvs        95:        {
1.20    ! cvs        96:         dtc > :<* style="font-weight:bold">;
        !            97:         ddc > :*;
1.1       cvs        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: 
1.20    ! cvs       119: !Preformatted: P+;
        !           120: !      {
        !           121: !      P>:PRE;
        !           122: !      }
1.1       cvs       123: 
1.20    ! cvs       124: !Paragraph: PRE+;
        !           125: !      {
        !           126: !      PRE>:P;
        !           127: !      }
1.1       cvs       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:        }
1.20    ! cvs       169: Definition List:TABLE{?CAPTION,(block:*{(TR{(TD|TH),?(TD2:TD|TH2:TH)+})+})+};
        !           170:         {
        !           171:         CAPTION > :DL.DT;
        !           172:         block   > :DL;
        !           173:         TD      > DL:DT;
        !           174:         TH      > DL:DT;
        !           175:         TD2     > DL:DD;
        !           176:         TH2     > DL:DD;
        !           177:         }
1.1       cvs       178: 
                    179: ! List transformations
                    180: !!!!!!!!!!!!!!!!!!!!!!
                    181: 
                    182: Remove one level: *{(LI{(cont:*)+})+};
                    183:        {
                    184:        cont > :*;
                    185:        }
                    186: 
                    187: Remove two levels: *{(LI{(*{?(LI{(Lev2:*)+})+})+})+};
                    188:        {
                    189:        Lev2 > :*;
                    190:        }
                    191: 
                    192: Merge Items: LI,(LI2:LI)+;
                    193:        {
                    194:        LI > LI:;
                    195:        LI2 > LI:;
                    196:        }
                    197: 
                    198: Split Items: (LI{a:*,(b:*)+})+;
                    199:        {
                    200:        a > :LI.*;
                    201:        b > :LI.*;
                    202:        }
                    203: 
                    204: Merge Lists: UL{LI+},(UL{LI+})+;
                    205:        {
                    206:        LI > UL:LI;
                    207:        }
                    208: 
                    209: Merge Lists: OL{LI+},(OL{LI+})+;
                    210:        {
                    211:        LI > OL:LI;
                    212:        }
                    213: 
                    214: Merge Lists: DL{(DT|DD)+},(DL{(DT|DD)+})+;
                    215:        {
                    216:        DT > DL:DT;
                    217:        DD > DL:DD;
                    218:        }
                    219: 
                    220: ! Forms to/from elements
                    221: !!!!!!!!!!!!!!!!!!!!!!!!
                    222: 
                    223: Form: *+;
                    224:        {
                    225:        *>Form:*;
                    226:        }
                    227: 
                    228: Remove Form: FORM{*+};
                    229:        {
                    230:        *>:*;
                    231:        }
                    232: 
1.16      cvs       233: Remove submenu: (OPTGROUP{*+})+;
                    234:        {
                    235:         * > :*;
                    236:        }
                    237: 
1.1       cvs       238: ! Lists to/from elements
                    239: !!!!!!!!!!!!!!!!!!!!!!!!
                    240: 
1.9       cvs       241: Bulleted list: (P|OL|MENU|DIR|PRE|FORM)+;
1.1       cvs       242:        {
1.9       cvs       243:         P > UL:LI;
                    244:         OL> UL;
1.1       cvs       245:         MENU> UL:LI.MENU;
                    246:         DIR> UL:LI.DIR;
                    247:         PRE> UL:LI.PRE;
                    248:         FORM> UL:LI.FORM;
                    249:         }
                    250: 
1.9       cvs       251: Numbered list:(P|UL|MENU|DIR|PRE|FORM)+;
1.1       cvs       252:           {
1.9       cvs       253:         P > OL:LI;
                    254:         UL> OL;
1.1       cvs       255:         MENU> OL:LI.MENU;
                    256:         DIR> OL:LI.DIR;
                    257:         PRE> OL:LI.PRE;
                    258:         FORM> OL:LI.FORM;
                    259:         }
                    260: 
                    261: ! Tables to/from elements
                    262: !!!!!!!!!!!!!!!!!!!!!!!!!
                    263: 
                    264: !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|*)+;
                    265: !      {
                    266: !      P> <TABLE border=1>.TR.TD:P;
                    267: !      H> <TABLE border=1>:TR.TD.*;
                    268: !      *> <TABLE border=1>.TR:TD.*;
                    269: !      }
                    270: 
                    271: 
1.15      cvs       272: Vertical Table: *+;
1.1       cvs       273:        {
                    274:        *><TABLE border=1>:TR.TD.*;
                    275:        }
                    276: 
1.15      cvs       277: Horizontal Table : *+;
1.1       cvs       278:        {
                    279:        *><TABLE border=1>.TR:TD.*;
                    280:        }
                    281: 
1.11      cvs       282: Remove Table:TABLE{?CAPTION,?(body:*{(TR{(*{(?cell_content:*)+})+})+})+};
1.1       cvs       283:        {
                    284:        CAPTION>H3;
                    285:        cell_content>:*;
                    286:        }
                    287: 
1.11      cvs       288: Transpose Table:TABLE{TBODY{TR{(TD|TH)+}|(TR{td2:TD|th2:TH})+}};
1.1       cvs       289:        {
1.11      cvs       290:        TD><TABLE BORDER=TABLE.BORDER>:TR.TD;
                    291:        TH>TABLE:TR.TD;
                    292:        td2><TABLE BORDER=TABLE.BORDER>.TR:TD;
                    293:        th2>TABLE.TR:TD;
1.1       cvs       294:        }
                    295: 
1.11      cvs       296: Heading Cell :?(TD|TH)+,TD,?(TD|TH)+;
                    297:        {
                    298:        TD>:TH;
                    299:        }
                    300: 
                    301: Data Cell :?(TD|TH)+,TH,?(TD|TH)+;
                    302:        {
                    303:        TH>:TD;
                    304:        }
1.1       cvs       305: 
                    306: !headings to/from definitions
                    307: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    308: 
1.9       cvs       309: Definition list:((H1|H2|H3|H4|H5|H6),*+)+;
                    310:        {
                    311:        H1 > DL:DT;
                    312:        H2 > DL:DT;
                    313:        H2 > DL:DT;
                    314:        H3 > DL:DT;
                    315:        H4 > DL:DT;
                    316:        H5 > DL:DT;
                    317:        H6 > DL:DT;
                    318:        * > DL.DD:*;
                    319:        }
                    320: 
                    321: 
1.1       cvs       322: Definition list:(H1,?HR,?(level1:*)+,?(H2,?(level2:*)+,?((H3|H4|H5|H6),(level3:*)+)+)+)+;
                    323:        {
                    324:        H1 > DL:DT;
                    325:        level1>DL.DD:*;
                    326:        H2 > DL.DD:DL.DT ;
                    327:        level2 > DL.DD.DL.DD:*;
                    328:        H3 > DL.DD.DL.DD:DL.DT ;
                    329:        H4 > DL.DD.DL.DD:DL.DT ;
                    330:        H5 > DL.DD.DL.DD:DL.DT ;
                    331:        H6 > DL.DD.DL.DD:DL.DT ;
                    332:        level3 > DL.DD.DL.DD.DL.DD:*;
                    333:        }
                    334: 
                    335: Definition list:(H2,?HR,?(level1:*)+,(H3,?(level2:*)+,((H4|H5|H6),(level3:*)+)+)+)+;
                    336:        {
                    337:        H2 > DL:DT;
                    338:        level1>DL.DD:*;
                    339:        H3 > DL.DD:DL.DT ;
                    340:        level2 > DL.DD.DL.DD:*;
                    341:        H4 > DL.DD.DL.DD:DL.DT ;
                    342:        H5 > DL.DD.DL.DD:DL.DT ;
                    343:        H6 > DL.DD.DL.DD:DL.DT ;
                    344:        level3 > DL.DD.DL.DD.DL.DD:*;
                    345:        }
                    346: 
                    347: 
                    348: 
                    349: Definition list:(H3,?HR,?(level1:*)+,?(H4,?(level2:*)+,((H5|H6),(level3:*)+)+)+)+;
                    350:        {
                    351:        H3 > DL:DT;
                    352:        level1>DL.DD:*;
                    353:        H4 > DL.DD:DL.DT ;
                    354:        level2 > DL.DD.DL.DD:*;
                    355:        H5 > DL.DD.DL.DD:DL.DT ;
                    356:        H6 > DL.DD.DL.DD:DL.DT ;
                    357:        level3 > DL.DD.DL.DD.DL.DD:*;
                    358:        }
                    359: 
                    360: Multi level Definition list:(H4,?HR,?(level1:*)+,(H5,?(level2:*)+,((H6)+,(level3:*)+)+)+)+;
                    361:        {
                    362:        H4 > DL:DT;
                    363:        level1>DL.DD:*;
                    364:        H5 > DL.DD:DL.DT ;
                    365:        level2 > DL.DD.DL.DD:*;
                    366:        H6 > DL.DD.DL.DD:DL.DT ;
                    367:        level3 > DL.DD.DL.DD.DL.DD:*;
                    368:        }
                    369: 
                    370: 
1.8       cvs       371: 
1.1       cvs       372: Headings H1:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
                    373:        {
                    374:        dt1 > :H1;
                    375:        dt2 > :H2;
                    376:        dt3 > :H3;
                    377:        content > :*;
                    378:        }
                    379: 
                    380: Headings H2:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
                    381:        {
                    382:        dt1 > :H2;
                    383:        dt2 > :H3;
                    384:        dt3 > :H4;
                    385:        content > :*;
                    386:        }
                    387: 
                    388: 
                    389: Headings H3:(DL{(dt1:DT|DD{(DL{(dt2:DT|DD{(DL{(dt3:DT|DD{content:*})+}|content:*)+})+}|content:*)+})+}|HR)+;
                    390:        {
                    391:        dt1 > :H3;
                    392:        dt2 > :H4;
                    393:        dt3 > :H5;
                    394:        content > :*;
                    395:        }
                    396: 
1.8       cvs       397: Definition list: P,*+;
1.1       cvs       398:        {
1.8       cvs       399:        P > DL:DT;
                    400:        * > DL.DD:*;
1.1       cvs       401:        }
                    402: 
                    403: Remove Div: (DIV{*+})+;
                    404:        {
1.3       cvs       405:         * > :*;
                    406:        }
                    407: 
1.14      cvs       408: Remove Center: (CENTER{*+})+;
                    409:        {
                    410:         * > :*;
                    411:        }
                    412: 
1.3       cvs       413: Remove P level: P{IMG};
                    414:        {
                    415:         IMG > :*;
1.20    ! cvs       416:        }
        !           417: 
        !           418: Remove P level: P{*+};
        !           419:        {
        !           420:         * > :*;
1.1       cvs       421:        }
                    422: 
1.19      cvs       423: Remove BlockQuote: BLOCKQUOTE{*+};
1.1       cvs       424:        {
                    425:        * > :*;
                    426:        }
                    427: 
1.19      cvs       428: Remove FONT: FONT{*+};
1.1       cvs       429:        {
                    430:        * > :*;
                    431:        }
1.4       cvs       432: 
1.9       cvs       433: Remove SPAN: SPAN{*+};
                    434:        {
                    435:        *>:*;
                    436:        }
1.13      cvs       437: 
                    438: Remove Subscript: SUB{*+};
                    439:        {
                    440:        * > :*;
                    441:        }
1.9       cvs       442:        
1.13      cvs       443: Remove Superscript: SUP{*+};
                    444:        {
                    445:        * > :*;
                    446:        }
                    447:        
                    448: Remove Quotation: Q{*+};
                    449:        {
                    450:         * > :*;
                    451:        }
                    452: 
                    453: Remove BiDi: BDO{*+};
                    454:        {
                    455:         * > :*;
                    456:        }
                    457: 
1.9       cvs       458: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    459: ! Global Document transformation tests !
                    460: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    461: 
                    462: DistrThot: BODY{*+}
                    463:        {
                    464:        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">;
                    465:        BODY > TABLE.TBODY.TR.TD:<A href = "http://opera.inrialpes.fr">.<IMG src="opera.gif" alt="Opera project" border=0 align="middle">;
                    466:        BODY > TABLE.TBODY.TR:TD.<IMG src="guide.gif" alt="Documentation" border=0 align="middle">;
                    467:        BODY > TABLE.TBODY.TR.TD:H1."Title of the page";
                    468:        BODY > :<TABLE border=0 with="100%">.TBODY.TR.<TD with="30%">.H2.<A href="Index.html">."Home";
                    469:        * > TABLE.TBODY.TR:TD.*;
                    470:        }
1.10      cvs       471: 

Webmaster