Physikerwelt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/172540
Change subject: Uniform naming of Math anchors
......................................................................
Uniform naming of Math anchors
Change-Id: I64b69aba6d479d020d5b2a219405ea011c24ed7f
---
M FormulaInfo.php
M MathEngineBaseX.php
M MathQueryObject.php
M MathSearch.hooks.php
M SpecialUploadResult.php
M maintenance/CreateBaseXMathTable.php
M maintenance/CreateMWSHarvest.php
7 files changed, 16 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch
refs/changes/40/172540/1
diff --git a/FormulaInfo.php b/FormulaInfo.php
index b57a89d..fffe20e 100644
--- a/FormulaInfo.php
+++ b/FormulaInfo.php
@@ -100,7 +100,6 @@
$mo->findSimilarPages( $pid );
$out->addWikiText( '==Variables==' );
$mo->getObservations();
- // $wgOut->addWikiText( "[[$pagename#math$eid|Eq: $eid]] ",
false );
$out->addWikiText( '==MathML==' );
$out->addHtml( "<br />" );
diff --git a/MathEngineBaseX.php b/MathEngineBaseX.php
index 48ea045..6e64590 100644
--- a/MathEngineBaseX.php
+++ b/MathEngineBaseX.php
@@ -65,6 +65,7 @@
$this->relevanceMap = array();
$this->resultSet = array();
if( $res ){
+ //TODO: ReEvaluate the regexp.
$baseXRegExp = "/<a .*?
href=\"http.*?curid=(\d+)#math(\d?)\"/";
preg_match_all( $baseXRegExp , $res,
$matches,PREG_SET_ORDER);
foreach($matches as $match){
diff --git a/MathQueryObject.php b/MathQueryObject.php
index d05b2bc..6eca335 100644
--- a/MathQueryObject.php
+++ b/MathQueryObject.php
@@ -58,11 +58,12 @@
$this->queryID = $id;
}
- public function exportTexDocument(){
- $texInput = htmlspecialchars( $this->getUserInputTex());
- $texInputComment = preg_replace("/[\n\r]/","\n%",$texInput);
+ public function exportTexDocument() {
+ $texInput = htmlspecialchars( $this->getUserInputTex() );
+ $texInputComment = preg_replace( "/[\n\r]/", "\n%", $texInput );
$title = Title::newFromId( $this->getPageID() );
- $absUrl =
$title->getFullURL(array("oldid"=>$title->getLatestRevID()))."#math{$this->getAnchorID()}";
+ $absUrl = $title->getFullURL( array( "oldid" =>
$title->getLatestRevID() ) ) .
+ MathSearchHooks::generateMathAnchorString(
$title->getLatestRevID(), $this->getAnchorID() );
return <<<TeX
\begin{topic}{{$this->getPageTitle()}-{$this->getAnchorID()}}
\begin{fquery}\${$this->getTeXQuery()}\$\end{fquery}
diff --git a/MathSearch.hooks.php b/MathSearch.hooks.php
index cab93d8..60d99b3 100644
--- a/MathSearch.hooks.php
+++ b/MathSearch.hooks.php
@@ -12,6 +12,7 @@
* LoadExtensionSchemaUpdates handler; set up math table on
install/upgrade.
*
* @param $updater DatabaseUpdater
+ * @throws MWException
* @return bool
*/
static function onLoadExtensionSchemaUpdates( $updater = null ) {
@@ -206,7 +207,7 @@
if ( preg_match( '#<math(.*)?\sid="(?P<id>[\w\.]+)"#', $Result,
$matches ) ) {
$rendererId = $matches['id'];
$oldId = self::curId2OldId( $pid );
- $newID = "math.${oldId}.${eid}";
+ $newID = self::generateMathAnchorString($oldId,$eid);
$Result = str_replace( $rendererId, $newID, $Result );
}
return true;
@@ -223,4 +224,8 @@
$files = array_merge( $files, glob( "$testDir/*Test.php" ) );
return true;
}
+
+ static function generateMathAnchorString($pageID, $anchorID){
+ return "#math.$pageID.$anchorID";
+ }
}
diff --git a/SpecialUploadResult.php b/SpecialUploadResult.php
index 49ac58d..e4bd25d 100644
--- a/SpecialUploadResult.php
+++ b/SpecialUploadResult.php
@@ -180,7 +180,7 @@
} else {
$renderedMath = $md5;
}
- $formulaId = "math.{$row['oldId']}.{$row['fId']}";
+ $formulaId =
MathSearchHooks::generateMathAnchorString($row['oldId'],$row['fId']);;
$link=Revision::newFromId( $row['oldId']
)->getTitle()->getCanonicalURL()."#$formulaId";
$this->getOutput()->addHTML("<tr><td>${row['qId']}</td><td><a
href=\"${link}\">$formulaId</a></td>
<td>${row['rank']}</td><td>$renderedMath</td></tr>");
diff --git a/maintenance/CreateBaseXMathTable.php
b/maintenance/CreateBaseXMathTable.php
index 2124218..6ce615d 100644
--- a/maintenance/CreateBaseXMathTable.php
+++ b/maintenance/CreateBaseXMathTable.php
@@ -58,7 +58,8 @@
libxml_clear_errors();
return "";
}
- $out .= "\n<" . self::$mwsns . "expr url=\"" .
$row->mathindex_page_id . "#math" . $row->mathindex_anchor . "\">\n\t";
+ $out .= "\n<" . self::$mwsns . "expr url=\"" .
+ MathSearchHooks::generateMathAnchorString(
$row->mathindex_page_id, $row->mathindex_anchor ) . "\">\n\t";
$out .= utf8_decode( $row->math_mathml );//
$xml->math->children()->asXML();
$out .= "\n</" . self::$mwsns . "expr>\n";
// TODO: This does not work yet.
diff --git a/maintenance/CreateMWSHarvest.php b/maintenance/CreateMWSHarvest.php
index 97cbbf0..b09933a 100644
--- a/maintenance/CreateMWSHarvest.php
+++ b/maintenance/CreateMWSHarvest.php
@@ -57,7 +57,7 @@
}
// if ( $xml->math ) {
// $smath = $xml->math->semantics-> { 'annotation-xml'
} ->children()->asXML();
- $out .= "\n<" . self::$mwsns . "expr url=\"math." .
$row->mathindex_page_id . "." . $row->mathindex_anchor . "\">\n\t";
+ $out .= "\n<" . self::$mwsns . "expr url=\"" .
MathSearchHooks::generateMathAnchorString($row->mathindex_page_id ,
$row->mathindex_anchor ) ."\">\n\t";
$out .= utf8_decode( $row->math_mathml );//
$xml->math->children()->asXML();
$out .= "\n</" . self::$mwsns . "expr>\n";
return $out;
--
To view, visit https://gerrit.wikimedia.org/r/172540
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I64b69aba6d479d020d5b2a219405ea011c24ed7f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits