Last modified: 2014-04-23 17:15:26 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 T59824, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 57824 - Display tabs in .mw-code as 4 spaces using CSS tab-size property
Display tabs in .mw-code as 4 spaces using CSS tab-size property
Status: NEW
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.23.0
All All
: Low minor (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-02 03:36 UTC by Minh Nguyễn
Modified: 2014-04-23 17:15 UTC (History)
4 users (show)

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


Attachments

Description Minh Nguyễn 2013-12-02 03:36:14 UTC
Tabs in code blocks should be rendered as four spaces, instead of the default eight, using the tab-size CSS3 property.

Shorter tabs make most languages more readable, especially on smaller screens. Moreover, shortening the tabs would harmonize this feature with the CodeEditor extension, which displays tabs as four spaces and now binds the Tab key to the tab character.

The following rule in MediaWiki core would primarily apply to stylesheets and scripts in the MediaWiki: namespace:

.mw-code {
    -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4;
}

It degrades gracefully in browsers that lack support for the tab-size property. (See <http://caniuse.com/css3-tabsize>.) Some caveats:

* It doesn't cover Lua modules, because the Scribunto extension doesn't use the `mw-code` class (it probably should).
* It doesn't match ordinary <pre> blocks. Alternatively, it might make sense to just select `.mw-code, pre`, and let extensions or individual pages override the rule if necessary.
* The SyntaxHighlight extension seems to convert tabs to eight actual spaces, so this rule would have no effect on <source> tags.

See [[Wikipedia:Village pump (technical)#GeSHi tab size]] for more discussion about this proposal. The Vietnamese Wikipedia has used tab-size for awhile without complaints.
Comment 1 Minh Nguyễn 2013-12-02 03:55:07 UTC
(In reply to comment #0)
> * It doesn't cover Lua modules, because the Scribunto extension doesn't use
> the
> `mw-code` class (it probably should).

Filed bug 57825.

> * The SyntaxHighlight extension seems to convert tabs to eight actual spaces,
> so this rule would have no effect on <source> tags.

Filed bug 57826.
Comment 2 Andre Klapper 2013-12-02 11:34:02 UTC
Is there a minimal testcase somewhere available?
Comment 3 Minh Nguyễn 2013-12-02 11:46:59 UTC
How about [[mw:MediaWiki:Gadget-oldeditor.js]]? An example on a wiki that uses tab-size is [[wikt:vi:MediaWiki:Gadget-headers.js]].
Comment 4 Rastus Vernon 2013-12-08 01:04:10 UTC
I think it would be better to simply set the tab-size property to 4 on the entire document (the body element). Tabulations equivalent to 8 spaces are never desirable, so I can't think of any reason to not set it to 4 on everything.
Comment 5 Erwin Dokter 2014-03-26 11:25:56 UTC
tab-size is still a CSS3 draft. There is no support in IE (not even 11). Such a rule would cause some inconsistencies across browsers.
Comment 6 Minh Nguyễn 2014-03-26 12:01:05 UTC
There’s already an inconsistency in every browser between the view and edit actions, which leads to confusing indentation in scripts and modules. In IE and older versions of Safari, tab-size degrades gracefully, in that tabs continue to appear eight spaces wide. I wouldn’t consider that a regression.
Comment 7 Rastus Vernon 2014-03-27 02:16:47 UTC
(In reply to Erwin Dokter from comment #5)

I think that would be a problem if it caused a regression, but, as Minh Nguyễn mentioned, it degrades gracefully since it does not cause problems. That it is inconsistent is not really a problem: it is still an improvement to have a decent tab size on modern browsers even if the old behavior is kept on browsers that do not implement it.

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


Navigation
Links