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 : 1.30 ! vatton 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 ";" 1.1 cvs 21: ! 1.30 ! vatton 22: ! a) The NAME will appear in the transform menu. 1.1 cvs 23: ! 1.30 ! vatton 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 1.1 cvs 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: ! 1.30 ! vatton 37: ! c) RULES express transformations to be applied to the elements ! 38: ! identified in the pattern. ! 39: ! Each rule end with a symbol ";" 1.10 cvs 40: ! 1.30 ! vatton 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. 1.10 cvs 43: ! 1.30 ! vatton 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. 1.10 cvs 62: ! 1.30 ! vatton 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. 1.1 cvs 67: 68: ! Transformation rules 69: !!!!!!!!!!!!!!!!!!!!!! 70: 1.26 cvs 71: Address:(p{*+})+; 1.9 cvs 72: { 1.26 cvs 73: * > address:*; 1.9 cvs 74: } 75: 1.1 cvs 76: !between lists 77: !!!!!!!!!!!!!! 78: 1.26 cvs 79: Definition list:*{(li{(list:*{(li2:li)+}|other:*)+})+}; 1.1 cvs 80: { 1.26 cvs 81: other > dl:dt; 82: list > dl:dd; 83: li2 > dl.dd:; 1.1 cvs 84: } 85: 1.26 cvs 86: Bulleted list:(dl{(dt|dd{(*)+})+})+; 1.1 cvs 87: { 1.26 cvs 88: dt > ul:li; 89: * > ul.li.ul:li.*; 1.1 cvs 90: } 91: 1.26 cvs 92: Numbered list:(dl{(dt|dd{(*)+})+})+; 1.1 cvs 93: { 1.26 cvs 94: dt > ol:li; 95: * > ol.li.ol:li.*; 1.1 cvs 96: } 97: 1.29 cvs 98: Bulleted list:(ol{(li{(*)+})+})+; 99: { 100: * > ul:li.*; 101: } 102: 103: Numbered list:(ul{(li{(*)+})+})+; 104: { 105: * > ol:li.*; 106: } 107: 1.26 cvs 108: Remove dl: (dl{(dt{(dtc:*)+}|dd{(ddc:*)+})+})+; 1.1 cvs 109: { 1.20 cvs 110: dtc > :<* style="font-weight:bold">; 111: ddc > :*; 1.1 cvs 112: } 113: 114: !flattering headings 115: !!!!!!!!!!!!!!!!!!!! 116: 117: Paragraphs: 1.26 cvs 118: (h1|h2|h3|h4|h5|h6|*{(li{(il:*)+})+}),(h1|h2|h3|h4|h5|h6|p|*{(li{(il:*)+})+})+; 1.1 cvs 119: { 1.26 cvs 120: h1 > :p; 121: h2 > :p; 122: h3 > :p; 123: h4 > :p; 124: h5 > :p; 125: h6 > :p; 126: p > :p; 127: il > :p; 1.1 cvs 128: } 129: 130: ! Preformatted to/from paragraphs 131: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 132: 1.26 cvs 133: !Preformatted: p+; 1.20 cvs 134: ! { 1.26 cvs 135: ! p>:pre; 1.20 cvs 136: ! } 1.1 cvs 137: 1.26 cvs 138: !Paragraph: pre+; 1.20 cvs 139: ! { 1.26 cvs 140: ! pre>:p; 1.20 cvs 141: ! } 1.1 cvs 142: 143: 144: !Tables to/from lists 145: !!!!!!!!!!!!!!!!!!!! 146: 1.26 cvs 147: Table: *{(lev1:li{?(*{(lev2:li)+}|elem:*)+})+}; 1.1 cvs 148: { 1.26 cvs 149: lev1 > <table border="1">:tr; 150: elem > table.tr:td.*; 151: lev2 > table.tr:td; 1.1 cvs 152: } 153: 1.26 cvs 154: Table: dl{(dt|dd)+}; 1.1 cvs 155: { 1.26 cvs 156: dt > <table border="1">.tbody:tr.td; 157: dd > table.tbody.tr:td; 1.1 cvs 158: } 159: 1.26 cvs 160: Numbered List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+}; 1.1 cvs 161: { 1.26 cvs 162: caption > :ol.li.strong; 163: block > :ol; 164: tr > ol:li; 165: td > ol.li:; 166: th > ol.li:; 167: td2 >ol.li.ul:li; 168: th2 >ol.li.ul:li; 169: } 170: 171: Bulleted List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+}; 172: { 173: caption > :ul.li.strong; 174: block > :ul; 175: tr > ul:li; 176: td > ul.li:; 177: th > ul.li:; 178: td2 >ul.li.ul:li; 179: th2 >ul.li.ul:li; 1.1 cvs 180: } 1.26 cvs 181: Definition List:table{?caption,(block:*{(tr{(td|th),?(td2:td|th2:th)+})+})+}; 1.20 cvs 182: { 1.26 cvs 183: caption > :dl.dt; 184: block > :dl; 185: td > dl:dt; 186: th > dl:dt; 187: td2 > dl:dd; 188: th2 > dl:dd; 1.20 cvs 189: } 1.1 cvs 190: 191: ! List transformations 192: !!!!!!!!!!!!!!!!!!!!!! 193: 1.26 cvs 194: Remove one level: *{(li{(cont:*)+})+}; 1.1 cvs 195: { 196: cont > :*; 197: } 198: 1.26 cvs 199: Remove two levels: *{(li{(*{?(li{(lev2:*)+})+})+})+}; 1.1 cvs 200: { 1.26 cvs 201: lev2 > :*; 1.1 cvs 202: } 203: 1.26 cvs 204: Merge Items: li,(li2:li)+; 1.1 cvs 205: { 1.26 cvs 206: li > li:; 207: li2 > li:; 1.1 cvs 208: } 1.26 cvs 209: Remove Paragraph level: li{p{(cont:*)+},?(next:*)+}; 1.23 cvs 210: { 1.26 cvs 211: li > li:; 1.23 cvs 212: cont > *; 213: next > *; 214: } 1.28 cvs 215: Remove Underline: (u{*+})+; 216: { 217: * > :*; 218: } 1.1 cvs 219: 1.26 cvs 220: Split Items: (li{a:*,(b:*)+})+; 1.1 cvs 221: { 1.26 cvs 222: a > :li.*; 223: b > :li.*; 1.1 cvs 224: } 225: 1.26 cvs 226: Merge Lists: ul{li+},(ul{li+})+; 1.1 cvs 227: { 1.26 cvs 228: li > ul:li; 1.1 cvs 229: } 230: 1.26 cvs 231: Merge Lists: ol{li+},(ol{li+})+; 1.1 cvs 232: { 1.26 cvs 233: li > ol:li; 1.1 cvs 234: } 235: 1.26 cvs 236: Merge Lists: dl{(dt|dd)+},(dl{(dt|dd)+})+; 1.1 cvs 237: { 1.26 cvs 238: dt > dl:dt; 239: dd > dl:dd; 1.1 cvs 240: } 241: 242: ! Forms to/from elements 243: !!!!!!!!!!!!!!!!!!!!!!!! 244: 245: Form: *+; 246: { 247: *>Form:*; 248: } 249: 1.26 cvs 250: Remove Form: form{*+}; 1.1 cvs 251: { 252: *>:*; 253: } 254: 1.26 cvs 255: Remove submenu: (optgroup{*+})+; 1.16 cvs 256: { 257: * > :*; 258: } 259: 1.1 cvs 260: ! Lists to/from elements 261: !!!!!!!!!!!!!!!!!!!!!!!! 262: 1.26 cvs 263: Bulleted list: (p|ol|menu|dir|pre|form)+; 1.1 cvs 264: { 1.26 cvs 265: p > ul:<li style=p.style>; 266: ol> ul; 267: pre> ul:li.pre; 268: form> ul:li.form; 1.1 cvs 269: } 270: 1.26 cvs 271: Numbered list:(p|ul|menu|dir|pre|form)+; 1.1 cvs 272: { 1.26 cvs 273: p > ol:li; 274: ul> ol; 275: pre> ol:li.pre; 276: form> ol:li.form; 1.1 cvs 277: } 278: 279: ! Tables to/from elements 280: !!!!!!!!!!!!!!!!!!!!!!!!! 281: 1.26 cvs 282: !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|*)+; 1.1 cvs 283: ! { 1.26 cvs 284: ! p> <table border="1">.tr.td:p; 285: ! h> <table border="1">:tr.td.*; 286: ! *> <table border="1">.tr:td.*; 1.1 cvs 287: ! } 288: 289: 1.15 cvs 290: Vertical Table: *+; 1.1 cvs 291: { 1.26 cvs 292: *><table border="1">:tr.td.*; 1.1 cvs 293: } 294: 1.15 cvs 295: Horizontal Table : *+; 1.1 cvs 296: { 1.26 cvs 297: *><table border="1">.tr:td.*; 1.1 cvs 298: } 299: 1.26 cvs 300: Remove Table:table{?caption,?(body:*{(tr{(*{(?cell_content:*)+})+})+})+}; 1.1 cvs 301: { 1.26 cvs 302: caption>h3; 1.1 cvs 303: cell_content>:*; 304: } 305: 1.26 cvs 306: Transpose Table:table{tbody{tr{(td|th)+}|(tr{td2:td|th2:th})+}}; 1.1 cvs 307: { 1.26 cvs 308: td><table border=table.border>:tr.td; 309: th>table:tr.td; 310: td2><table border=table.border>.tr:td; 311: th2>table.tr:td; 1.1 cvs 312: } 313: 1.26 cvs 314: Heading Cell :?(td|th)+,td,?(td|th)+; 1.11 cvs 315: { 1.30 ! vatton 316: $CreateHeadingCell; 1.11 cvs 317: } 318: 1.26 cvs 319: Data Cell :?(td|th)+,th,?(td|th)+; 1.11 cvs 320: { 1.30 ! vatton 321: $CreateDataCell; 1.11 cvs 322: } 1.1 cvs 323: 324: !headings to/from definitions 325: !!!!!!!!!!!!!!!!!!!!!!!!!!!!! 326: 1.26 cvs 327: Definition list:((h1|h2|h3|h4|h5|h6),*+)+; 1.9 cvs 328: { 1.26 cvs 329: h1 > dl:dt; 330: h2 > dl:dt; 331: h2 > dl:dt; 332: h3 > dl:dt; 333: h4 > dl:dt; 334: h5 > dl:dt; 335: h6 > dl:dt; 336: * > dl.dd:*; 1.9 cvs 337: } 338: 1.26 cvs 339: Definition list:(h1,?hr,?(level1:*)+,?(h2,?(level2:*)+,?((h3|h4|h5|h6),(level3:*)+)+)+)+; 1.1 cvs 340: { 1.26 cvs 341: h1 > dl:dt; 342: level1>dl.dd:*; 343: h2 > dl.dd:dl.dt ; 344: level2 > dl.dd.dl.dd:*; 345: h3 > dl.dd.dl.dd:dl.dt ; 346: h4 > dl.dd.dl.dd:dl.dt ; 347: h5 > dl.dd.dl.dd:dl.dt ; 348: h6 > dl.dd.dl.dd:dl.dt ; 349: level3 > dl.dd.dl.dd.dl.dd:*; 1.1 cvs 350: } 351: 1.26 cvs 352: Definition list:(h2,?hr,?(level1:*)+,(h3,?(level2:*)+,((h4|h5|h6),(level3:*)+)+)+)+; 1.1 cvs 353: { 1.26 cvs 354: h2 > dl:dt; 355: level1>dl.dd:*; 356: h3 > dl.dd:dl.dt ; 357: level2 > dl.dd.dl.dd:*; 358: h4 > dl.dd.dl.dd:dl.dt ; 359: h5 > dl.dd.dl.dd:dl.dt ; 360: h6 > dl.dd.dl.dd:dl.dt ; 361: level3 > dl.dd.dl.dd.dl.dd:*; 1.1 cvs 362: } 363: 1.26 cvs 364: Definition list:(h3,?hr,?(level1:*)+,?(h4,?(level2:*)+,((h5|h6),(level3:*)+)+)+)+; 1.1 cvs 365: { 1.26 cvs 366: h3 > dl:dt; 367: level1>dl.dd:*; 368: h4 > dl.dd:dl.dt ; 369: level2 > dl.dd.dl.dd:*; 370: h5 > dl.dd.dl.dd:dl.dt ; 371: h6 > dl.dd.dl.dd:dl.dt ; 372: level3 > dl.dd.dl.dd.dl.dd:*; 1.1 cvs 373: } 374: 1.26 cvs 375: Multi level Definition list:(h4,?hr,?(level1:*)+,(h5,?(level2:*)+,((h6)+,(level3:*)+)+)+)+; 1.1 cvs 376: { 1.26 cvs 377: h4 > dl:dt; 378: level1>dl.dd:*; 379: h5 > dl.dd:dl.dt ; 380: level2 > dl.dd.dl.dd:*; 381: h6 > dl.dd.dl.dd:dl.dt ; 382: level3 > dl.dd.dl.dd.dl.dd:*; 1.1 cvs 383: } 384: 1.26 cvs 385: Headings h1:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+; 1.1 cvs 386: { 1.26 cvs 387: dt1 > :h1; 388: dt2 > :h2; 389: dt3 > :h3; 1.1 cvs 390: content > :*; 391: } 392: 1.26 cvs 393: Headings h2:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+; 1.1 cvs 394: { 1.26 cvs 395: dt1 > :h2; 396: dt2 > :h3; 397: dt3 > :h4; 1.1 cvs 398: content > :*; 399: } 400: 1.26 cvs 401: Headings h3:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+; 1.1 cvs 402: { 1.26 cvs 403: dt1 > :h3; 404: dt2 > :h4; 405: dt3 > :h5; 1.1 cvs 406: content > :*; 407: } 408: 1.26 cvs 409: Definition list: p,*+; 1.1 cvs 410: { 1.26 cvs 411: p > dl:dt; 412: * > dl.dd:*; 1.1 cvs 413: } 414: 1.26 cvs 415: Remove Div: (div{*+})+; 1.1 cvs 416: { 1.3 cvs 417: * > :*; 418: } 419: 1.26 cvs 420: Remove Center: (center{*+})+; 1.14 cvs 421: { 422: * > :*; 423: } 424: 1.26 cvs 425: Remove Paragraph level: p{img}; 1.23 cvs 426: { 1.26 cvs 427: img > :*; 1.23 cvs 428: } 1.1 cvs 429: 1.26 cvs 430: Remove BlockQuote: blockquote{*+}; 1.1 cvs 431: { 432: * > :*; 433: } 434: 1.26 cvs 435: Remove font: font{*+}; 1.1 cvs 436: { 437: * > :*; 438: } 1.4 cvs 439: 1.26 cvs 440: Remove span: span{*+}; 1.9 cvs 441: { 442: *>:*; 443: } 1.13 cvs 444: 1.26 cvs 445: Remove Subscript: sub{*+}; 1.13 cvs 446: { 447: * > :*; 448: } 1.9 cvs 449: 1.26 cvs 450: Remove Superscript: sup{*+}; 1.13 cvs 451: { 452: * > :*; 453: } 454: 1.26 cvs 455: Remove Quotation: q{*+}; 1.13 cvs 456: { 457: * > :*; 458: } 459: 1.26 cvs 460: Remove BiDi: bdo{*+}; 1.13 cvs 461: { 462: * > :*; 463: } 464: 1.9 cvs 465: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 466: ! Global Document transformation tests ! 467: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 468: 1.26 cvs 469: DistrThot: body{*+} 1.9 cvs 470: { 1.26 cvs 471: 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">; 472: body > table.tbody.tr.td:<a href="http://opera.inrialpes.fr">.<img src="opera.gif" alt="Opera project" border="0" align="middle">; 473: body > table.tbody.tr:td.<img src="guide.gif" alt="Documentation" border="0" align="middle">; 474: body > table.tbody.tr.td:h1."Title of the page"; 475: body > :<table border="0" with="100%">.tbody.tr.<td with="30%">.h2.<a href="Index.html">."Home"; 476: * > table.tbody.tr:td.*; 1.9 cvs 477: } 1.10 cvs 478: