mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +00:00
Link wikidata items to math tags
Adds a parameter that links individual formulae to their respective wikidata items. Bug: T71424 Change-Id: I32cfe2039e62f163fe3aebaf77bafbdd84b343c6
This commit is contained in:
parent
b6cf2e7c02
commit
2699479827
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue