internal package Foswiki::Plugins::WysiwygPlugin::TML2HTML

See PublishedAPI for packages intended to be used by Plugin and Contrib authors, or browse all packages.
See also Developing plugins, Developer's Bible, Technical Overview

internal package Foswiki::Plugins::WysiwygPlugin::TML2HTML

Convertor class for translating TML (Topic Meta Language) into HTML

The convertor does not use the Foswiki rendering, as that is a lossy conversion, and would make symmetric translation back to TML an impossibility.

The design goal was to support round-trip conversion from well-formed TML to XHTML1.0 and back to identical TML. Notes that some deprecated TML syntax is not supported.

ClassMethod new()

Construct a new TML to HTML convertor.

ObjectMethod convert( $tml, \%options ) → $tml

Convert a block of TML text into HTML. Options:
  • \&expandVarsInURL is a reference to a static function:
    expandVarsInURL($url, \%options) -> $url
    that expands selected variables in URLs so that, for example, tags appear as pictures in the wysiwyg editor.
  • \&isKnownColour - pointer to a function that will determine if the parameter maps to a known HTML colour e.g. BLACK -> black and return the colour name if it does, or undef otherwise.
  • \%xmltag is a reference to a hash. The keys are names of XML-like tags. The values are references to a function to determine if the content of the tag must be protected:
    fn($markup) -> $bool
    The $markup appears between the delimiters. The functions may modify the markup.
  • dieonerror makes convert throw an exception if a conversion fails. The default behaviour is to encode the whole topic as verbatim text.
  • \@keeptags - gives an array of HTML tag names that are to have the TMLhtml class added, to protect them during subsequent HTML2TML conversion.
  • \@keepblocks - gives an array of (lowercase) tag names of HTML block tags that are to be protected. Default is [ 'script', 'style' ]
  • forcenoautolink can be set to a true value to apply NOAUTOLINK across the entire conversion.

Topic revision: r1 - 21 Nov 2014, ProjectContributor
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding WikiCMC? Send feedback