Extension talk:StringFunctionsEscaped/Archive

Problem when using this Extension together with ParserFunctions
I'm running MediaWiki 1.16.1 together with Extension:ParserFunctions r62695 which is the default snapshot when selecting MediaWiki 1.16.x from the Extension Distributor. In LocalSettings.php I first include ParserFunctions, then StringFunctionsEscaped. Extension StringFunctions is not included, because it is already contained by ParserFunctions. All ParserFunctions- and StringFunctions-related stuff works fine in the wiki, but none of the StringFunctionsEscaped work.

Without having a lot of knowledge about MediaWiki-Extension-devlopment I managed to solve the problem by also installing and including the Extension StringFunctions and then uncommenting the setfunctionhooks in ParserFunctions.php (lines 94-103): //String Functions // if ( $wgpfenablestringfunctions ) { // $parser->setfunctionhook( 'len',     array(&$this, 'runlen'      )); // $parser->setfunctionhook( 'pos',     array(&$this, 'runpos'      )); // $parser->setfunctionhook( 'rpos',    array(&$this, 'runrpos'     )); // $parser->setfunctionhook( 'sub',     array(&$this, 'runsub'      )); // $parser->setfunctionhook( 'count',   array(&$this, 'runcount'    )); // $parser->setfunctionhook( 'replace', array(&$this, 'runreplace'  )); // $parser->setfunctionhook( 'explode', array(&$this, 'runexplode'  )); // }

I'm not sure if this should be regarded as a bug or if it's just a known incompatibility between versions.

ATHeinrich 08:49, 1 June 2011 (UTC)

White-space trimming --Dmb 14:10, 4 June 2010 (UTC)
Hi,

How would I use this extension to make a general purpose 'white-space trimming' template? I often find that my layout of code in templates, which is optimized for readability, is substandard when it comes to layout, typically introducing too much white-space at the point where the template is called.

I'd like to write two 'wrapper' templates that would call templates but strip white-space:
 * 1) before and after the textual return value of the template, and
 * 2) everywhere within the textual return of the template.

For example, the latter template would be useful when the called template isn't designed to generate any output, but rather perform some calculation or another. In that case, the template should be 'invisible' to the calling page. As it is I often find a) problems with white-space, or b) template code that is hard to read and lacks in-line documentation.

Where I'd normally be saying, I'd like to say:


 * , or

Or something like that. Can I build those templates with this extension?

Cheers, --Dmb 14:10, 4 June 2010 (UTC)

Re:White-space trimming --jdpond 16:07, 4 June 2010 (UTC)

 * I don't know if this answers your question, but...


 * You could absolutely use this extension if you know what you want to remove by specifying the characters to remove. For example:


 * This will eliminate all the newlines from the source.


 * Some commonly used "white space" characters are:


 * "\x20" (ASCII 32 (0x20)), an ordinary space.
 * "\t" (ASCII 9 (0x09)), a tab.
 * "\n" (ASCII 10 (0x0A)), a new line (line feed).
 * "\r" (ASCII 13 (0x0D)), a carriage return.
 * "\0" (ASCII 0 (0x00)), the NUL-byte.
 * "\x0B" (ASCII 11 (0x0B)), a vertical tab


 * On the other hand, if you'd like me to add the PHP equivalent of "trim" and "php_strip_whitespace", I don't see why not, it would only take about 15 minutes to do - just submit that as an MW Extension Enhancement Request. (make sure you select the component "StringFunctionsEscaped").  I'd probably use the #trim_e and the #strip_whitespace_e tags.

Which Wikimedia wikis?
The OnWikimedia box claims this extension is used on wikimedia wikis. However, on which wiki is it used? The check usage does not know the extension at all and no information seems to be given (or perhaps I missed it?). -- (asked by G.Hagedorn 20 December 2010)
 * (Hi, please sign your questions with ~ and consider using the Talk page). You can look at CommonSettings.php and InitialiseSettings.php on http://noc.wikitech.org for the current configuration details. I'm not sure which Wikimedia sites ever activated it (i.e. it appeared in their Special:Version), but the extension is no longer part of WMF's internal deployments after 1.21wmf4. Unfortunately there's no Template: Was on Wikimedia sites. -- S Page (WMF) (talk) 20:55, 29 November 2012 (UTC)