Changes

Jump to: navigation, search

Template:Str index/decode

2,537 bytes added, 19:13, 16 November 2014
category
<noinclude><!--
-======================================================================
- Str_index/decode - Get character for code in parameter 1, else same
-======================================================================
-- (see NOTES at bottom)
--></noinclude>{{{{{|safesubst:}}}#ifeq:
&#|{{{{{|safesubst:}}}padleft:|2|{{{1|&#xx}}} }}|<noinclude><!--
--then decode
--></noinclude>{{{{{|safesubst:}}}#ifeq:
&#35|{{{{{|safesubst:}}}padleft:|4|{{{1|&#35}}} }}|<nowiki/>#}}<noinclude><!--
--></noinclude>{{{{{|safesubst:}}}#ifeq:
&#42|{{{{{|safesubst:}}}padleft:|4|{{{1}}} }}|<nowiki/>*}}<noinclude><!--
--></noinclude>{{{{{|safesubst:}}}#ifeq:
&#58|{{{{{|safesubst:}}}padleft:|4|{{{1}}} }}|<nowiki/>:}}<noinclude><!--
--></noinclude>{{{{{|safesubst:}}}#ifeq:
&#59|{{{{{|safesubst:}}}padleft:|4|{{{1}}} }}|<nowiki/>;}}<noinclude><!--
--check for encoded space--></noinclude>{{{{{|safesubst:}}}#ifeq:
&#32|{{{{{|safesubst:}}}padleft:|4|{{{1}}} }}|<nowiki> </nowiki>}}<noinclude><!--
--else return same--></noinclude>|{{{1|&#xx}}}<noinclude><!--
--></noinclude>}}<noinclude><!--endif '&#' in {1}
---------------------------------------------------------------------
- NOTES
--
-- NOTE A1: This template compares the character code in parameter 1
-- to the prefix "&#" by using Template:Ifeq which can return
-- a result containing a leading space character.
--
---------------------------------------------------------------------
-HISTORY:
-14Nov2012 Created to decode &#nn into a special character of markup
-14Nov2012 Put NOTES comments to explain template operation.
-14Nov2012 Put HISTORY comments to log major changes.
-->

The '''[[Template:Str_index/decode]]''' decodes a character code to return a special character which is normally warpified into a newline by being the first character on a line. The handling of the character is
done through [[Template:Ifeq]] which does not trim leading spaces but will process colon-indent, asterisk-bullets, or semicolon bold-headers. To avoid the column-1 markup codes, a null-nowiki-tag "&lt;nowiki/>" is placed before each special character. For example:
::* {&#123;str_index/decode |&amp;#58;}} &rarr; &lt;nowiki/>:
In the displayed output, all the null-nowiki tags will be skipped, and the formatted page will contain only the specific characters, in their exact positions, as intended. The characters can be decoded at the rate of over 300 per second.

[[Category:String manipulation templates]]
</noinclude>
Anonymous user

Navigation menu