Re-emit unknown tags from #tag
authorJackmcbarn <jackmcbarn@gmail.com>
Fri, 6 Jun 2014 19:56:19 +0000 (15:56 -0400)
committerJackmcbarn <jackmcbarn@gmail.com>
Fri, 19 Dec 2014 04:06:22 +0000 (23:06 -0500)
When #tag is given a tag that it doesn't recognize, re-emit it as a
regular tag instead of giving an error. This allows for it to be used with
transparent tags and HTML tags.

Change-Id: I0ceee8a4fdaf2d3142054a108f445ff06597c31a

includes/parser/CoreParserFunctions.php
languages/i18n/en.json
languages/i18n/qqq.json

index e820fe2..a95bbfe 100644 (file)
@@ -953,13 +953,6 @@ class CoreParserFunctions {
                        $inner = null;
                }
 
-               $stripList = $parser->getStripList();
-               if ( !in_array( $tagName, $stripList ) ) {
-                       return '<span class="error">' .
-                               wfMessage( 'unknown_extension_tag', $tagName )->inContentLanguage()->text() .
-                               '</span>';
-               }
-
                $attributes = array();
                foreach ( $args as $arg ) {
                        $bits = $arg->splitArg();
@@ -973,6 +966,19 @@ class CoreParserFunctions {
                        }
                }
 
+               $stripList = $parser->getStripList();
+               if ( !in_array( $tagName, $stripList ) ) {
+                       // we can't handle this tag (at least not now), so just re-emit it as an ordinary tag
+                       $attrText = '';
+                       foreach ( $attributes as $name => $value ) {
+                               $attrText .= ' ' . htmlspecialchars( $name ) . '="' . htmlspecialchars( $value ) . '"';
+                       }
+                       if ( $inner === null ) {
+                               return "<$tagName$attrText/>";
+                       }
+                       return "<$tagName$attrText>$inner</$tagName>";
+               }
+
                $params = array(
                        'name' => $tagName,
                        'inner' => $inner,
index da49fe9..8fc9cf2 100644 (file)
        "signature": "[[{{ns:user}}:$1|$2]] ([[{{ns:user_talk}}:$1|talk]])",
        "signature-anon": "[[{{#special:Contributions}}/$1|$2]]",
        "timezone-utc": "UTC",
-       "unknown_extension_tag": "Unknown extension tag \"$1\"",
        "duplicate-defaultsort": "<strong>Warning:</strong> Default sort key \"$2\" overrides earlier default sort key \"$1\".",
        "duplicate-displaytitle": "<strong>Warning:</strong> Display title \"$2\" overrides earlier display title \"$1\".",
        "invalid-indicator-name": "<strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.",
index 42ae44c..2c01b02 100644 (file)
        "signature": "This will be substituted in the signature (~<nowiki></nowiki>~~ or ~~<nowiki></nowiki>~~ excluding timestamp).\n\nParameters:\n* $1 - the username that is currently login\n* $2 - the customized signature which is specified in [[Special:Preferences|user's preferences]] as non-raw\nUse your language default parentheses ({{msg-mw|parentheses}}), but not use the message direct.\n\nSee also:\n* {{msg-mw|Signature-anon}} - signature for anonymous user",
        "signature-anon": "{{notranslate}}\nUsed as signature for anonymous user. Parameters:\n* $1 - username (IP address?)\n* $2 - nickname (IP address?)\nSee also:\n* {{msg-mw|Signature}} - signature for registered user",
        "timezone-utc": "{{optional}}",
-       "unknown_extension_tag": "This is an error shown when you use an unknown extension tag name.\n\nThis feature allows tags like <code><nowiki><pre></nowiki></code> to be called with a parser like <code><nowiki>{{#tag:pre}}</nowiki></code>.\n\nParameters:\n* $1 - the unknown extension tag name",
        "duplicate-defaultsort": "See definition of [[w:Sorting|sort key]] on Wikipedia. Parameters:\n* $1 - old default sort key\n* $2 - new default sort key",
        "duplicate-displaytitle": "Warning shown when a page has its display title set multiple times. Parameters:\n* $1 - old display title\n* $2 - new display title",
        "invalid-indicator-name": "Warning shown when the [https://www.mediawiki.org/wiki/Help:Page_status_indicators &lt;indicator name=\"''unique-identifier''\">''content''&lt;/indicator>] parser tag is used incorrectly.",