Last Comment Bug 267882 - Make http://www.mozilla.org/projects/mathml/demo/texvsmml.xhtml validate
: Make http://www.mozilla.org/projects/mathml/demo/texvsmml.xhtml validate
Status: RESOLVED FIXED
:
Product: www.mozilla.org
Classification: Other
Component: General (show other bugs)
: other
: All All
: -- normal
: ---
Assigned To: Gérard Talbot
:
Mentors:
: 268750 273184 (view as bug list)
Depends on:
Blocks: validate
  Show dependency treegraph
 
Reported: 2004-11-05 00:29 PST by Jan Egil Kristiansen
Modified: 2012-08-23 00:16 PDT (History)
9 users (show)
See Also:
Locale:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Make the torture test valid (7.09 KB, patch)
2007-11-10 05:48 PST, Frédéric Wang (:fredw)
no flags Details | Diff | Splinter Review
W3C-valid, but with the hack (7.46 KB, patch)
2007-11-10 10:14 PST, Frédéric Wang (:fredw)
no flags Details | Diff | Splinter Review
Screenshot of the hack (7.17 KB, image/png)
2008-07-15 01:04 PDT, Frédéric Wang (:fredw)
no flags Details
Hack with mo (7.23 KB, image/png)
2008-07-15 01:05 PDT, Frédéric Wang (:fredw)
no flags Details
No hack (7.64 KB, image/png)
2008-07-15 01:05 PDT, Frédéric Wang (:fredw)
no flags Details

Description Jan Egil Kristiansen 2004-11-05 00:29:34 PST
The page is still at its old URL at
http://www.mozilla.org/projects/mathml/demo/texvsmml.xhtml.

(But that page doesn't validate, is 'torture' also including invalid markup?)
Comment 1 dolphinling 2004-11-09 18:26:50 PST
*** Bug 268750 has been marked as a duplicate of this bug. ***
Comment 2 Anne (:annevk) 2004-11-20 02:45:34 PST
Since the link part has been fixed, I'm turning this into a "make valid" bug.

Someone with suggestions for the ALT text?
Comment 3 Jan Egil Kristiansen 2004-11-20 04:49:27 PST
As far as validation is concerned, alt="" will do.

What about alt="Formula screenshot"?

Going for alt="(x+y**2)/k+1" etc., is probably too farfetched?
Comment 4 Anne (:annevk) 2004-11-20 05:19:23 PST
Maybe an empty OBJECT element should be used instead? Or an OBJECT element with
as alternative content MathML or a description of the formula (so not 'F = m * a').

Jacques Distler, do you have any suggestions?
Comment 5 distler 2004-11-20 07:38:56 PST
Good Alt text?

For those of us who use mathematics on the web, the best Alt text would be a
(La)TeX representation of the same formula. That's what I would put as the Alt
text for any GIF image representing a mathematical formula.

But that page isn't called "torture test" for nothing. Here's the (AMS)LaTeX
representation of #23:

alt="\begin{pmatrix}\begin{pmatrix} a & b\\ c & d \end{pmatrix} &
\begin{pmatrix} e & f\\ g & h \end{pmatrix} \\ 0 & \begin{pmatrix} i
& j\\ k & l \end{pmatrix} \end{pmatrix}"

Plain LaTeX would be even more convoluted:

alt="\left(\begin{array}\left(\begin{array}\right) a & b\\ c & d
\end{array}\right) & \left(\begin{array} e & f\\ g & h
\end{array}\right) \\ 0 & \left(\begin{array} i & j\\ k & l
\end{array}\right) \end{array}\right)"

And I like plain TeX even less.
Comment 6 Jan Egil Kristiansen 2004-11-21 03:42:40 PST
For a serious MathML page, having a MathML object failback to TeX, which
failbacks to a GIF object, with failback to HTML is a good idea.

But this page - being a test - will be better served with alt="load this GIF to
see what the formula should look like".
Comment 7 distler 2004-11-21 08:03:41 PST
We all know that <object> provides more flexible fallback options than <img
alt="..." longdesc="...">. That's not the *point*.

