User:AnomieBOT/source/d/Nowiki.pm/doc

NAME
d::Nowiki - AnomieBOT decorator for nowiki (and other content) stripping

SYNOPSIS
use AnomieBOT::API; $api = new AnomieBOT::API('conf.ini', 1); $api->decorators(qw/d::Nowiki/);

DESCRIPTION
contains utility functions for manipulating nowiki tags in the page, for use by an AnomieBOT task. When "d::Nowiki" is used as a decorator on the API object, the following methods are available.

METHODS PROVIDED

 * $api->get_token_for( $content )
 * Returns the opaque token to be used for the specified content. Modulo hash collisions, the same token will not be returned for different contents; the same token will be returned for identical values of content.


 * $api->get_token_regex
 * Returns a regular expression that will match tokens.


 * $api->strip_regex( $re, $wikitext )
 * $api->strip_regex( $re, $wikitext, \%mapping )
 * Given some wikitext and a regular expression, replaces all text matching the regex with an opaque token. If the optional  hashref is provided, the mappings of the tokens back to the removed text will be added to that hashref (and that hashref will be returned as the second value).
 * Returns a list of two values: The wikitext with matches replaced and a hashref mapping tokens back to the removed text. In a scalar context, returns just the text.
 * Notes:
 * The returned text may contain unusual characters such as  and  . MediaWiki doesn't like to save these, so this should help prevent your saving a broken page.
 * If you apply this function multiple times, it would be best to apply  in the reverse order.


 * $api->replace_stripped( $wikitext, \%mapping )
 * $api->replace_stripped( $wikitext, \%mapping, ... )
 * Searches  for tokens defined in the mapping hashrefs, and replaces them with the original text. If multiple mapping hashrefs are given, they are processed in the order given. In other words, this is correct:

($text,$mapping1) = $api->strip_regex($re1, $text); ($text,$mapping2) = $api->strip_regex($re2, $text); $text = $api->replace_stripped($text, $mapping2, $mapping1);
 * Returns the corrected wikitext.


 * $api->strip_tags( \@tags, $wikitext )
 * $api->strip_tags( \@tags, $wikitext, \%mapping )
 * Given some wikitext, replaces the specified XML-like tags with an opaque token. To also strip comments, include the special tag "!--". You can then process the wikitext without worrying about affecting things you shouldn't and call  when done.
 * Returns the same as, which in fact it uses internally.
 * Note that this doesn't handle #tags. Use  from d::Templates for that.


 * $api->extension_tags
 * $api->extension_tags( $reload )
 * Return the current list of XML-like extension tags, plus "!--".


 * $api->strip_nowiki( $wikitext )
 * $api->strip_nowiki( $wikitext, \%mapping )
 * Given some wikitext, replaces nowikis, pres, and comments with an opaque token. You can then process the wikitext without worrying about affecting things you shouldn't and call  when done.
 * Returns the same as, which in fact it uses internally.


 * $api->replace_nowiki( $wikitext, $nowiki_hashref )
 * Exists as an alias for  for backwards compatibility.

COPYRIGHT
Copyright 2008–2013 Anomie

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.