Last modified: 2013-01-14 17:17:53 UTC
The following wiki code {| class="wikitable" |- | A | % |} == A == == % == is converted to the following HTML: <table class="wikitable"> <tbody><tr> <td>A</td> <td> %</td> </tr> </tbody></table> <h2> <span id="A" class="mw-headline">A</span></h2> <h2> <span id=".25" class="mw-headline"> %</span></h2> Expected result: <table class="wikitable"> <tbody><tr> <td>A</td> <td>%</td> </tr> </tbody></table> <h2> <span id="A" class="mw-headline">A</span></h2> <h2> <span id=".25" class="mw-headline">%</span></h2>
Work around is to do ==%== instead. (yeah i know, not a fix, but is a workable work around. Also replacing the space before the % with an   would probably work, but not tested) We add a nbsp (note the entity actually output is   not We avoid outputting named entities for compatibility with xml libs when in html5 mode) for things of the form "20 %" which in most langs should be a non-breaking space (Esp. french from my understanding). Bug 18443 comment 7 explains precisely when we do this.
Are these two cases (header and table) the only places, where this automatic replacing is unwanted? In that case, an quick and dirt^Weasy solution would be to replace '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 ', by '/([^=|!]) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 ', or equivalently '/[^=|!]\K (?=[?:;!%]|\\302\\273)/' => ' ', However, bug #18443 would lead to a renewal of those pattern, anyway.
*** Bug 28248 has been marked as a duplicate of this bug. ***
Further wrong converted whitespace: * % # % : % ; %
Then one of the following solutions would be better: '/[^=|!+#:;]\K (?=[?:;!%]|\\302\\273)/' => ' ' or even a separate substitution '/[^=|!+#:;]\K (?=[?:;!]|\\302\\273)/' => ' ' '/[0-9]\K (?=%)/' => ' ' Of course, there may occur things like "a %" or "(a+b) %" but I guess, in those (rare) cases tex or a manual ' ' or ' ' should be used instead. Bug #18443 (meanwhile marked as a duplicate of bug #13619) gives a typographically better solution of the replacement part: '/[0-9]\K (?=%)/' => '<span style="margin-left:0.167em"><span style="display:none"> </span></span>' Looks horrible, but is a great (and tested) solution, concerning readability of wiki source code and usability.