W3C home > Mailing lists > Public > public-webplatform@w3.org > July 2014

MediaWiki escape function

From: Rob^_^ <iecustomizer@hotmail.com>
Date: Thu, 31 Jul 2014 16:10:37 +1000
Message-ID: <BLU168-DS65914B628E62FF3BB4024D4E60@phx.gbl>
To: "List WebPlatform public" <public-webplatform@w3.org>
Hi et al....

It takes a long time to transpose HTML and java script examples into media wiki friendly syntax....



I have written a small MSIE context menu extension to help in the process... it uses the following escape function...

function htmlEscape(s) {
    s = s.replace(/&/g, '&amp;');
    s = s.replace(/>/g, '&gt;');
    s = s.replace(/</g, '&lt;');
    //s = s.replace(/"/g, '&quot;');
    s = s.replace(/'/g, '\'');
    s = s.replace(/=/g, '{{=}}');
    s = s.replace(/\|/g, '{{!}}');
    return s;
}


with the help of http://docs.webplatform.org/wiki/WPD:Style_Guide/Gotchas

Q1. How do I escape double-single quotes.... (‘’)... I have raised an issue ticket for this, but a quick answer would be helpful. eg... var foo=’’; gets transposed to var foo=;

Q2. Are there any other gotcha’s for escaping html and script?

Once completed I can package an installer for IE, Webkit and Gecko for ppl to use....

Greetings from Australia.
Received on Thursday, 31 July 2014 06:11:28 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:21:02 UTC