Last modified: 2014-11-20 09:20:14 UTC
Created attachment 8985 [details] Before JS code for LTR Math extension equations in RTL wikis is not left aligned. Using a javascript code, this problem is solved in Persian Wikipedia http://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C:Common.js /** * قرار دادن فرمولهای ریاضی در سمت چپ مناسب برای ویکیهای راست به چپ */ $(function(){ $("img.tex, span.texhtml").each(function () { if($(this).parent().text().trim() == $(this).text() && $(this).parent().is("p,dd")) $(this).parent().css({direction: "ltr", padding: "1em 0"}); }); }); but it is just a little hacky so in my opinion it is better to solve it in in mediawiki core.
Created attachment 8986 [details] after JS code after using JS code in fa.wiki
Adding SPQRobin since he has done a lot of RTL work so he can look at this.
1) Is this actually a formatting change that would be desirable? 2) Does this apply to all RTL languages? 3) if 1) and 2) this should probably just be a CSS bit.
mathematics is RTL so its formula have to wright RTL (when formula is in single line) it doesn't have problem in RTL wikis in fa.wiki we correct it http://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C:Common.js but it is hacky and it makes some problem and doesn't work with extensions such as PDF export extension. if we don't correct it all of LTR wikis have to correct it by that JS code.
Created attachment 8995 [details] incurrect direction result in PDF extension
mathematics is LTR so its formula have to wright LTR (when formula is in single line) it doesn't have problem in LTR wikis in fa.wiki (RTL) we correct it http://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C:Common.js but it is hacky and it makes some problem and doesn't work with extensions such as PDF export extension. if we don't correct it all of LTR wikis have to correct it by that JS code.
(In reply to comment #4) > mathematics is RTL so its formula have to wright RTL (when formula is in single > line) > it doesn't have problem in RTL wikis > in fa.wiki we correct it > http://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C:Common.js RTL is "right to left" and describes the overall text direction for Arabic and Hebrew scripts. Farsi text written in Arabic script will be laid out as RTL, with some numerals, Latin text, etc as embedded bits of LTR ("left to right"). In the examples you link to above, it *looks* like all the math formulas are meant to be read as LTR ("left to right"). The ones that appear inline in body text seem to be getting shown much like any other LTR bit (English text, numerals, etc). The one that appears on a standalone line is, in the "before" picture, laid out as LTR. It's also right-aligned, matching the overall look of the page. The "after" picture shows the exact same LTR layout of the formula, but also left-aligns the whole chunk, making it stand out as rather distinct from the rest of the page. Is this how math formulas are normally laid out in Arabic, Farsi, Urdu, Hebrew, etc texts? > but it is hacky and it makes some problem and doesn't work with extensions such > as > PDF export extension. > > if we don't correct it all of LTR wikis have to correct it by that JS code. (In reply to comment #5) > Created attachment 8995 [details] > incurrect direction result in PDF extension PDF export will be entirely separate software and bugs should be opened separately -- if about the PDF export on *.wikipedia.org etc that'll belong in with the Collection extension. There'll be a number of RTL and complex-script issues there.
Created attachment 8997 [details] iran's high school books screen shot http://www.chap.sch.ir/MaghtaList.asp
in Farsi i am sure that mathematics formula is like "after JS" image.
Created attachment 8998 [details] another screen shop from physics book
Created attachment 8999 [details] another screen shop from physics book
Awesome -- these sorts of real-world usage examples are *very* helpful when we're evaluating things like this! Will still want to double-check in other RTL languages to confirm that's generalizable.
Indeed. Notified Amir about this bug, and adding him as CC. I suppose he can tell how it's written in Hebrew.
I checked a few printed Hebrew math textbooks. In Hebrew, the *directionality* of the formula itself is LTR. If the formula is in a paragraph by itself, the *alignment* (text-align) of the paragraph is usually 'center' or 'left', but it is conceivable that it would be 'right'. If the default text-align of a paragraph that consists of nothing but a formula will be 'left', nobody in the Hebrew Wikipedia would complain. It must, of course, be remembered that formulas can be inline.
The trick I think is that we need to make the _parent block_ LTR if all it contains is one (just one? what about one or more?) LTR math elements. The JS on fa.wikipedia does this by checking all math bits (img.tex etc) to see if they have a <p> or <dd> parent that doesn't seem to have other stuff in it, and then adjusting directionality there. This may be doable through CSS instead (cleaner, doesn't require postprocessing) but ... I think it would require additional stuff we don't have. This may really be a more hairy problem, akin to detecting that only LTR text is present in some paragraph and declaring it to be LTR-primary instead of RTL-primary. Urk!
I wrote that little JS on fa.wikipedia, I tried some CSS tricks that I knew. For example this: p > img.tex:first-child:last-child { display: block; text-align: left; } But there is some some problem here: 0) I don't think this is cross-browser compatible. 1) "display: block" not working well (a wrapper needed) so in this situation "text-align: left" has no effect I think. 2) This CSS can not find out there is some texts in that paragraph addition of equation. 3) Two (and more) equations in a paragraph will reject by this.
The PDF rendering engine now renders math nodes left aligned. The following examples where used to check for correctness: http://fa.wikipedia.org/w/index.php?title=%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1:Volker.haas&oldid=5505734 fixed mainly with: https://github.com/pediapress/mwlib/commit/d56e5bc389fadcd2ef1f4d78bc163a3f3d106871
thank you! for pdf extension now it is ok http://fa.wikipedia.org/wiki/%D9%82%D8%B6%DB%8C%D9%87_%D8%A8%DB%8C%D8%B2
in samples if you see left side of formula when it is inside text it does'nt have space for example: http://fa.wikipedia.org/wiki/%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1:Reza1615/pdf in firest line of sample between (formula) "P(A|B)" and "را" in pdf version it doesn't have space
(In reply to comment #19) > in samples if you see left side of formula when it is inside text it does'nt > have space for example: > http://fa.wikipedia.org/wiki/%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1:Reza1615/pdf > in firest line of sample between (formula) "P(A|B)" and "را" in pdf version it > doesn't have space I don't know exactly what goes wrong, but I fear there's not much I can do about it. Spacing around inline images is a bit flaky.
it has also this problem http://en.wikipedia.org/wiki/User:Reza1615/pdf
(In reply to comment #21) > it has also this problem > > http://en.wikipedia.org/wiki/User:Reza1615/pdf Please create a new bug for that. The reported issue is solved.
(In reply to comment #22) > (In reply to comment #21) > > it has also this problem > > > > http://en.wikipedia.org/wiki/User:Reza1615/pdf > > Please create a new bug for that. The reported issue is solved. It solved only on PDF export, in RTL wikis it doesn't change
Now that we have deployed MediaWiki 1.18 to WMF wikis: is this problem still reproducible?
Hi, I checked http://he.wikipedia.org/wiki/%D7%97%D7%95%D7%A7_%D7%91%D7%99%D7%99%D7%A1#.D7.A7.D7.99.D7.A9.D7.95.D7.A8.D7.99.D7.9D_.D7.97.D7.99.D7.A6.D7.95.D7.A0.D7.99.D7.99.D7.9D and http://ar.wikipedia.org/wiki/%D9%85%D8%A8%D8%B1%D9%87%D9%86%D8%A9_%D8%A8%D8%A7%D9%8A%D8%B2 it isn't solved and in fa.wiki it solved with that JS mentioned in comment 1
(In reply to comment #0) > Math extension equations in RTL wikis is not left aligned. Quick update: http://fa.wikipedia.org/wiki/%D9%82%D8%B6%DB%8C%D9%87_%D8%A8%DB%8C%D8%B2 shows that math expression are LTR (because of JavaScript in comment 0) http://ar.wikipedia.org/wiki/%D9%85%D8%A8%D8%B1%D9%87%D9%86%D8%A9_%D8%A8%D8%A7%D9%8A%D8%B2 and http://he.wikipedia.org/wiki/%D7%97%D7%95%D7%A7_%D7%91%D7%99%D7%99%D7%A1#.D7.A7.D7.99.D7.A9.D7.95.D7.A8.D7.99.D7.9D_.D7.97.D7.99.D7.A6.D7.95.D7.A0.D7.99.D7.99.D7.9D they are RTL. If I get it right, the only remaining situation when the problem applies are lines that have a math expression only and no other surrounding text?
yes! it works only for lines which doesn't have text and only <math> used in them
Just stumbled upon this bug via Wikitech-I. For background information RTL+LTR and RTL+RTL, this old W3C document is still useful http://www.w3.org/TR/arabic-math/ -- just keep in mind that it's about MathML 2 -- MathML 3 now supports RTL/LTR fully.
(In reply to comment #28) > Just stumbled upon this bug via Wikitech-I. > > For background information RTL+LTR and RTL+RTL, this old W3C document is > still > useful http://www.w3.org/TR/arabic-math/ -- just keep in mind that it's about > MathML 2 -- MathML 3 now supports RTL/LTR fully. It is fantastic but not very related, this bug is about making math equation left aligned like what we use in our books. Many users was using <div style="text-align: left"> or dir="ltr" to make it on Persian Wikipedia articles so I wrote that little JS code to make only element in a line/paragraph left aligned.