Last modified: 2007-06-28 16:36:34 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.
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)
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.
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
I'd prefer to go with a class. It's rather more flexible that way.
(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.
<source> is part of an extension and is not present in the core of MediaWiki.
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.
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.
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.
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.
(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.
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.
Thank you. Very well done.