.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::WikiConverter 3pm" .TH HTML::WikiConverter 3pm "2022-06-14" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" HTML::WikiConverter \- Convert HTML to wiki markup .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use HTML::WikiConverter; \& my $wc = new HTML::WikiConverter( dialect => \*(AqMediaWiki\*(Aq ); \& print $wc\->html2wiki( html => \*(Aqtext\*(Aq ), "\en\en"; \& \& # A more complete example \& \& my $html = qq( \&
Italic, bold, also bold, etc.
\& ); \& \& my @dialects = HTML::WikiConverter\->available_dialects; \& foreach my $dialect ( @dialects ) { \& my $wc = new HTML::WikiConverter( dialect => $dialect ); \& my $wiki = $wc\->html2wiki( html => $html ); \& printf "The %s dialect gives:\en\en%s\en\en", $dialect, $wiki; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`HTML::WikiConverter\*(C'\fR is an \s-1HTML\s0 to wiki converter. It can convert \&\s-1HTML\s0 source into a variety of wiki markups, called wiki \&\*(L"dialects\*(R". The following dialects are supported: .PP .Vb 10 \& DokuWiki \& Kwiki \& MediaWiki \& MoinMoin \& Oddmuse \& PbWiki \& PhpWiki \& PmWiki \& SlipSlap \& TikiWiki \& UseMod \& WakkaWiki \& WikkaWiki .Ve .PP Note that while dialects usually produce satisfactory wiki markup, not all features of all dialects are supported. Consult individual dialects' documentation for details of supported features. Suggestions for improvements, especially in the form of patches, are very much appreciated. .PP Since version 0.50 all dialects were separated out from HTML:WikiConverter. Please install the independent dialect packages as needed. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 1 \& my $wc = new HTML::WikiConverter( dialect => $dialect, %attrs ); .Ve .PP Returns a converter for the specified wiki dialect. Croaks if \&\f(CW$dialect\fR is not provided or its dialect module is not installed on your system. Additional attributes may be specified in \f(CW%attrs\fR; see \&\*(L"\s-1ATTRIBUTES\*(R"\s0 for a complete list. .SS "html2wiki" .IX Subsection "html2wiki" .Vb 4 \& $wiki = $wc\->html2wiki( $html, %attrs ); \& $wiki = $wc\->html2wiki( html => $html, %attrs ); \& $wiki = $wc\->html2wiki( file => $file, %attrs ); \& $wiki = $wc\->html2wiki( uri => $uri, %attrs ); .Ve .PP Converts \s-1HTML\s0 source to wiki markup for the current dialect. Accepts either an \s-1HTML\s0 string \f(CW$html\fR, an file \f(CW$file\fR, or a \s-1URI\s0 <$uri> to read from. .PP Attributes assigned in \f(CW%attrs\fR (see \*(L"\s-1ATTRIBUTES\*(R"\s0) will augment or override previously assigned attributes for the duration of the \&\f(CW\*(C`html2wiki()\*(C'\fR call. .SS "elem_search_lineage" .IX Subsection "elem_search_lineage" .Vb 1 \& my $ancestor = $wc\->elem_search_lineage( $node, \e%rules ); .Ve .PP Searches the lineage of \f(CW$node\fR and returns the first ancestor node that has rules matching those specified in \f(CW%rules\fR, or \f(CW\*(C`undef\*(C'\fR if no matching node is found. .PP For example, to find out whether \f(CW$node\fR has an ancestor with rules matching \f(CW\*(C`{ block =>1 }\*(C'\fR, one could use: .PP .Vb 3 \& if( $wc\->elem_search_lineage( $node, { block => 1 } ) ) { \& # do something \& } .Ve .SS "given_html" .IX Subsection "given_html" .Vb 1 \& my $html = $wc\->given_html; .Ve .PP Returns the \s-1HTML\s0 passed to or fetched (ie, from a file or \s-1URI\s0) by the last \f(CW\*(C`html2wiki()\*(C'\fR method call. Useful for debugging. .SS "parsed_html" .IX Subsection "parsed_html" .Vb 1 \& my $parsed_html = $wc\->parsed_html; .Ve .PP Returns a string containing the post-processed \s-1HTML\s0 from the last \&\f(CW\*(C`html2wiki\*(C'\fR call. Post-processing includes parsing by HTML::TreeBuilder, \s-1CSS\s0 normalization by HTML::WikiConverter::Normalizer, and calls to the \f(CW\*(C`preprocess\*(C'\fR and \&\f(CW\*(C`preprocess_tree\*(C'\fR dialect methods. .SS "available_dialects" .IX Subsection "available_dialects" .Vb 1 \& my @dialects = HTML::WikiConverter\->available_dialects; .Ve .PP Returns a list of all available dialects by searching the directories in \f(CW@INC\fR for \f(CW\*(C`HTML::WikiConverter::\*(C'\fR modules. .SS "rules_for_tag" .IX Subsection "rules_for_tag" .Vb 1 \& my $rules = $wc\->rules_for_tag( $tag ); .Ve .PP Returns the rules that will be used for converting elements of the given tag. Follows \f(CW\*(C`alias\*(C'\fR references. Note that the rules used for a particular tag may depend on the current set of attributes being used. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" You may configure \f(CW\*(C`HTML::WikiConverter\*(C'\fR using a number of attributes. These may be passed as arguments to the \f(CW\*(C`new\*(C'\fR constructor, or can be called as object methods on an H::WC object. .PP Some dialects allow other attributes in addition to those below, and may override the attributes' default values. Consult the dialect's documentation for details. .SS "base_uri" .IX Subsection "base_uri" \&\s-1URI\s0 to use for converting relative URIs to absolute ones. This effectively ensures that the \f(CW\*(C`src\*(C'\fR and \f(CW\*(C`href\*(C'\fR attributes of image and anchor tags, respectively, are absolute before converting the \s-1HTML\s0 to wiki markup, which is necessary for wiki dialects that handle internal and external links separately. Relative URIs are only converted to absolute ones if the \f(CW\*(C`base_uri\*(C'\fR argument is present. Defaults to \f(CW\*(C`undef\*(C'\fR. .SS "dialect" .IX Subsection "dialect" (Required) Dialect to use for converting \s-1HTML\s0 into wiki markup. See the \*(L"\s-1DESCRIPTION\*(R"\s0 section above for a list of dialects. \f(CW\*(C`new()\*(C'\fR will fail if the dialect given is not installed on your system. Use \&\f(CW\*(C`available_dialects()\*(C'\fR to list installed dialects. .SS "encoding" .IX Subsection "encoding" Specifies the encoding used by the \s-1HTML\s0 to be converted. Also determines the encoding of the wiki markup returned by the \&\f(CW\*(C`html2wiki\*(C'\fR method. Defaults to \f(CW"utf8"\fR. .SS "escape_entities" .IX Subsection "escape_entities" Passing \f(CW\*(C`escape_entities\*(C'\fR a true value uses HTML::Entities to encode potentially unsafe '<', '>', and '&' characters. Defaults to true. .SS "p_strict" .IX Subsection "p_strict" Boolean indicating whether HTML::TreeBuilder will use strict handling of paragraph tags when parsing \s-1HTML\s0 input. (This corresponds to the \f(CW\*(C`p_strict\*(C'\fR method in the HTML::TreeBuilder module.) Enabled by default. .SS "passthrough_naked_tags" .IX Subsection "passthrough_naked_tags" Boolean indicating whether tags with no attributes (\*(L"naked\*(R" tags) should be removed and replaced with their content. By default, this only applies to non-semantic tags such as ,