Last modified: 2013-01-14 17:17:53 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T40797, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 38797 - Whitespace between syntax of table or heading and percent sign is converted to a non-breaking space
Whitespace between syntax of table or heading and percent sign is converted t...
Status: NEW
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.20.x
All All
: Low normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
https://meta.wikimedia.org/wiki/Help:...
:
: 28248 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-29 18:36 UTC by Fomafix
Modified: 2013-01-14 17:17 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Fomafix 2012-07-29 18:36:24 UTC
The following wiki code

{| class="wikitable"
|-
| A
| %
|}
== A ==
== % ==

is converted to the following HTML:

<table class="wikitable">
<tbody><tr>
<td>A</td>
<td>&nbsp;%</td>
</tr>
</tbody></table>
<h2> <span id="A" class="mw-headline">A</span></h2>
<h2> <span id=".25" class="mw-headline">&nbsp;%</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>
Comment 1 Bawolff (Brian Wolff) 2012-07-29 18:42:45 UTC
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 &#32; would probably work, but not tested)


We add a nbsp (note the entity actually output is &#160; not &nbsp; 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.
Comment 2 seth 2012-07-29 22:49:21 UTC
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&#160;',
by
  '/([^=|!]) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1&#160;',

or equivalently

  '/[^=|!]\K (?=[?:;!%]|\\302\\273)/' => '&#160;',

However, bug #18443 would lead to a renewal of those pattern, anyway.
Comment 3 Umherirrender 2012-07-31 20:08:30 UTC
*** Bug 28248 has been marked as a duplicate of this bug. ***
Comment 4 Fomafix 2012-08-01 12:22:21 UTC
Further wrong converted whitespace:

* %
# %
: %
; %
Comment 5 seth 2012-08-05 08:39:17 UTC
Then one of the following solutions would be better:

  '/[^=|!+#:;]\K (?=[?:;!%]|\\302\\273)/' => '&#160;'

or even a separate substitution
  '/[^=|!+#:;]\K (?=[?:;!]|\\302\\273)/' => '&#160;'
  '/[0-9]\K (?=%)/' => '&#160;'

Of course, there may occur things like
 "a %" or "(a+b) %"
but I guess, in those (rare) cases tex or a manual '&nbsp;' or '&#160;' 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">&nbsp;</span></span>'

Looks horrible, but is a great (and tested) solution, concerning readability of wiki source code and usability.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links