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