Creating Web Pages

SnuggleTeX tries to make it easy to create web pages suitable for use on various browser platforms, creating XHTML+MathML web pages by default. It can also generate Legacy Web Pages via the optional JEuclid extension.

Usage Recipe

  1. You must first decide what kind of web page you would like to generate. These are listed in the XHTML+MathML Web Page Types page. (You might prefer to create a Legacy Web Page.)
  2. Pass your selected WebPageType to WebPageOutputOptionsTemplate.createWebPageOptions(). This will create a WebPageOutputOptions Object configured with suitable defaults for the type of web page you want to create.
  3. You can now tweak your newly-created WebPageOutputOptions Object to control the following aspects of the output:
    • Set a language, encoding and title for the resulting page;
    • Specify client-side XSLT stylesheets to include via <?xml-stylesheet?>;
    • Specify client-side CSS stylesheets to attach via <link/>;
    • Whether to inline the SnuggleTeX’s CSS styles as a <style/> section or leave you to link to it yourself.
    • Whether to add an automatic title heading element to the web page body;
    • Whether to indent the output;
    • Whether to apply your own XSLT Stylesheets (passed as JAXP Transformer Objects) to the resulting page before it is serialized. (This is useful if you want to add in custom headers and footers or otherwise soup up the outputs you get.)
    • …plus the same options as for generating XML/DOM Outputs.
  4. Finally, you pass your WebPageOutputOptions Object to either snuggleSession.createWebPage() or snuggleSession.writePageWeb() methods to generate one of the following outputs:
    • The snuggleSession.createWebPage() methods return a DOM Document representing a web page rendition of your input. You can then serialize this or perform further transforms/manipulations as required.
    • The snuggleSession.writeWebPage() methods create and write out a web page rendition of your input to the given OutputStream.

Example Code

Have a look at WebPageExample.java  for a simple self-contained example.