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