alt="..." is supposed to provide a textual alternative to the image. "Load the
GIF" is *not* a textual alternative. Better to leave it blank, alt="".

If you want a textual alternative, use the (La)TeX formula. That is the Lingua
Franca for describing what a formula should look like, using plain text.
Comment 8 Anne (:annevk) 2004-11-21 08:15:07 PST
There seems to be a publishing problem with this file. I updated it a while ago
and it still isn't republished. David, do you know what might be wrong?
Comment 9 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2004-11-21 09:53:57 PST
The change you checked in looks like it's reflected on the website.  Or is it on
some mirrors and not others?
Comment 10 Anne (:annevk) 2004-11-21 09:58:28 PST
It's changed now. Maybe it was my cache, sorry about bugging you.
Comment 11 Anne (:annevk) 2004-12-04 15:36:24 PST
*** Bug 273184 has been marked as a duplicate of this bug. ***
Comment 12 Frédéric Wang (:fredw) 2007-11-10 05:48:49 PST
Created attachment 288134 [details] [diff] [review]
Make the torture test valid

I add empty alt texts to images of TeX.
I remove the "mphamtom" hack (example 22), as it seems useless for me. However you can keep it if you change the "(" by "<mo>(</mo>".
Comment 13 rbs 2007-11-10 06:25:08 PST
> I remove the "mphamtom" hack (example 22), as it seems useless for me.

