Last modified: 2007-06-28 16:36:34 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 10196 - A class is needed for the pre tags on CSS/JS pages (and display them LTR)
A class is needed for the pre tags on CSS/JS pages (and display them LTR)
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Aryeh Gregor (not reading bugmail, please e-mail directly)
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-08 10:45 UTC by Huji
Modified: 2007-06-28 16:36 UTC (History)
1 user (show)

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


Attachments

Description Huji 2007-06-08 10:45:50 UTC
It is a fairly easy to solve issue, and I would be grateful if this is not postponed to future.

Look at this example page please:
http://fa.wikipedia.org/wiki/%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1:ExtraTools/ExtraTools.js

As you notice, because the wiki is in a right-to-left language, the Javascript code is also rendered right-to-left. Looking at the page HTML, we observe that the Javascript code is inside a PRE tag. If we had a way to add a style to this PRE tag (through common.css file) to force it to be rendered left-to-right, the problem was solved. However, we need a solution which impacts on this PRE only, not all PRE tags on wiki pages (there are cases where a right-to-left PRE is needed).

The solution is fairly easy. We just need to have an ID attribute for the PRE tags used on User:foo/bar.js and User:foo/bar.css pages of the wiki, so we can add this to commons.css:

PRE#theID{
 direction:ltr;
}

and voila!

Hope you will oblige.
Comment 1 Danny B. 2007-06-08 10:50:31 UTC
body.page-کاربر_ExtraTools_ExtraTools_js pre
  {
  direction: ltr;
  }

works at least in gecko based browsers

(each body has a class named page-<pagename> and that's how you can differentiate)
Comment 2 Danny B. 2007-06-08 10:53:16 UTC
add on:

In case the solution above wouldn't fit your needs: You don't want to use _id_ but _class_ if you plan to have same styled <pre>s on one page otherwise you'll make the page invalid.
Comment 3 Huji 2007-06-08 13:03:08 UTC
Danny,

We need a solution which works on all .css and .js pages, not only one specific page. This is because all JS and CSS code should be shown left-to-right, logically.

The first solution you posted above, which was a wise one, is limited to the page I gave as the example, so it doesn't fit our needs. Of course I could right a javascript hack, which would check if the last three letters of the BODY tag's class attrib or "_js" and to apply a special class to the PRE in such a situation; but this is a "hack" not a solution.

As this special style is going to be used only with one object in the page (the PRE on JS or CSS pages) I don't think it would be necessary to use a class for it. (By defintion, classes are used for cases when multiple objects should share a common style). An ID attrib would do it very well.

Thanks for your comments

Comment 4 Aryeh Gregor (not reading bugmail, please e-mail directly) 2007-06-08 13:58:19 UTC
I'd prefer to go with a class.  It's rather more flexible that way.
Comment 5 Danny B. 2007-06-08 19:27:12 UTC
(In reply to comment #3)
> Danny,
> 
> We need a solution which works on all .css and .js pages, not only one specific
> page. This is because all JS and CSS code should be shown left-to-right,
> logically.
>
> The first solution you posted above, which was a wise one, is limited to the
> page I gave as the example, so it doesn't fit our needs. Of course I could
> right a javascript hack, which would check if the last three letters of the
> BODY tag's class attrib or "_js" and to apply a special class to the PRE in
> such a situation; but this is a "hack" not a solution.

I wasn't apparently reading carefuly... ;-)

Anyway, how about using <source> instead of <pre>? <source> has it's own stylesheets so you can define proper direction there... Therefore you can also have syntax hilighting as a side-effect.

> As this special style is going to be used only with one object in the page (the
> PRE on JS or CSS pages) I don't think it would be necessary to use a class for
> it. (By defintion, classes are used for cases when multiple objects should
> share a common style). An ID attrib would do it very well.

Well, the source on page you linked to has couple of <pre> tags... -> You never know if you will ever need more blocks. And as Simetrical says in comment #4: It's much more flexible.

> Thanks for your comments

You're welcome.
Comment 6 Aryeh Gregor (not reading bugmail, please e-mail directly) 2007-06-08 21:41:04 UTC
<source> is part of an extension and is not present in the core of MediaWiki.
Comment 7 Huji 2007-06-09 17:57:40 UTC
All right, I'm fine with the idea of using a class. I'm trying my best to create a patch for it myself, but I would really appreciate anyone to help in this case.
Comment 8 Danny B. 2007-06-09 22:37:12 UTC
Actually another solution, which you can use right at the moment without requesting the patch is this:

<div class="ltrpre">
<pre>
... some JS or CSS code ...
</pre>
</div>


div.ltrpre pre
  {
  direction: ltr;
  }

Wrapping in <div> or <span> with such class works almost always.
Comment 9 Huji 2007-06-10 14:55:34 UTC
That is not an option I think. the PRE tag created by MediaWiki for .js and .css pages, is included in a DIV tag right now. Actually, the current structure of the .js or .css pages is as follows:

body > DIV#globalWrapper > DIV#column-content > DIV#content > DIV#bodyContent > PRE

However, if we have a non-js non-css page with PRE tags, it again has the above structure. Applying the CSS you provided above to DIV#bodyContent as such:

DIV#bodyContent PRE {
  direction:ltr;
}

Will of course make the PRE on .js and .css pages to look correct, but it will also affect all of the PRE tags in all other non-js non-css pages, which is what I want to avoid. I only need the PRE tags for "code" pages (CSS or JS) to be left-to-right.
Comment 10 Aryeh Gregor (not reading bugmail, please e-mail directly) 2007-06-10 16:37:40 UTC
Fixed in r22887 for user CSS/JS.  Note that I used dir="ltr", not CSS properties; the information is part of the content, it's not stylistic.  This should still be done for site CSS/JS.
Comment 11 Brion Vibber 2007-06-12 19:16:10 UTC
(In reply to comment #6)
> <source> is part of an extension and is not present in the core of MediaWiki.

Just a note on this -- in theory the rendering could be hooked so a syntax-highlighting extension could prettify the display of such source pages. If that's desired it should be opened as a separate entry, though.
Comment 12 Aryeh Gregor (not reading bugmail, please e-mail directly) 2007-06-26 01:01:20 UTC
I figured out why I couldn't find the bit that wrapped site CSS/JS in a <pre>: there is none, right.  :)  Added one, with class and dir="ltr", in r23409.
Comment 13 Huji 2007-06-28 16:36:34 UTC
Thank you. Very well done. 

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


Navigation
Links