Customizing the output of w2x

Customizing the XHTML+CSS files generated by w2x

Using a XED script to modify the styles embedded in the XHTML+CSS file

By default, w2x adds a number of CSS rules to the /html/head/style element of the generated XHTML+CSS file. Example: excerpts from w2x_install_dir/doc/manual/manual.html:

<style type="text/css">
body {
    counter-reset: n-1-0 0 n-1-1 0 n-1-2 0 n-17-0 0 n-20-0 0;
    font-family: Calibri;
    font-size: 11pt;
}
...
</style>

A XED script allows to modify, not only the nodes of an XHTML document, but also its “CSS styles”. These “CSS styles” may be either style properties contained in the style attribute of an element or class names found in the class attribute of an element or the CSS rules of the document.

Therefore, when the desired customization is limited, suffice to execute a XED script in order to modify the XHTML+CSS document created by the Convert step. Example:

w2x -pu edit.before.finish-styles customize\patch_manual.xed¬
 manual.docx out\manual.html

where w2x_install_dir/doc/manual/customize/patch_manual.xed contains:

set-rule(".p-ProgramListing", "white-space", "pre");

The above line adds CSS property “white-space: pre;” to the CSS rule having “.p-ProgramListing” as its selector. This CSS rule corresponds to custom paragraph[6] style called “ProgramListing”.

Besides XED command set-rule, the following commands allow to edit the CSS styles contained in the XHTML+CSS document created by the Convert step: add-class, add-rule, remove-class, remove-rule, set-style.


[6]It’s a paragraph style because the CSS style name has a “p-“ prefix.