! Use of the file HTML.trans !!!!!!!!!!!!!!!!!!!!!!!!!!!! ! This file can be edited during an Amaya session. It will be ! dynamically parsed when the transformation tool is required by ! the editor. So new transformations can be added while editing. ! ! Syntax of the transformation language for Amaya !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! comments begin with ! ! ! This file can be edited during an Amaya session. It will be ! dynamically parsed when the transformation tool is required by ! the editor. So new transformations can be added while editing. ! ! A tranformation rule has three parts : ! - a NAME terminated by a colon ":" ! - a SOURCE PATTERN terminated by a semi-colon ";" ! - and a list of RULES between braces "{" "}", each one ! terminated by a semi-colon ";" ! ! a) The NAME will appear in the transform menu. ! ! b) The SOURCE PATTERN gives of a specific organization of the elements ! to be transformed: it contains XML/HTML tags and SGML-like syntax ! for the composition operators: ! e1 | e2 for a choice between elements e1 and e2 ! e1 , e2 for a sequence e1 followed by e2 ! e+ for a sequence of one or more elements e ! ?e for an optional element e ! ( ) for grouping nodes ! The braces "{" "}" define the content of a node. ! The symbol "*" is a token that matches any element type ! It is possible to rename a tag by preceeding it with a name ! followed by a colon ":" ! ! c) RULES express transformations to be applied to the elements ! identified in the pattern. ! Each rule end with a symbol ";" ! ! - It could be performed by an action rule. In this case the rule ! starts with a "$" followed by the menu action to be called. ! ! - It could be a list of transformation items: ! They have two parts : ! - a source identifier: a tag or a name which occurs in ! the pattern and links the rule to the pattern nodes ! - a rule body: drives the transformation ! there are two kinds of rule bodies: ! - a discard rule body is slash and express that the correspoding ! pattern node does not occuring the transformation result ! - a generation rule begins with ! - a symbol ">" ! - and a target tag list. This list is itself divided into ! two parts separated by a colon":": ! * the generation location path ! * and the list of tags to be generated ! The dot symbol "." is used for descending in the tree structure. ! if the special token star "*" ends the list of tags to be ! generated, the source elment tag is not changed but this element ! can be moved in a different place in the destination. ! ! The rules are applied in the order the identifiers are met when ! (depth first) traversing the source structure. ! Several rules may have the same identifier, in that case, the rules ! are applied in the order they are defined. ! Transformation rules !!!!!!!!!!!!!!!!!!!!!! Address:(p{*+})+; { * > address:*; } Paragraph:(address{*+}); { * > p:*; } !between lists !!!!!!!!!!!!!! Definition list:*{(li{(list:*{(li{li2:(*)+})+}|other:*)+})+}; { li2 > dl:dd.*; other > dl:dt; } Bulleted list:(dl{(dt|dd{(*)+})+})+; { dt > ul:li; * > ul.li.ul:li.*; } Numbered list:(dl{(dt|dd{(*)+})+})+; { dt > ol:li; * > ol.li.ol:li.*; } Bulleted list:(ol{(li{(*)+})+})+; { * > ul:li.*; } Numbered list:(ul{(li{(*)+})+})+; { * > ol:li.*; } Definition data:dt{(*)+}; { * > dd:*; } Definition term:dd{(p|*)+}; { dd > :dt; p > :dt; * > dt:*; } Remove definition list:(dl{(dt{(dtc:*)+}|dd{(p|*)+})+})+; { dtc > h4:*; p > p; * > p:*; } !flattering headings !!!!!!!!!!!!!!!!!!!! Paragraphs: (h1|h2|h3|h4|h5|h6|p|*{(li{(il:*)+})+})+; { h1 > :p; h2 > :p; h3 > :p; h4 > :p; h5 > :p; h6 > :p; p > :p; il > :p; } !headings to/from definitions !!!!!!!!!!!!!!!!!!!!!!!!!!!!! Definition list:*,(h1|h2|h3|h4|h5|h6|p)+; { * > dl:dt; h1 > dl:dt; h2 > dl:dt; h2 > dl:dt; h3 > dl:dt; h4 > dl:dt; h5 > dl:dt; h6 > dl:dt; p > dl:dd; } Definition list:(h1,?hr,?(level1:*)+,?(h2,?(level2:*)+,?((h3|h4|h5|h6),(level3:*)+)+)+)+; { h1 > dl:dt; level1>dl.dd:*; h2 > dl.dd:dl.dt ; level2 > dl.dd.dl.dd:*; h3 > dl.dd.dl.dd:dl.dt ; h4 > dl.dd.dl.dd:dl.dt ; h5 > dl.dd.dl.dd:dl.dt ; h6 > dl.dd.dl.dd:dl.dt ; level3 > dl.dd.dl.dd.dl.dd:*; } Definition list:(h2,?hr,?(level1:*)+,(h3,?(level2:*)+,((h4|h5|h6),(level3:*)+)+)+)+; { h2 > dl:dt; level1 > dl.dd:*; h3 > dl.dd:dl.dt ; level2 > dl.dd.dl.dd:*; h4 > dl.dd.dl.dd:dl.dt ; h5 > dl.dd.dl.dd:dl.dt ; h6 > dl.dd.dl.dd:dl.dt ; level3 > dl.dd.dl.dd.dl.dd:*; } Definition list:(h3,?hr,?(level1:*)+,?(h4,?(level2:*)+,((h5|h6),(level3:*)+)+)+)+; { h3 > dl:dt; level1 > dl.dd:*; h4 > dl.dd:dl.dt ; level2 > dl.dd.dl.dd:*; h5 > dl.dd.dl.dd:dl.dt ; h6 > dl.dd.dl.dd:dl.dt ; level3 > dl.dd.dl.dd.dl.dd:*; } Multi-level definition list:(h4,?hr,?(level1:*)+,(h5,?(level2:*)+,((h6)+,(level3:*)+)+)+)+; { h4 > dl:dt; level1 > dl.dd:*; h5 > dl.dd:dl.dt ; level2 > dl.dd.dl.dd:*; h6 > dl.dd.dl.dd:dl.dt ; level3 > dl.dd.dl.dd.dl.dd:*; } Headings h1:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+; { dt1 > :h1; dt2 > :h2; dt3 > :h3; content > :*; } Headings h2:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+; { dt1 > :h2; dt2 > :h3; dt3 > :h4; content > :*; } Headings h3:(dl{(dt1:dt|dd{(dl{(dt2:dt|dd{(dl{(dt3:dt|dd{content:*})+}|content:*)+})+}|content:*)+})+}|hr)+; { dt1 > :h3; dt2 > :h4; dt3 > :h5; content > :*; } ! Preformatted to/from paragraphs !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Preformatted: (p{*+})+; { * > pre:*; } Paragraph: (pre{*+})+; { * > p:*; } Merge items: li,(li2:li)+; { li > li:; li2 > li:; } Remove the paragraph level: li{p{(cont:*)+},?(next:*)+}; { li > li:; cont > *; next > *; } Remove the Underline: (u{*+})+; { * > :*; } Split items: (li{a:*,(b:*)+})+; { a > :li.*; b > :li.*; } Merge lists: ul{li+},(ul{li+})+; { li > ul:li; } Merge lists: ol{li+},(ol{li+})+; { li > ol:li; } Merge lists: dl{(dt|dd)+},(dl{(dt|dd)+})+; { dt > dl:dt; dd > dl:dd; } !Paragraph: *{(li{(cont:*)+})+}; ! { ! cont > :*; ! } Paragraph: *{(li{(*{?(li{(lev2:*)+})+})+})+}; { lev2 > :*; } Paragraphs: (ol{(li{(h1|h2|h3|h4|h5|h6|p|*)+})+})+; { h1 > :h1; h2 > :h2; h3 > :h3; h4 > :h4; h5 > :h5; h6 > :h6; p > :p; * > :p.*; } Paragraphs: (ul{(li{(h1|h2|h3|h4|h5|h6|p|*)+})+})+; { h1 > :h1; h2 > :h2; h3 > :h3; h4 > :h4; h5 > :h5; h6 > :h6; p > :p; * > :p.*; } Remove two list levels: *{(li{(*{?(li{(lev2:*)+})+})+})+}; { lev2 > :*; } ! Forms to/from elements !!!!!!!!!!!!!!!!!!!!!!!! Enclosing into Form: (h1|h2|h3|h4|h5|h6|p)+; { h1 > form:h1; h2 > form:h2; h3 > form:h3; h4 > form:h4; h5 > form:h5; h6 > form:h6; p > form:p; } Remove the Form: form{?*+}; { * > :*; } Remove the submenu: (optgroup{*+})+; { * > :*; } ! Lists to/from elements !!!!!!!!!!!!!!!!!!!!!!!! Bulleted list: (p|ol|menu|dir|pre|form)+; { p >