<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://leushev.ru/content/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://leushev.ru/content/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3ATextCleaner.js</id>
		<title>MediaWiki:TextCleaner.js - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://leushev.ru/content/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3ATextCleaner.js"/>
		<link rel="alternate" type="text/html" href="http://leushev.ru/content/index.php?title=MediaWiki:TextCleaner.js&amp;action=history"/>
		<updated>2026-04-25T10:10:00Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.19.4</generator>

	<entry>
		<id>http://leushev.ru/content/index.php?title=MediaWiki:TextCleaner.js&amp;diff=79298&amp;oldid=prev</id>
		<title>Sysop: Новая страница: «// &lt;source lang=&quot;javascript&quot;&gt; /*   Wikitext sanitation for MediaWiki     Author: User:Lupo, January 2008   License: Quadruple licensed GFDL, GPL, LGPL and Creati…»</title>
		<link rel="alternate" type="text/html" href="http://leushev.ru/content/index.php?title=MediaWiki:TextCleaner.js&amp;diff=79298&amp;oldid=prev"/>
				<updated>2009-09-20T07:45:21Z</updated>
		
		<summary type="html">&lt;p&gt;Новая страница: «// &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt; /*   Wikitext sanitation for MediaWiki     Author: &lt;a href=&quot;/content/index.php?title=%D0%A3%D1%87%D0%B0%D1%81%D1%82%D0%BD%D0%B8%D0%BA:Lupo&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Участник:Lupo (страница не существует)&quot;&gt;User:Lupo&lt;/a&gt;, January 2008   License: Quadruple licensed GFDL, GPL, LGPL and Creati…»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;// &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
  Wikitext sanitation for MediaWiki&lt;br /&gt;
 &lt;br /&gt;
  Author: [[User:Lupo]], January 2008&lt;br /&gt;
  License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)&lt;br /&gt;
 &lt;br /&gt;
  Choose whichever license of these you like best :-)&lt;br /&gt;
*/&lt;br /&gt;
 &lt;br /&gt;
