Text::WikiText - Converting WikiText markup to other formats
use Text::WikiText; print Text::WikiText->new->convert(\*STDIN, format => 'Latex');
or
use Text::WikiText; use Text::WikiText::Output::HTML; my $parser = Text::WikiText->new; my $document = $parser->parse(\*STDIN); my $html = Text::WikiText::Output::HTML->new->dump($document); print $html;
The WikiText markup specification (and its source in WikiText) may be found at:
http://podius.wox.org/documentation/wikitext-spec.html http://podius.wox.org/documentation/wikitext-spec.txt
Text::WikiText provides a parser for the WikiText markup language, and output modules to convert parsed documents into other markup languages, such as HTML, Latex or Pod.
The following methods are available:
new, parse, convert.
Create a new WikiText parser object.
Parse a WikiText document from an IO::Handle or a string variable. The function returns the parsed document as a tree structure as defined below.
Parse and convert a WikiText document. This method uses parse to parse a WikiText document and immediately converts it to the specified output format.
The options parameter is a hash reference specifying the output format and various output options.
Specifies the output format. Valid options are HTML and Latex. Defaults to HTML.
Specifies whether the outputted string should be a full document, or an embeddable document part. This options decides whether the output module should generate document headers and footers. Defaults to 0 (omit document headers and footers).
Specifies the output document title and author. The values are used only when full_page is set. Defaults are undefined.
Specifies an optional offset applied to the level of all headings. An offset of 1 will convert level 1 headings to level 2, level 2 headings to level 3, etc. This option is useful when the output is embedded into other documents. Defaults to 0.
Specifies whether verbatim blocks should be omitted from the output. Verbatim blocks can break the output document structure and thus should only be allowed from trusted sources. Defaults to 0 (include verbatim blocks).
Specifies whether compact lists include additional paragraph elements. Applies to ul, ol, and dl elements. Defaults to 0 (generate additional paragraph elements).
Example:
<!-- normal output --> <ul> <li><p>foo</p></li> <li><p>bar</p></li> </ul> <!-- flat output --> <ul> <li>foo</li> <li>bar</li> </ul>
Note: The document structure might be redefined in the future.
A parsed WikiText document is an anonymous array of WikiText elements. Each element is an anonymous hash with various properties. All elements have at least the field type, used to identify the type of the element.
Four categories of items are defined:
SECTION
Fields: level, heading, content.
QUOTE, LISTING, ENUMERATION, DESCRIPTION.
Fields: content.
TABLE, RULE, P, PRE, CODE, COMMENT, VERBATIM.
Fields: text (all but TABLE and RULE), content (TABLE only).
EMPHASIS, STRONG, UNDERLINE, STRIKE, TYPEWRITER, LINK, TEXT, VERBATIM.
Fields: text.
Sections can contain other sections, environments and paragraphs. Environments can contain other environments and paragraphs. Paragraphs can contain formatting elemens. Formatting elements contain plain text.
Enno Cramer, Mikhael Goikhman
wikitext-convert, Text::WikiText::InputFilter, Text::WikiText::Output.
To install Text::WikiText, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::WikiText
CPAN shell
perl -MCPAN -e shell install Text::WikiText
For more information on module installation, please visit the detailed CPAN module installation guide.