Page MenuHomePhabricator

Support px as LaTeX length unit
Closed, ResolvedPublic

Description

While my version of LaTeX does not seem to support px, people were using it. It is easy to add support for this, at the cost of the expression no longer being copyable from Wikipedia to LaTeX. I don't have a strong preference for either. But maybe we keep it as is and decide later to deprecate support for px lengths.

Details

Related Changes in Gerrit:

Event Timeline

Change #1342811 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@master] WikiTexVC: Accept px as a length unit

https://gerrit.wikimedia.org/r/1342811

The units advertised by https://en.wikipedia.org/wiki/Help:Displaying_a_formula are:
em, mu, ex, in, pc, pt, cm, mm

(I wouldn't have a problem if we reduce the number of supported units, and do some kind of Wikipedia-wide find/replace to fix any examples which use non-standard units. But we should make sure we don't leave any articles broken.)

We should probably make all our units relative rather than absolute, and base the interpretation of units on whatever currently happens in the "server-side SVG" mode. I don't think most Wikipedia authors are very scrupulous about picking the correct units, so we want to keep the appearance (i.e. relative spacing) the same as the current version, even if font sizes, devices, display resolutions, etc. change.

Ok, the current LaTeX Syntax checker accepts the units from the manual + some extra cases. Anything else is not detected as and thus rendered as Tex in the next line. There is unfortunately jet another problem. The correct MathML spacing is not picked up by mathjax. I will open another ticket.

Maybe we just hold a vote on whether we want px. I would not ask if people would prefer to find [some invalid length spec] because that might make it more difficult to type something that starts with a [ on a new line. Ok?

I make it 119 uses in en wikipedia. Some quite high profile articles like Platonic solid, and Bessel function. So a yes from me.

In the current "server-side SVG" mode, px and pt behave exactly the same.

So 2 possible approaches:

(1) your implementation treats these identically
(2) we run a search and turn every instance of px into pt across English Wikipedia

@Jacobolus, thank you. The downside of (2) is that we can't change history, so permanent links would still show broken formulae. I think, therefore, we can just merge the minimal change I suggested (1).

I'm not too worried about permalinks.

Mediawiki has profoundly broken permalinks, because transclusion (templates) always uses the current version of the transcluded resource rather than the historical version.

But sure, supporting 'px' as an alias for 'pt' would be fine. (I am not seeing where in the code the size of the unit is defined, and I don't really understand why making a trivial change like this requires modifying hundreds of lines of code.)

Change #1342811 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Accept px as a length unit

https://gerrit.wikimedia.org/r/1342811