MediaWiki:Gadget-I18n-js.js: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
remove markdown support in msgs (not used by any code on dev + markdown is not a format used anywhere else in MediaWiki)
m (Add missing path separator)
(remove markdown support in msgs (not used by any code on dev + markdown is not a format used anywhere else in MediaWiki))
Line 6: Line 6:
  * @author OneTwoThreeFall <https://dev.fandom.com/User:OneTwoThreeFall>
  * @author OneTwoThreeFall <https://dev.fandom.com/User:OneTwoThreeFall>
  *
  *
  * @version 0.5.8
  * @version 0.5.9
  *
  *
  * @notes Also used by VSTF wiki for their reporting forms (with a non-dev i18n.json page)
  * @notes Also used by VSTF wiki for their reporting forms (with a non-dev i18n.json page)
Line 439: Line 439:
             .replace(genderRgx, function (_match, gender, forms) {
             .replace(genderRgx, function (_match, gender, forms) {
                 return mw.language.gender(gender, forms.split('|'));
                 return mw.language.gender(gender, forms.split('|'));
            });
    }
    /*
    * Parse markdown links into HTML. Also supports basic inline HTML tags.
    *
    * Will process:
    * - [text](url)
    * - [page]
    * - [text](page)
    *
    * @param The message to process.
    *
    * @return the resulting string.
    */
    function markdown(message) {
            // [text](url)
        var urlRgx = /\[(.+?)\]\(((?:https?:)?\/\/.+?)\)/g,
            // [page]
            simplePageRgx = /\[(.+?)\]/g,
            // [text](page)
            pageWithTextRgx = /\[(.+?)\]\((.+?)\)/g;
        if (message.indexOf('<') > -1) {
            message = sanitiseHtml(message);
        }
        return message
            .replace(urlRgx, function (_match, text, href) {
                return makeLink(href, text, true);
            })
            .replace(simplePageRgx, function (_match, href) {
                return makeLink(href);
            })
            .replace(pageWithTextRgx, function (_match, text, href) {
                return makeLink(href, text);
             });
             });
     }
     }
Line 518: Line 482:


                 return parse(msg);
                 return parse(msg);
            },
            /*
            * Parse markdown links in the message and return the result.
            *
            * @return The resulting string.
            */
            markdown: function () {
                // skip parsing if the message wasn't found otherwise
                // the sanitisation will mess with it
                if (!this.exists) {
                    return this.escape();
                }
                return markdown(msg);
             },
             },


Line 850: Line 799:
         _handleArgs: handleArgs,
         _handleArgs: handleArgs,
         _parse: parse,
         _parse: parse,
        _markdown: markdown,
         _fallbacks: fallbacks
         _fallbacks: fallbacks
     });
     });
Cookies help us deliver our services. By using our services, you agree to our use of cookies.