Convert::Wiki - Convert HTML/POD/txt from/to Wiki code
use Convert::Wiki; my $wiki = Convert::Wiki->new(); $wiki->from_txt ( $txt ); die ("Error: " . $wiki->error()) if $wiki->error; print $wiki->as_wiki(); $wiki->from_html ( $html ); die ("Error: " . $wiki->error()) if $wiki->error; print $wiki->as_wiki(); # clear the object manually $wiki->clear(); $wiki->add_txt ( $txt ); die ("Error: " . $wiki->error()) if $wiki->error; print $wiki->as_wiki();
Convert::Wiki converts from various formats to various Wiki formats.
Convert::Wiki
Input can come as HTML, POD or plain TXT (like it is written in many READMEs). The data will be converted to an internal, node based format and can then be converted to Wikicode as used by many wikis like the Wikipedia.
$cvt = Convert::Wiki->new();
Creates a new conversion object. It takes an optional list of options. The following are valid:
debug if set, will enable some debug outputs interlink a list of phrases, that if found in a paragraph, are turned into links (into the same Wiki)
The phrases in interlink are searched case-sensitive, and if the found phrase differs from the searched one, a piped link will be generated. In addition, you can give a different link target and link name by separating them with | :
|
Foo # turn "foo" into "[[Foo|foo]]", "Foo" into [Foo] etc Foobar|foo # find "foo", "Foo" etc. and makes them [[Foobar|foo]]
$cvt->as_wiki();
Returns the internally stored contents in wiki code.
$cvt->clear();
Clears the conversion object by resetting the last error and throwing away all internally stored nodes. There is usually no need to do this manually, except if you want to reuse a conversion object with the add methods.
add
$debugmode = $cvt->debug(); # true or false
Returns true if the debug mode is enabled.
$last_error = $cvt->error(); $cvt->error($error); # set new messags $cvt->error(''); # clear error
Returns the last error message, or '' for no error.
$cvt->from_txt();
Clears the object via clear() and then converts the given text to the internal format.
print "Nodes: ", $cvt->nodes(), "\n";
Returns the number of nodes the current document consists of. A fresh Convert::Wiki object has zero, and after you =head2 EXPORT
None by default.
http://en.wikipedia.org/, Pod::Simple::Wiki.
Tels http://bloodgate.com
Copyright (C) 2004 by Tels
This library is free software; you can redistribute it and/or modify it under the terms of the GPL. See the LICENSE file for more details.
To install Convert::Wiki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Convert::Wiki
CPAN shell
perl -MCPAN -e shell install Convert::Wiki
For more information on module installation, please visit the detailed CPAN module installation guide.