Merge "Link wikidata items to math tags"

This commit is contained in:
jenkins-bot 2018-11-12 13:18:21 +00:00 committed by Gerrit Code Review
commit 954b37599a
2 changed files with 16 additions and 0 deletions

View File

@ -480,6 +480,9 @@ class MathMathML extends MathRenderer {
if ( $this->getID() !== '' ) {
$attribs['id'] = $this->getID();
}
if ( isset( $this->params['qid'] ) && preg_match( '/Q\d+/', $this->params['qid'] ) ) {
$attribs['data-qid'] = $this->params['qid'];
}
$output = Html::openElement( $element, $attribs );
// MathML has to be wrapped into a div or span in order to be able to hide it.
// Remove displayStyle attributes set by the MathML converter

View File

@ -260,6 +260,19 @@ class MathMathMLTest extends MediaWikiTestCase {
->with( 'math-tracking-category-mhchem-deprecation' );
$renderer->addTrackingCategories( $parser );
}
public function testGetHtmlOutputQID() {
$math = new MathMathML( "a+b", [ "qid" => "Q123" ] );
$out = $math->getHtmlOutput();
$this->assertContains( "data-qid=\"Q123\"", $out );
}
public function testGetHtmlOutputInvalidQID() {
// test with not valid ID. An ID must match /Q\d+/
$math = new MathMathML( "a+b", [ "qid" => "123" ] );
$out = $math->getHtmlOutput();
$this->assertNotContains( "data-qid", $out );
}
}
/**