Page MenuHomePhabricator

Render math markup in query service
Closed, ResolvedPublic

Description

The query result should render math rather than displaying the data source
http://tinyurl.com/jrh2ldx

Details

Related Gerrit Patches:
wikidata/query/gui-deploy : productionMerging from 3df1df468a66a22996e4b75d4826f81056997647:
wikidata/query/gui : masterDisplay MathML in the table view

Event Timeline

Restricted Application added a project: Wikidata. · View Herald TranscriptJun 14 2016, 9:25 AM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald Transcript
Restricted Application added a project: Discovery. · View Herald TranscriptJul 20 2016, 12:22 PM

I used the rest interface to get closer to the origin of the problem:
Formulae are returned as

</binding>
           <binding name='formula'>
                       <literal datatype='http://www.w3.org/1998/Math/MathML'>>&lt;math xmlns="http://www.w3.org/1998/Math/MathML" display="block"&gt;

which does not seem reasonable.
Where does the literal, and with the datatype attribute come from?
Is there a chance to fix that within the math extension?

Maybe the relevant code is https://github.com/wikimedia/mediawiki-extensions-Math/blob/master/MathMLRdfBuilder.php#L33

		$writer->say( $propertyValueNamespace, $propertyValueLName )
			->value( $mml, 'http://www.w3.org/1998/Math/MathML' );

Is there a vagrant role that creates an Wikidata Query Service for testing?

Can it be that the title is misleading?
You want the math to be rendered in the table and other?

This is the place where you could change the rendering:
https://github.com/wikimedia/wikidata-query-gui/blob/master/wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js#L69

@Jonas thank you. After your comment, that was very helpful for me, it turns out that the title is misleading;-)

And yes. Math should be rendered in that table.

For the implementation I would add

var DATATYPE_MATHML = 'http://www.w3.org/1998/Math/MathML';

extend the case statement with

case DATATYPE_MATHML:
 html = data;
 break;

Is it really that simple?

Yes, this should work :)
Thank you for your effort!

T.seppelt added a comment.EditedJul 20 2016, 3:28 PM

Doesn't html need to be a JQuery object? data is only string.

Smalyshev moved this task from All WDQS-related tasks to GUI on the Wikidata-Query-Service board.

@Jonas do you have an idea how to test this change?
I have set up a vagrant test instance at wmflabs
http://wikidata-math-de.wmflabs.org/wiki/Q15
But the information at https://github.com/wikimedia/wikidata-query-gui is quite brief;-)

Thanks for your pull request, but this is just a mirror, please submit your patch here:
https://gerrit.wikimedia.org/r/#/admin/projects/wikidata/query/gui

Just checkout the repo and open index.html that's it.

Jonas renamed this task from Wikidata label service should render math to Render math markup in query service.Jul 20 2016, 4:21 PM
Jonas updated the task description. (Show Details)

Change 300055 had a related patch set uploaded (by Physikerwelt):
Display MathML in the table view

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

^^ the patch above works for me

Jonas closed this task as Resolved.Jul 20 2016, 4:30 PM
Jonas moved this task from Proposed to Done on the Wikidata-Sprint-2016-07-19 board.

Change 300055 merged by jenkins-bot:
Display MathML in the table view

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

We have a test instance at wdqs-test.wikidata.org, where we could test things. It runs on Wikidata data so should be good for testing.

There's also role::wdqs role which allows to deploy in labs, but there are a bunch of manual steps - you have to check out WDQS deploy repo manually (scap doesn't work that well in labs IIRC) and then manually load data. Ping me if you need help with that, it's not hard but needs some manual steps now.

Change 300074 had a related patch set uploaded (by Smalyshev):
Merging from 3df1df468a66a22996e4b75d4826f81056997647:

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

Smalyshev reopened this task as Open.Jul 20 2016, 6:44 PM
Smalyshev triaged this task as Medium priority.
Smalyshev closed this task as Resolved.Jul 20 2016, 6:49 PM

Ah, it works for me now - meaning it displays something like:

{\displaystyle x:y:z\longrightarrow x^{-1}:y^{-1}:z^{-1}}

Is this how it's supposed to work?

Smalyshev added a comment.EditedJul 20 2016, 6:53 PM

Oh, cool. Looks like it's my browser that is missing math... I don't see it in Chrome, but Safari works just fine. Great then. Will be deployed on production next deployment window (Monday).

Unfortunately only works in some browsers:
http://caniuse.com/#search=mathml

On Wikidata.org we have png fallback for this, I am not sure if it is necessary here.

It's still an improvement for some browsers, but a PNG fallback would be nice I think.

what about using KaTeX or MathJax instead of PNG fallback ?
https://github.com/Khan/KaTeX
https://www.mathjax.org/

Lydia_Pintscher moved this task from incoming to in progress on the Wikidata board.Aug 2 2016, 9:00 AM