- SEE ALSO
- COPYRIGHT AND LICENSE
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.
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]]
Returns the internally stored contents in wiki code.
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
$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.
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.
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.