Page MenuHomePhabricator

Allow HTML attributes for <math>
Closed, ResolvedPublic

Description

Author: en.ABCD

Description:
In a <math> tag, it should be possible to assign the alt and title attributes of
the generated image to something other than the default. If only the alt
attribute is specified, then the title attribute should be set to the value of
the alt attribute.

Example:
<math alt="1/2">\frac{1}{2}</math>


Version: unspecified
Severity: enhancement

Details

Reference
bz1962

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:19 PM
bzimport added a project: Math.
bzimport set Reference to bz1962.
bzimport added a subscriber: Unknown Object (MLST).

en.ABCD wrote:

Patch to add title and alt attributes

Added untested patch against HEAD

attachment math.diff ignored as obsolete

en.ABCD wrote:

Updated - fix error in prev

Fixed the patch

attachment math.diff ignored as obsolete

Hmm, I think this won't strip newlines from specified alt or title text. That might be a problem with
doBlockLevels unless that's been fixed. (eg if there's a newline followed by a list character)

en.ABCD wrote:

Update - fix typo

attachment math.diff ignored as obsolete

en.ABCD wrote:

(In reply to comment #3)

Hmm, I think this won't strip newlines from specified alt or title text. That

might be a problem with

doBlockLevels unless that's been fixed. (eg if there's a newline followed by a

list character)

Testing with this simple test case shows that it works just fine:

<math alt="text" title="some
*text
#&lt;&amp;&gt;

">y=x+2</math>

The text outputed is:

<img class='tex' src="/w/images/math/<SOME_HEX_NUMBER>.png" alt="text"
title="some *text #&lt;&amp;&gt;" />

Patch as posted (attachment 757) doesn't appear to work at all, as it references an
undefined local variable $params in MathRenderer::_linkToMathImage(). If I change
that reference to $this->params and paste in ABCD's sample, I receive this output:

<p><img class='tex' src="/head/images/math/daa63ef966cc412541190bc8794731de.png"
alt="text" title="some
</p>
<ul><li>text
</li></ul>
<ol><li>&lt;&amp;&gt;
</li></ol>
<p>" />
</p>

en.ABCD wrote:

Newest fix

Forgot that I fixed the patch again - this one works directly on my private
wiki

attachment math.diff ignored as obsolete

en.ABCD wrote:

fix it (again!)

attachment math.diff ignored as obsolete

en.ABCD wrote:

fix it (again!!) - wrong type patch

attachment math.diff ignored as obsolete

en.ABCD wrote:

fix it (again!!!) - forgot a file

I really need to proofread first

Attached:

koneko wrote:

So, it's been a few months already, was the patch added or recorrected ?

ayg wrote:

Why not other HTML attributes? class, style, id, and longdesc would all be
potentially handy. (IMO, *all* HTML-style tags should have these, where
appropriate: why not?) Naturally, class/style would be applied to the enclosing
<span>, not to the <img>.

(In reply to comment #11)

So, it's been a few months already, was the patch added or recorrected ?

Evidently not.

bugzilla wrote:

Besides images, tables generated from tex input would benefit from classes.
Perhaps all <code>img</code> and <code>table</code> elements should have a class
of „math“ anyway.

Done in r24065.

Note that 'title' may or may not be technically valid on <math> embedded in HTML, it's kind of unclear, but Mozilla likes it.