Useless? Looks like you may be overlooking the fact that the two braces on that expression may not be on the same level anymore. [without that mphantom, one brace should be at a little lower position than the other one because you have the braces on top of "a,...,a" and "b,...,b" -- which are of different height -- c.f. "ab". The trick with that "(" is to give the same height to "(a" and "b", see "(a" and "(b"?  TeX calls the height of an (invisible/zero-width) parenthesis the \mathstrut, and it is handy to stack things uniformly. MathML doesn't have this thing -- which is what that mphantom hack tried to emulate.]
Comment 14 Frédéric Wang (:fredw) 2007-11-10 10:14:44 PST
Created attachment 288149 [details] [diff] [review]
W3C-valid, but with the hack

OK, so here is a new patch that preserve the hack...
Comment 15 rbs 2007-11-11 15:42:09 PST
All you want is to change the "(" by "<mo>(</mo>", as you thought earlier. My comment was to document the why-side of the hack.

[It can not be achieved with a fixed setting like "20px" or such -- because it is a dynamic hack -- like the "ex" or "em" units that can change dynamically with the CSS cascade/font-size/zoom/etc.]
Comment 16 Frédéric Wang (:fredw) 2007-11-12 10:09:07 PST
I had also tried to change the "(" by "<mo>(</mo>", but in this case the hack does not work (I suppose Firefox display it smaller when it is in a <mo>) ! I agree about the dynamic problem of "20px" but it is not worse than doing the assumption about the size of the parenthesis... and at less it validates.
Comment 17 Gérard Talbot 2008-07-12 22:57:42 PDT
Hello all,

I have read all of the comments so far and have examined attachment 288149 [details] [diff] [review] carefully. I'm ready to apply such patch unless I hear objections, opposing comments.

Regards, Gérard
Comment 18 Frédéric Wang (:fredw) 2008-07-13 03:40:48 PDT
The main objection was about the way to fix the "ugly hack". Some people wanted to preserve it even if it makes the page not valid and may only work with Firefox 2. Maybe you should study the rendering with Firefox 3 before applying the patch.
Comment 19 Gérard Talbot 2008-07-13 08:30:28 PDT
Hello Frédéric,

Thank you for the quick reply.

The (only!) difference between attachment 288134 [details] [diff] [review] and attachment 288149 [details] [diff] [review] is the way this code from example 22 is coded and replaced:

Line 802 and line 822 in the source code: 
<mpadded width="0"><mphantom>(</mphantom></mpadded>
<!-- \mathstrut -ugly hack a la TeX -->

My intent - and it is still the same - is to replace that line (802 and 822 in source code) of code with what you proposed in attachment 288149 [details] [diff] [review]:

+          <mstyle mathsize="20px">
+             <!-- ugly hack a la TeX -->
+             <mpadded width="0"><mphantom><mtext>\mathstrut</mtext></mphantom></mpadded>
+          </mstyle>

In any case(1), whether we agree or not on such way to replace that line of code, I see no reason not to submit, apply all of the other changes (namely add the alt="") for that webpage.

I must say that I do NOT have the font faces CMSY10, CMEX10 (tex.css), Math1, Math2, Math4 (mathematica.css) installed on my machines.. so I do not see exactly what the ugly hack is about and why or what it does... most likely overcoming a layout issue with the rendering of those font faces.

Anyway... if some of you or some of you prefer that I leave lines 802 and 822 
<mpadded width="0"><mphantom>(</mphantom></mpadded>
as they are, I can do that too.
Comment 20 Gérard Talbot 2008-07-13 08:35:35 PDT
One small thing that bugged me when examining the code. All of the images do not have their width and height attributes specified.

It's always preferable to define width and height for images. The reason for that is that defining image width and height helps speed up rendering as the browser knows how much space to allocate a particular area (image placeholder) while parsing and rendering the page. Otherwise, the browser has to wait until the graphic is loaded before it knows where to put anything below or to the right of the graphic. The browser may need to rearrange the page as the images are downloaded. When it does, the visitor sees a reflow, a shift in the page
layout.
Comment 22 Gérard Talbot 2008-07-13 08:49:54 PDT
right part of the underbrace doesn't render correctly, mathml torture 
page #22:   (1.66 KB, image/gif) from peter kootstra,
attachment 99389 [details] from bug 120198

Is that what the ugly hack is trying to overcome?
Comment 23 Gérard Talbot 2008-07-13 08:55:13 PDT
Also
http://www.mozilla.org/projects/mathml/demo/extras.xhtml (41 errors with W3C validator)

When I use Firefox extension HTML validator 0.8.5.2, I get 1 or 2 more errors than from when using the W3C validation service.
Comment 24 Gérard Talbot 2008-07-13 10:28:56 PDT
Re comment #21
Bug 445029:
Make several MathML xhtml demo webpages validate (with no errors)
has just been created for this purpose.
Comment 25 Frédéric Wang (:fredw) 2008-07-13 11:14:29 PDT
- Yes, adding alt tag to each image will be a good thing to fix several errors. Nevertheless, note that even if empty alt tag are recommended for "decorative" image (http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8 ) I don't really know what is appropriate for the present case (see the discussion above).

- I agree that adding size of the image would be useful.

- If I remember well, the "ugly hack" was used to fix layout problem but your screenshot shows rather a font issue. In Firefox 3, layout engine has been rewritten and normally the STIX font are used. Hence the result may be different and I don't know if the hack is still relevant.
Comment 26 Gérard Talbot 2008-07-13 12:27:49 PDT
- alt attribute value: the webpage is served as utf-8. One thing we can do for simple mathematical expressions is to find the correspondent utf-8 (numerical) character entity references. E.g.:
Example 1's alt attribute could be: x&x2082;y&x2082; or x&#8322;y&#8322;
So Line 98:
<td><img src="../screenshots/ex1.gif" /></td>
becomes then
<td><img src="../screenshots/ex1.gif" width="38" height="22" alt="x&#8322;y&#8322;" /></td>


subscripts and superscripts: U2070 to U2094: 0 to 9 and some others

mathematical symbols: U2200 to U23DB
E.g.: large left parenthesis upper hook, extension and lower hook: U239B, U239C, U239D

miscellaneous mathematical symbols A: U27C0 to U27FF

For a majority of the examples in the webpage, it's not possible to construct an alternate text's alt attribute value. I think it's not that important since the image is there to graphically render what the rendered text should be or look like... and alt attribute value is there to provide a textual equivalent, a text rendering of a non-text content (image, audio, video).

- I'll include the width and height values in their correspondent attribute value then

- the link href value at line 84
<a href="http://bugzilla.mozilla.org/show_bug.cgi?id=120198">
should rather be
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=120198">

- at line 60
<body onclick="javascript:viewmath(event);">
should be instead
<body onclick="viewmath(event);">

and in the <head> part, we could (and should!) just include

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Language" content="en" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />

In that spirit, I suggest changing line 1
<?xml version="1.0"?>
into
<?xml version="1.0" encoding="UTF-8"?>


- at line 42 and 43,
tr { 
  vertical-align: middle;
}
should be entirely removed since
vertical-align only applies to table-cells and inline elements
"vertical-align
   Applies to: inline-level and 'table-cell' elements "
http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align

and because the default vertical alignement of table cells [in all browsers too] is middle.
"middle: Cell data is centered vertically within the cell. This is the default value."
http://www.w3.org/TR/html4/struct/tables.html#adef-valign

- "I don't know if the hack is still relevant"
Ok, then. I will leave line 802 and line 822 in the source code as they are: 
<mpadded width="0"><mphantom>(</mphantom></mpadded>
<!-- \mathstrut -ugly hack a la TeX -->
We can later reevaluate or make corrections once we clarify that issue. 

Agreed?


Comment 27 Gérard Talbot 2008-07-13 12:33:49 PDT
Argh... Doh!

x&x2082;y&x2082; or x&#8322;y&#8322;
is for subscripts, not superscript which is what is in the example.

Correction:
Line 98:
<td><img src="../screenshots/ex1.gif" /></td>
becomes then
<td><img src="../screenshots/ex1.gif" width="38" height="22"
alt="x&#178;y&#178;" /></td>

(or x&#x00B2;y&#x00B2; for hexadecimal)
Comment 28 Gérard Talbot 2008-07-13 12:41:17 PDT
Line 116:
<td><img src="../screenshots/ex2.gif" /></td>
becomes then
<td><img src="../screenshots/ex2.gif" width="30" height="17" alt="&x2082;F&x2083;" /></td>

Line 138:
<td><img src="../screenshots/ex21.gif" /></td>
becomes then
<td><img src="../screenshots/ex21.gif" width="58" height="47" alt="x + y&#178; divided by k + 1" /></td>

etc.. for cases which are possible to do.
Comment 29 Gérard Talbot 2008-07-14 01:42:28 PDT
> Line 116:
> <td><img src="../screenshots/ex2.gif" /></td>
> becomes then
> <td><img src="../screenshots/ex2.gif" width="30" height="17"
> alt="&x2082;F&x2083;" /></td>

I tried that in a local version and I must do

<td><img src="../screenshots/ex2.gif" width="30" height="17"
alt="&#8322;F&#8323;" /></td>

instead.

With all the changes discussed, I go from 31 errors to 2 errors only... which correspond to the "hacks" discussed before:

<mpadded width="0"><mphantom>(</mphantom></mpadded> <!-- \mathstrut -ugly hack a la TeX -->
Comment 30 Gérard Talbot 2008-07-14 02:07:18 PDT
Patched webpage (intermediary stage), which include all changes discussed (except the 2 "hacks"):

http://www.gtalbot.org/BugzillaSection/Bug267882-new-version-inter.xhtml

What I wanted to test is if HTML Tidy was able to pretty print that XHTML + MathML code.

Note that 5 images have relevant non-empty alt attribute values.
Comment 31 Gérard Talbot 2008-07-14 02:28:34 PDT
In this webpage:

http://www.gtalbot.org/BugzillaSection/Bug267882-new-version-inter.xhtml

on top of the changes and corrections discussed and submitted,

- I tweaked the local stylesheet code a bit
- I added scope="col" for the table headers
- I converted " -> " into " -&gt; "
- code outside the <table> has been re-indented to 2 characters (just like default code indentation value in HTML Tidy)
- code outside the <table> line-wraps at 76 characters. This helps code maintenance and eventual code review, code comparison with previous versions.
- added <code> around user_pref("font.minimum-size.x-western", 10)

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.gtalbot.org%2FBugzillaSection%2FBug267882-new-version-inter.xhtml&charset=(detect+automatically)&doctype=Inline&group=0 
Comment 32 Gérard Talbot 2008-07-14 02:46:14 PDT
Another thing. The content of items 3 and 4 (about font size, minimal font size and how to text zoom) should be updated and be on par with Firefox 3 and not with the old Mozilla suite or previous versions of Firefox.


Current text:
"
(...) this can be 
set with, e.g, user_pref("font.minimum-size.x-western", 10).
(...) to increase your default font size in the menu:
'Edit -> Preferences -> Appearance -> Fonts'.
(...) 4. You can use 'View -> Text Zoom' in the usual way to zoom the MathML text 
"

Suggested changes:
"
(...) this can be 
set with Tools/Options.../Content tab/Fonts and colors/Advanced button/
(...) to increase your default font size in the menu:
'Tools -> Options... -> Content tab -> Fonts and colors, size'
(...) 4. You can use 'View -> Zoom, Text Zoom only checked' to zoom the MathML text 
"
Comment 33 Frédéric Wang (:fredw) 2008-07-15 01:04:54 PDT
Created attachment 329632 [details]
Screenshot of the hack
Comment 34 Frédéric Wang (:fredw) 2008-07-15 01:05:28 PDT
Created attachment 329633 [details]
Hack with mo
Comment 35 Frédéric Wang (:fredw) 2008-07-15 01:05:43 PDT
Created attachment 329634 [details]
No hack
Comment 36 Frédéric Wang (:fredw) 2008-07-15 01:06:01 PDT
- "the webpage is served as utf-8. One thing we can do for simple mathematical expressions is to find the correspondent utf-8 (numerical) character entity references". Just a small remark: It seems that you believe serving the page as UTF-8 is mandatory in order to use the entity references. It is not true, since characters used to encode entity references in XML are all ASCII (digits, sharp etc). Actually, serving the page as UTF-8 allows to directly write these characters in the page, without using entity references! By the way I don't see why you fail using hexadecimal entity references in alt text. Is it a bug of Firefox?

- I've just made some tests with the hack, using the new configuration of Firefox 3 (Gecko 1.9 + STIX fonts). As I said before, the purpose of this hack was to fix a problem of layout: alignment of the two braces (see the screenshots). I remember that adding <mo> arround the parenthesis did not fix the problem, but it seems that it does with the new configuration. Hence I suppose you can make this correction to make the page valid. However, I still think we should find a way to do the alignment properly... I guess we should look to http://www.w3.org/TR/MathML3/chapter3.html#presm.malign

- For alt text, I'm not sure that your idea of using utf-8 characters is good and you admit yourself that it can not be applied for all tests. Some people proposed TeX syntax but the problem is that it is not universally understood. In my opinion there are two main cases where the alt text is useful for people: when they have visual disabilities or when their browsers are not able to display images. Ideally, if they use tools that can deal with MathML, such as speech synthesizers, they don't need a non-empty alt text attached to the image of the formula (after all, replacing image was one of the reason MathML was done!). Nevertheless, we have to remember that it is a test page and so these tools may fail, just like a browser may not render the formulae properly. Finally, I believe that we can leave the alt text empty (or if we really want to, write how the formula is read in english) but we must add a column that describes the test rather than the formula. For instance "variables with exponents" (1), "variable with multiscripts" (2) etc.
Comment 37 Gérard Talbot 2008-07-15 09:42:37 PDT
> serving the page as
> UTF-8 is mandatory in order to use the entity references. It is not true, 
> (...)  Actually, serving the page as UTF-8 allows to directly write these
> characters in the page, without using entity references! 

Yes. Correct. You are right.
The use of character entity references is mainly, only limited by the capabilities (Unicode range support) of the font in use.

> I don't see
> why you fail using hexadecimal entity references in alt text. Is it a bug of
> Firefox?

I have no idea.

> - For alt text, I'm not sure that your idea of using utf-8 characters is good
> and you admit yourself that it can not be applied for all tests. 

I agree with you that if a found solution can not be applied to all 28 test-lines, then it may not be a suitable solution.

> I believe that we can leave the alt text empty (or if we really want
> to, write how the formula is read in english)

Yes. Writing how the whole formula would be read in english is most likely a better solution and a solution which would work for all 28 test-lines.
So the table of that "MathML Torture Test" needs a 3rd column now.

> but we must add a column that
> describes the test rather than the formula. For instance "variables with
> exponents" (1), "variable with multiscripts" (2) etc.

I agree. A column describing what each test-line is doing will be useful in such "MathML Torture Test". So, that would be a 4th column.
Comment 38 Gérard Talbot 2008-07-15 09:56:55 PDT
Ok, here's what I'll do.

I'll make a first patch this weekend and apply it. It won't have any alt text. It will have all of the issues, corrections discussed and agreed so far, including the one in comment #32.

It will have what you proposed in attachment 288149 [details] [diff] [review] regarding
line (802 and 822 in source code) of code

+          <mstyle mathsize="20px">
+             <!-- ugly hack a la TeX -->
+             <mpadded
width="0"><mphantom><mtext>\mathstrut</mtext></mphantom></mpadded>
+          </mstyle>

After such patch, we can tackle issues which may be remaining.

So, if anyone has objections or issues, they have until this weekend to speak up in this bug.

-------------

As for another column indicating how the formula is read in english, I can not do that. And another bug report should be created specifically for that.

As for another column describing the test, I can not do that and again, best would be to create another bug. I took assignment of bug 151557 and wanted to see if I could help fix this 267882 bug.
Comment 39 Gérard Talbot 2008-07-15 09:57:59 PDT
-> me
Comment 40 Frédéric Wang (:fredw) 2008-07-15 23:40:23 PDT
For the hack, you can replace

<mpadded width="0"><mphantom>(</mphantom></mpadded>

by

<mpadded width="0"><mphantom><mo>(</mo></mphantom></mpadded>
Comment 41 Gérard Talbot 2008-07-18 21:28:17 PDT
Patched submitted and checked in

Checking in mozilla-org/html/projects/mathml/demo/texvsmml.xhtml;
/www/mozilla-org/html/projects/mathml/demo/texvsmml.xhtml,v  <--  texvsmml.xhtml
new revision: 1.4; previous revision: 1.3
done

Let me know if anything is wrong or missing.

Gérard
Comment 42 Gérard Talbot 2008-07-19 10:34:14 PDT
Checking in mozilla-org/html/projects/mathml/demo/texvsmml.xhtml;
/www/mozilla-org/html/projects/mathml/demo/texvsmml.xhtml,v  <--  texvsmml.xhtml
new revision: 1.5; previous revision: 1.4
done

Added intra-project [crumbs] navigation links as recommended by http://www.mozilla.org/contribute/writing/guidelines
and at
http://www.mozilla.org/contribute/writing/markup; added <link>s for Site navigation toolbar for the same reasons; made "ViewView -&gt; Zoom, Text Zoom only checked" styled as .menu; replaced single quote around strechy='false' with double quotes.

Unless I hear something from someone about something missing or wrong, I will resolve this bug as FIXED in 4 days or so.

Regards, Gérard
Comment 43 Joe Java 2008-07-21 11:58:59 PDT
http://www.mozilla.org/projects/mathml/demo/texvsmml.xhtml
validates as XHTML with 

This Page Is Valid XHTML 1.1 plus MathML 2.0!

but fails CSS validation at ( http://jigsaw.w3.org/css-validator/ ) with 

Target: http://www.mozilla.org/projects/mathml/demo/texvsmml.xhtml
Please, validate your XML document first!
Line 239
Column 15
A colon is not allowed in the name 'IS10744:arch' when namespaces are enabled.
Comment 44 Gérard Talbot 2008-07-23 20:07:03 PDT
The error message regarding the colon and the IS10744:arch have nothing to do with the actual CSS code of local embedded stylesheet and alternate stylesheets but rather with namespace support.

Resolving as FIXED

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