var TextCleaner =&lt;br /&gt;
{&lt;br /&gt;
 &lt;br /&gt;
  // This function attempts to construct well-formed wikitext from input that may contain&lt;br /&gt;
  // possibly broken wikitext.&lt;br /&gt;
  //&lt;br /&gt;
  // Note: even just a half-baked sanitation of wikitext is hyper-complex due to the presence&lt;br /&gt;
  // of templates, and due to the fact that image thumbnail captions may themselves contain&lt;br /&gt;
  // links. This implementation catches the most common errors (such as forgetting to close a&lt;br /&gt;
  // template or a link), and even some more elaborate ones. With enough malice, this sanitation&lt;br /&gt;
  // can still be broken by user input such that the result is not well-formed wikitext as the&lt;br /&gt;
  // parser at the servers would like to have it. (It's still possible that the result is broken&lt;br /&gt;
  // wikitext, if the input was broken wikitext. But it never transforms well-formed wikitext&lt;br /&gt;
  // into broken wikitext.)&lt;br /&gt;
  //&lt;br /&gt;
  // If 'only_thumbs' is true, all [[Image: links are changed to [[:Image:, unless the original&lt;br /&gt;
  // image link was a thumbnail or had a width smaller than 300px specified.&lt;br /&gt;
  //&lt;br /&gt;
  // WARNING: do *not* attempt to use this to process large texts (e.g., a whole article). It is&lt;br /&gt;
  // probably rather inefficient due to the many substrings that are generated. This function is&lt;br /&gt;
  // primarily intended to be used to clean up user input in forms, which are typically rather&lt;br /&gt;
  // short.&lt;br /&gt;
  sanitizeWikiText : function (input, only_thumbs)&lt;br /&gt;
  {&lt;br /&gt;
    if (input.search (/[\][}{]|&amp;lt;nowiki(\s[^&amp;gt;]*)?&amp;gt;|&amp;lt;\!--/) &amp;lt; 0) return input;&lt;br /&gt;
    // No critical characters&lt;br /&gt;
 &lt;br /&gt;
    var consumed       = new Array (0, 0);&lt;br /&gt;
    // For image captions. Image caption may contain links, and may even contain images.&lt;br /&gt;
    // The current MediaWiki parser actually allows this only once. For deeper recursions,&lt;br /&gt;
    // it fails. But here, it's actually easier to implement no limit.&lt;br /&gt;
 &lt;br /&gt;
    var base_regexp    =&lt;br /&gt;
      new RegExp&lt;br /&gt;
            (   &amp;quot;[\\x01\\x02\\x03\\x04[\\]\\|\\x05\\x06\\x07\\x08]&amp;quot;&lt;br /&gt;
              + &amp;quot;|\&amp;lt;nowiki(\\s[^&amp;gt;]*)?\&amp;gt;|\&amp;lt;\!--&amp;quot;&lt;br /&gt;
            , &amp;quot;i&amp;quot;); // Ignore case&lt;br /&gt;
    var nowiki_regexp  = new RegExp (&amp;quot;\&amp;lt;\\/nowiki(\\s[^&amp;gt;]*)?\&amp;gt;|\&amp;lt;\!--&amp;quot;, &amp;quot;i&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
    var allow_only_thumbs = only_thumbs;&lt;br /&gt;
 &lt;br /&gt;
    function sanitize&lt;br /&gt;
      (s, with_links, caption_level, allow_thumbs, break_at_pipe, with_tables, with_galleries)&lt;br /&gt;
    {&lt;br /&gt;
      if (!s || s.length == 0) {&lt;br /&gt;
        if (caption_level &amp;gt; 0) {&lt;br /&gt;
          if (consumed.length &amp;lt; caption_level)&lt;br /&gt;
            consumed.push (0);&lt;br /&gt;
          else&lt;br /&gt;
            consumed[caption_level-1] = 0;&lt;br /&gt;
        }&lt;br /&gt;
        return s;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
      var result         = &amp;quot;&amp;quot;;&lt;br /&gt;
      var initial_length = s.length;&lt;br /&gt;
      var get_out        = false;&lt;br /&gt;
      var in_nowiki      = false;&lt;br /&gt;
      var endings        = null;&lt;br /&gt;
      // Stack recording template and table nesting&lt;br /&gt;
      var next;&lt;br /&gt;
 &lt;br /&gt;
      function push_end (val)&lt;br /&gt;
      {&lt;br /&gt;
        if (endings == null) {&lt;br /&gt;
          endings = new Array (1);&lt;br /&gt;
          endings[0] = val;&lt;br /&gt;
        } else {&lt;br /&gt;
          endings[endings.length] = val;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
      function pop_end ()&lt;br /&gt;
      {&lt;br /&gt;
        if (endings == null) return null; // Shouldn't happen&lt;br /&gt;
        var result;&lt;br /&gt;
        if (endings.length == 1) {&lt;br /&gt;
          result = endings[0];&lt;br /&gt;
          endings = null;&lt;br /&gt;
        } else {&lt;br /&gt;
          result = endings[endings.length -1];&lt;br /&gt;
          endings.length = endings.length - 1;&lt;br /&gt;
        }&lt;br /&gt;
        return result;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
      regexp = base_regexp;&lt;br /&gt;
      while (s.length &amp;gt; 0 &amp;amp;&amp;amp; !get_out) {&lt;br /&gt;
        next = s.search (regexp);&lt;br /&gt;
 &lt;br /&gt;
        if (next &amp;lt; 0) {&lt;br /&gt;
          result = result + s;&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        var ch = s.charAt (next);&lt;br /&gt;
        var i  = -1;&lt;br /&gt;
        var j  = -1;&lt;br /&gt;
        var k  = -1;&lt;br /&gt;
        switch (ch) {&lt;br /&gt;
          case '&amp;lt;':&lt;br /&gt;
            // Nowiki or HTML comment. Must be closed.&lt;br /&gt;
            if (s.charAt (next+1) == '!') {&lt;br /&gt;
              // HTML comment. Cannot be nested.&lt;br /&gt;
              i = s.indexOf ('--\&amp;gt;', next+3);&lt;br /&gt;
              if (i &amp;lt; 0) {&lt;br /&gt;
                result = result + s + '--\&amp;gt;';&lt;br /&gt;
                s = &amp;quot;&amp;quot;;&lt;br /&gt;
              } else {&lt;br /&gt;
                result = result + s.substring (0, i + 3);&lt;br /&gt;
                s = s.substring (i+3);&lt;br /&gt;
              }&lt;br /&gt;
            } else if (s.charAt (next+1) == 'n') {&lt;br /&gt;
              // Nowiki may contain HTML comments!&lt;br /&gt;
              in_nowiki = true;&lt;br /&gt;
              regexp = nowiki_regexp;&lt;br /&gt;
              result = result + s.substring (0, next + 7);&lt;br /&gt;
              s = s.substring (next + 7);&lt;br /&gt;
            } else {&lt;br /&gt;
              // End of nowiki. Searched for and found only if in_nowiki == true&lt;br /&gt;
              in_nowiki = false;&lt;br /&gt;
              regexp = base_regexp;&lt;br /&gt;
              i = s.indexOf ('&amp;gt;', next+1); // End of tag&lt;br /&gt;
              result = result + s.substring (0, i+1);&lt;br /&gt;
              s = s.substring (i+1);&lt;br /&gt;
            }&lt;br /&gt;
            break;&lt;br /&gt;
          case '\x05':&lt;br /&gt;
            // Table start&lt;br /&gt;
            if (!with_tables) {&lt;br /&gt;
              result  = result + s.substring (0, next);&lt;br /&gt;
              get_out = true;&lt;br /&gt;
              break;&lt;br /&gt;
            }&lt;br /&gt;
            // Fall through&lt;br /&gt;
          case '\x07':&lt;br /&gt;
            if (ch == '\x07' &amp;amp;&amp;amp; !with_galleries) {&lt;br /&gt;
              result = result + s.substring (0, next);&lt;br /&gt;
              get_out = true;&lt;br /&gt;
              break;&lt;br /&gt;
            }&lt;br /&gt;
          case '\x01':&lt;br /&gt;
            // Start of template, table, or gallery&lt;br /&gt;
            result = result + s.substring (0, next+1);&lt;br /&gt;
            push_end (String.fromCharCode(ch.charCodeAt (0)+1).charAt (0));&lt;br /&gt;
            s = s.substring (next+1);&lt;br /&gt;
            break;&lt;br /&gt;
          case '\x06':&lt;br /&gt;
            // Table end&lt;br /&gt;
            if (break_at_pipe &amp;amp;&amp;amp; endings == null) {&lt;br /&gt;
              result = result + s.substring (0, next);&lt;br /&gt;
              get_out = true;&lt;br /&gt;
              break;&lt;br /&gt;
            }&lt;br /&gt;
            // Fall through&lt;br /&gt;
          case '\x02':&lt;br /&gt;
            // End of a template or table&lt;br /&gt;
            result = result + s.substring (0, next);&lt;br /&gt;
            if (endings == null || endings[endings.length - 1] != ch) {&lt;br /&gt;
              // Spurious template or table end&lt;br /&gt;
              if (ch == '\x02')&lt;br /&gt;
                result = result + '&amp;amp;#x7D;&amp;amp;#x7D;';&lt;br /&gt;
              else&lt;br /&gt;
                result = result + '&amp;amp;#x7C;&amp;amp;#x7D;';&lt;br /&gt;
            } else {            &lt;br /&gt;
              result = result + pop_end ();&lt;br /&gt;
            }&lt;br /&gt;
            s = s.substring (next+1);&lt;br /&gt;
            break;&lt;br /&gt;
          case '\x08':&lt;br /&gt;
            // End of gallery&lt;br /&gt;
            result = result + s.substring (0, next+1);&lt;br /&gt;
            if (endings != null &amp;amp;&amp;amp; endings[endings.length - 1] == ch) pop_end (); &lt;br /&gt;
            s = s.substring (next+1);&lt;br /&gt;
            break; &lt;br /&gt;
          case '\x03':&lt;br /&gt;
          case '[':&lt;br /&gt;
            {&lt;br /&gt;
              if (!with_links &amp;amp;&amp;amp; endings == null) {&lt;br /&gt;
                get_out = true;&lt;br /&gt;
                break;&lt;br /&gt;
              }&lt;br /&gt;
              // Image links must be treated specially, since they may contain nested links&lt;br /&gt;
              // in the caption!&lt;br /&gt;
              var initial = null;  // If set, it's 'image:' or 'file:' and we have an image link&lt;br /&gt;
              i = next;&lt;br /&gt;
              while (i &amp;lt; s.length &amp;amp;&amp;amp; s.charAt (i) == ch) i++;&lt;br /&gt;
              if (ch == '\x03' &amp;amp;&amp;amp; i &amp;lt; s.length &amp;amp;&amp;amp; s.charAt (i) == '[') i++;&lt;br /&gt;
              if (i+5 &amp;lt; s.length) {&lt;br /&gt;
                initial = s.substr (i, 6);&lt;br /&gt;
                if (initial.toLowerCase () != 'image:') {&lt;br /&gt;
                  initial = initial.substr (0, 5);&lt;br /&gt;
                  if (initial.toLowerCase () != 'file:') initial = null;&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
              // Scan ahead. We'll break at the next top-level | or ] or ]] or [ or [[ or {| or |}&lt;br /&gt;
              var lk_text = sanitize (s.substring (i),&lt;br /&gt;
                                      false,           // No links at top-level allowed&lt;br /&gt;
                                      caption_level + 1,&lt;br /&gt;
                                      false,           // No thumbs&lt;br /&gt;
                                      true,            // Break at pipe&lt;br /&gt;
                                      false,           // No tables&lt;br /&gt;
                                      false);          // No galleries&lt;br /&gt;
              var lk_text_length = consumed[caption_level];&lt;br /&gt;
              j = i + lk_text_length;&lt;br /&gt;
              if (j &amp;gt;= s.length) {&lt;br /&gt;
                // Used up the whole text: [[Foo or [bar&lt;br /&gt;
                if (initial != null &amp;amp;&amp;amp; allow_only_thumbs)&lt;br /&gt;
                  // Should in any case have started with [[, not [&lt;br /&gt;
                  result = result + s.substring (0, i-1) + '\x03:' + initial&lt;br /&gt;
                         + lk_text.substring (initial.length) + '\x04';&lt;br /&gt;
                else&lt;br /&gt;
                  result = result + s.substring (0, i) + lk_text&lt;br /&gt;
                         + ((s.charAt (i-1) == '[') ? ']' : '\x04');&lt;br /&gt;
                s = &amp;quot;&amp;quot;;&lt;br /&gt;
                break;&lt;br /&gt;
              }&lt;br /&gt;
              if (s.charAt (j) == '|') k = j; else k = -1;&lt;br /&gt;
              if (k &amp;lt; 0) {&lt;br /&gt;
                // No pipe found: we should be on the closing ]] or ] or [[Foo]] or [bar]&lt;br /&gt;
                if (initial != null &amp;amp;&amp;amp; allow_only_thumbs)&lt;br /&gt;
                  // Should in any case have started with [[, not [&lt;br /&gt;
                  result = result + s.substring (0, i-1) + '\x03:' + initial&lt;br /&gt;
                         + lk_text.substring (initial.length) + '\x04';&lt;br /&gt;
                else&lt;br /&gt;
                  result = result + s.substring (0, i) + lk_text&lt;br /&gt;
                         + ((s.charAt (i-1) == '[') ? ']' : '\x04');&lt;br /&gt;
                if (s.charAt (j) == ']' || s.charAt (j) == '\x04') {&lt;br /&gt;
                  // Indeed closing the link&lt;br /&gt;
                  s = s.substring (j+1);&lt;br /&gt;
                } else {&lt;br /&gt;
                  s = s.substring (j);&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
              } else {&lt;br /&gt;
                var caption = null;&lt;br /&gt;
                var used    = 0;&lt;br /&gt;
                // Pipe found.&lt;br /&gt;
                if (initial == null) {&lt;br /&gt;
                  // Not an image link. Must be something like [[Foo|Bar]].&lt;br /&gt;
                  caption = sanitize&lt;br /&gt;
                              ( s.substring (k+1)&lt;br /&gt;
                               , false             // No links, please&lt;br /&gt;
                               , caption_level + 1&lt;br /&gt;
                               , false             // No thumbs either&lt;br /&gt;
                               , false             // Don't care about pipes&lt;br /&gt;
                               , true              // Allow tables (yes, parser allows that!)&lt;br /&gt;
                               , true);            // Allow galleries (?)&lt;br /&gt;
                  // Now we're at [[, [, ]], or ]&lt;br /&gt;
                  used = consumed[caption_level];&lt;br /&gt;
                  result = result + s.substring (0, i) + lk_text + '|' + caption&lt;br /&gt;
                         + ((s.charAt (i-1) == '[') ? ']' : '\x04');&lt;br /&gt;
                } else {&lt;br /&gt;
                  var q = s.substring (k);&lt;br /&gt;
                  // We assume that there are no templates, nowikis, and other nasty things&lt;br /&gt;
                  // in the parameters. Search forward until the next [, {, ], }&lt;br /&gt;
                  l = q.search(/[\x01\x02\x03[\x04\]\{\}\x05\x06\x07\x08]/);&lt;br /&gt;
                  if (l &amp;lt; 0) l = q.length;&lt;br /&gt;
                  if (l+1 &amp;lt; q.length) q = q.substring (0, l+1);&lt;br /&gt;
                  var is_thumb = q.search (/\|\s*thumb(nail)?\s*[\|\x04]/) &amp;gt;= 0;&lt;br /&gt;
                  var img_width = /\|\s*(\d+)px\s*[\|\x04]/.exec (q);&lt;br /&gt;
                  if (img_width &amp;amp;&amp;amp; img_width.length &amp;gt; 1) {&lt;br /&gt;
                    img_width = parseInt (img_width[1], 10);&lt;br /&gt;
                    if (isNaN (img_width)) img_width = null;&lt;br /&gt;
                  } else&lt;br /&gt;
                    img_width = null;&lt;br /&gt;
                  if (img_width === null &amp;amp;&amp;amp; is_thumb) img_width = 180;&lt;br /&gt;
                  var is_small = img_width &amp;lt; 300;&lt;br /&gt;
 &lt;br /&gt;
                  // Caption starts at the last pipe before l. If that is a parameter,&lt;br /&gt;
                  // it doesn't hurt.&lt;br /&gt;
                  var m = k + q.lastIndexOf ('|', l);&lt;br /&gt;
                  caption = sanitize&lt;br /&gt;
                              (  s.substring (m+1)&lt;br /&gt;
                               , is_thumb                  // Allow links only if it's a thumb&lt;br /&gt;
                               , caption_level + 1&lt;br /&gt;
                               , allow_thumbs &amp;amp;&amp;amp; is_thumb&lt;br /&gt;
                               , false                     // Don't break at pipe&lt;br /&gt;
                               , is_thumb                  // Tables only if it's a thumb&lt;br /&gt;
                               , is_thumb);                // Allow galleries for thumbs (?)&lt;br /&gt;
                  used = consumed[caption_level];&lt;br /&gt;
                  // caption used 'used' chars from m+1, s.charAt (m+1+used) == '\x04'&lt;br /&gt;
                  is_thumb = allow_thumbs &amp;amp;&amp;amp; is_small;&lt;br /&gt;
                  if (is_thumb || !allow_only_thumbs)&lt;br /&gt;
                    result = result + s.substring (0, i-1) + '\x03' + lk_text ;&lt;br /&gt;
                  else&lt;br /&gt;
                    result = result + s.substring (0, i-1) + '\x03:' + initial&lt;br /&gt;
                           + lk_text.substring (initial.length);&lt;br /&gt;
                  result = result + s.substring (k, m+1) + caption + '\x04';&lt;br /&gt;
                  k = m;&lt;br /&gt;
                }&lt;br /&gt;
                next = k+1+used;&lt;br /&gt;
                if (next &amp;lt; s.length) {&lt;br /&gt;
                  if (s.charAt (next) != '\x04')&lt;br /&gt;
                    s = s.substring (next);&lt;br /&gt;
                  else&lt;br /&gt;
                    s = s.substring (next+1);&lt;br /&gt;
                } else&lt;br /&gt;
                  s = &amp;quot;&amp;quot;;&lt;br /&gt;
              }&lt;br /&gt;
              break;&lt;br /&gt;
            }&lt;br /&gt;
          case '\x04':&lt;br /&gt;
          case ']':&lt;br /&gt;
            // Extra bracket.&lt;br /&gt;
            result = result + s.substring (0, next);&lt;br /&gt;
            if (caption_level == 0 &amp;amp;&amp;amp; !break_at_pipe) {&lt;br /&gt;
              result = result + (ch == ']' ? '&amp;amp;#x5D;' : '&amp;amp;#x5D;&amp;amp;#x5D;');&lt;br /&gt;
              s = s.substring (next+1);&lt;br /&gt;
            } else&lt;br /&gt;
              get_out = true;&lt;br /&gt;
            break;&lt;br /&gt;
          case '|':&lt;br /&gt;
            result = result + s.substring (0, next);&lt;br /&gt;
            if (break_at_pipe &amp;amp;&amp;amp; endings == null) {&lt;br /&gt;
              // Pipe character at top level&lt;br /&gt;
              get_out = true;&lt;br /&gt;
            } else {&lt;br /&gt;
              if (caption_level == 0 &amp;amp;&amp;amp; !break_at_pipe &amp;amp;&amp;amp; endings == null)&lt;br /&gt;
                result = result + '&amp;amp;#x7C;'; // Top-level pipe character&lt;br /&gt;
              else&lt;br /&gt;
                result = result + '|';&lt;br /&gt;
              s = s.substring (next+1);&lt;br /&gt;
            }&lt;br /&gt;
            break;&lt;br /&gt;
        } // end switch&lt;br /&gt;
      } // end while&lt;br /&gt;
      if (in_nowiki) result = result + &amp;quot;\&amp;lt;\/nowiki&amp;gt;&amp;quot;; // Make sure this nowiki is closed.&lt;br /&gt;
      // Close open templates and tables&lt;br /&gt;
      while (endings != null) {&lt;br /&gt;
        ch = pop_end ();&lt;br /&gt;
        result = result + (ch == '\x06' ? '\n' : &amp;quot;&amp;quot;) + ch;&lt;br /&gt;
      }&lt;br /&gt;
      if (caption_level &amp;gt; 0) {&lt;br /&gt;
        var used_up = initial_length - (get_out ? (s.length - next) : 0);&lt;br /&gt;
        if (consumed.length &amp;lt; caption_level)&lt;br /&gt;
          consumed[consumed.length] = used_up;&lt;br /&gt;
        else&lt;br /&gt;
          consumed[caption_level-1] = used_up;&lt;br /&gt;
      }&lt;br /&gt;
      return result;      &lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    // Replace multi-character tokens by one-character placeholders, simplifying the&lt;br /&gt;
    // subsequent processing.&lt;br /&gt;
    var s = input.replace (/\{\{/g, '\x01')&lt;br /&gt;
                 .replace (/\n\s*\|\}\}\}/g, '\n\x06\x02') // Table end + template end&lt;br /&gt;
                 .replace (/\}\}/g, '\x02')&lt;br /&gt;
                 .replace (/\[\[/g, '\x03')&lt;br /&gt;
                 .replace (/\]\]/g, '\x04')&lt;br /&gt;
                 .replace (/\n\s*\{\|/g, '\n\x05')       // Table start and end must be on own line&lt;br /&gt;
                 .replace (/^\s*\{\|/, '\x05')           // Table start at the very beginning&lt;br /&gt;
                 .replace (/\n\s*\|\}/g, '\n\x06')       // (we strip leading whitespace)&lt;br /&gt;
                 .replace (/\&amp;lt;\s*gallery\s*\&amp;gt;/g, '\x07')&lt;br /&gt;
                 .replace (/\&amp;lt;\/\s*gallery\s*\&amp;gt;/g, '\x08');&lt;br /&gt;
 &lt;br /&gt;
    s = sanitize (s, true, 0, true, false, true, true);&lt;br /&gt;
    // with links, allow thumbs, don't break at pipe, allow tables, allow galleries&lt;br /&gt;
    return s.replace (/\x01/g, '\{\{')&lt;br /&gt;
            .replace (/\x02/g, '\}\}')&lt;br /&gt;
            .replace (/\x03/g, '\[\[')&lt;br /&gt;
            .replace (/\x04/g, '\]\]')&lt;br /&gt;
            .replace (/\x05/g, '\{\|')&lt;br /&gt;
            .replace (/\x06/g, '\|\}')&lt;br /&gt;
            .replace (/\x07/g, '&amp;lt;gallery&amp;gt;')&lt;br /&gt;
            .replace (/\x08/g, '&amp;lt;/gallery&amp;gt;');&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
// &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sysop</name></author>	</entry>

	</feed>