Last modified: 2014-11-20 09:20:14 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 30630 - Math expressions in RTL wikis should have LTR alignment
Math expressions in RTL wikis should have LTR alignment
Status: REOPENED
Product: MediaWiki
Classification: Unclassified
Internationalization (Other open bugs)
1.21.x
All All
: Normal normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: i18n
Depends on:
Blocks: rtl 28708
  Show dependency treegraph
 
Reported: 2011-08-30 11:30 UTC by reza1615
Modified: 2014-11-20 09:20 UTC (History)
16 users (show)

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


Attachments
Before JS code for LTR (32.44 KB, image/png)
2011-08-30 11:30 UTC, reza1615
Details
after JS code (32.35 KB, image/png)
2011-08-30 13:24 UTC, reza1615
Details
incurrect direction result in PDF extension (396.91 KB, application/pdf)
2011-08-31 18:44 UTC, reza1615
Details
iran's high school books screen shot http://www.chap.sch.ir/MaghtaList.asp (46.52 KB, image/png)
2011-08-31 19:11 UTC, reza1615
Details
another screen shop from physics book (69 bytes, text/plain)
2011-08-31 19:16 UTC, reza1615
Details
another screen shop from physics book (911.43 KB, image/jpeg)
2011-08-31 19:19 UTC, reza1615
Details

Description reza1615 2011-08-30 11:30:57 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.
Comment 1 reza1615 2011-08-30 13:24:49 UTC
Created attachment 8986 [details]
after JS code

after using JS code in fa.wiki
Comment 2 Mark A. Hershberger 2011-08-31 14:22:49 UTC
Adding SPQRobin since he has done a lot of RTL work so he can look at this.
Comment 3 Brion Vibber 2011-08-31 18:02:00 UTC
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.
Comment 4 reza1615 2011-08-31 18:38:03 UTC
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.
Comment 5 reza1615 2011-08-31 18:44:04 UTC
Created attachment 8995 [details]
incurrect direction result in PDF extension
Comment 6 reza1615 2011-08-31 18:44:45 UTC
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.
Comment 7 Brion Vibber 2011-08-31 18:51:49 UTC
(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.
Comment 8 reza1615 2011-08-31 19:11:05 UTC
Created attachment 8997 [details]
iran's high school books screen shot http://www.chap.sch.ir/MaghtaList.asp
Comment 9 reza1615 2011-08-31 19:15:11 UTC
in Farsi i am sure that mathematics formula is like "after JS" image.
Comment 10 reza1615 2011-08-31 19:16:21 UTC
Created attachment 8998 [details]
another screen shop from physics book
Comment 11 reza1615 2011-08-31 19:19:54 UTC
Created attachment 8999 [details]
another screen shop from physics book
Comment 12 Brion Vibber 2011-08-31 19:29:40 UTC
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.
Comment 13 Robin Pepermans (SPQRobin) 2011-08-31 19:34:27 UTC
Indeed.

Notified Amir about this bug, and adding him as CC. I suppose he can tell how it's written in Hebrew.
Comment 14 Amir E. Aharoni 2011-08-31 21:37:09 UTC
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.
Comment 15 Brion Vibber 2011-08-31 23:42:59 UTC
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!
Comment 16 [no longer active user] 2011-09-01 06:10:48 UTC
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.
Comment 17 Volker Haas 2011-09-01 10:42:33 UTC
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
Comment 18 reza1615 2011-09-01 10:52:27 UTC
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
Comment 19 reza1615 2011-09-01 11:14:33 UTC
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
Comment 20 Volker Haas 2011-09-01 13:16:56 UTC
(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.
Comment 21 reza1615 2011-09-01 13:37:05 UTC
it has also this problem

http://en.wikipedia.org/wiki/User:Reza1615/pdf
Comment 22 Mark A. Hershberger 2011-09-21 13:47:34 UTC
(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.
Comment 23 reza1615 2011-09-21 14:11:04 UTC
(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
Comment 24 Sumana Harihareswara 2011-10-13 19:49:28 UTC
Now that we have deployed MediaWiki 1.18 to WMF wikis: is this problem still reproducible?
Comment 26 Andre Klapper 2013-03-07 16:52:14 UTC
(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?
Comment 27 reza1615 2013-03-07 16:58:03 UTC
yes! it works only for lines which doesn't have text and only <math> used in them
Comment 28 Peter Krautzberger 2013-08-23 17:13:57 UTC
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.
Comment 29 [no longer active user] 2013-08-24 13:08:12 UTC
(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.

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


Navigation
Links