Math/ 0000755 0001746 0001746 00000000000 12727636110 011720 5 ustar extdist extdist Math/Makefile 0000644 0001746 0001746 00000000217 12727636110 013360 0 ustar extdist extdist DIRS = texvc texvccheck
.PHONY: all
all: texvc texvccheck
texvc:
cd math; $(MAKE) $(MFLAGS)
texvccheck:
cd texvccheck; $(MAKE) $(MFLAGS)
Math/Math.php 0000644 0001746 0001746 00000001172 12727636110 013323 0 ustar extdist extdist inputTeX );
}
switch ( $texvcStatus ) {
case 'E':
$errMsg = $errorRenderer->getError( 'math_lexing_error' );
break;
case 'S':
$errMsg = $errorRenderer->getError( 'math_syntax_error' );
break;
case 'F':
$errMsg = $errorRenderer->getError( 'math_unknown_function', $errDetails );
break;
default:
$errMsg = $errorRenderer->getError( 'math_unknown_error' );
}
return $errMsg;
}
/**
* @return boolean
*/
public function isValid() {
$us = $this;
$checkWork = new PoolCounterWorkViaCallback( 'MathTexvc-check', "", [
'doWork' => function() use ( $us ) {
return $us->doValidCheck();
}
] );
return $checkWork->execute();
}
/**
* @return boolean
*/
public function doValidCheck() {
global $wgMathTexvcCheckExecutable;
if ( $wgMathTexvcCheckExecutable === false ){
$texvcCheckExecutable = __DIR__ . '/texvccheck/texvccheck';
} else {
$texvcCheckExecutable = $wgMathTexvcCheckExecutable;
}
if ( !is_executable( $texvcCheckExecutable ) ) {
$msg = 'Missing "texvccheck" executable. Please see math/README to configure.';
trigger_error( $msg, E_USER_NOTICE );
LoggerFactory::getInstance( 'Math' )->error( $msg );
return true;
}
$cmd = $texvcCheckExecutable . ' ' . wfEscapeShellArg( $this->inputTeX );
if ( wfIsWindows() ) {
# Invoke it within cygwin sh, because texvc expects sh features in its default shell
$cmd = 'sh -c ' . wfEscapeShellArg( $cmd );
}
LoggerFactory::getInstance( 'Math' )->debug( "TeX check command: $cmd" );
$contents = wfShellExec( $cmd );
LoggerFactory::getInstance( 'Math' )->debug( "TeX check result: $contents\n---" );
if ( strlen( $contents ) === 0 ) {
LoggerFactory::getInstance( 'Math' )->warning( 'TeX check output was empty.' );
$this->lastError = $this->convertTexvcError( $contents );
return false;
}
$retval = substr( $contents, 0, 1 );
if ( $retval !== '+' ) {
$this->lastError = $this->convertTexvcError( $contents );
LoggerFactory::getInstance( 'Math' )->warning( 'checkTex failed: ' . $this->lastError );
return false;
} else {
$this->validTeX = substr( $contents, 1 );
$this->isValid = true;
LoggerFactory::getInstance( 'Math' )->debug(
'checkTex successful tex is now: ' . $this->validTeX );
return true;
}
}
}
Math/Rakefile 0000644 0001746 0001746 00000001001 12727636110 013355 0 ustar extdist extdist require 'bundler/setup'
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |task|
# if you use mediawiki-vagrant, rubocop will by default use it's .rubocop.yml
# the next line makes it explicit that you want .rubocop.yml from the directory
# where `bundle exec rake` is executed
task.options = ['-c', '.rubocop.yml']
end
require 'mediawiki_selenium/rake_task'
MediawikiSelenium::RakeTask.new
task default: [:test]
desc 'Run all build/tests commands (CI entry point)'
task test: [:rubocop]
Math/MathWikidataHook.php 0000644 0001746 0001746 00000004574 12727636110 015633 0 ustar extdist extdist 'string',
'validator-factory-callback' => function() {
// load validator builders
$factory = WikibaseRepo::getDefaultValidatorBuilders();
// initialize an array with string validators
// returns an array of validators
// that add basic string validation such as preventing empty strings
$validators = $factory->buildStringValidators();
$validators[] = new MathValidator();
return $validators;
},
'parser-factory-callback' => function( ParserOptions $options ) {
$repo = WikibaseRepo::getDefaultInstance();
$normalizer = new WikibaseStringValueNormalizer( $repo->getStringNormalizer() );
return new StringParser( $normalizer );
},
'formatter-factory-callback' => function( $format, FormatterOptions $options ) {
global $wgOut;
$styles = [ 'ext.math.desktop.styles', 'ext.math.scripts', 'ext.math.styles' ];
$wgOut->addModuleStyles( $styles );
return new MathFormatter( $format );
},
'rdf-builder-factory-callback' => function (
$mode,
RdfVocabulary $vocab,
RdfWriter $writer,
EntityMentionListener $tracker,
DedupeBag $dedupe
) {
return new MathMLRdfBuilder();
},
];
}
/*
* Add Datatype "Math" to the Wikibase Client
*/
public static function onWikibaseClientDataTypes( array &$dataTypeDefinitions ) {
global $wgMathEnableWikibaseDataType;
if ( !$wgMathEnableWikibaseDataType ) {
return;
}
$dataTypeDefinitions['PT:math'] = [
'value-type' => 'string',
'formatter-factory-callback' => function( $format, FormatterOptions $options ) {
global $wgOut;
$styles = [ 'ext.math.desktop.styles', 'ext.math.scripts', 'ext.math.styles' ];
$wgOut->addModuleStyles( $styles );
return new MathFormatter( $format );
},
];
}
}
Math/modules/ 0000755 0001746 0001746 00000000000 12727636110 013370 5 ustar extdist extdist Math/modules/ext.math.js 0000644 0001746 0001746 00000003102 12727636110 015452 0 ustar extdist extdist ( function ( $ ) {
'use strict';
var img, url;
function insertImg( png ) {
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).each( function ( ) {
// Create a new image to use as the fallback.
img = document.createElement( 'img' );
url = this.style.backgroundImage.match( /url\(\s*(['"]?)([^\1\)]*)\1\s*\)/ )[ 2 ];
if ( png ) {
url = url.replace( 'media/math/render/svg/', 'media/math/render/png/' );
}
img.setAttribute( 'src', url );
img.setAttribute( 'class', 'tex mwe-math-fallback-image-' + ( $( this ).hasClass( 'mwe-math-fallback-image-inline' ) ? 'inline' : 'display' ) );
img.setAttribute( 'aria-hidden', 'true' );
this.parentNode.insertBefore( img, this );
// Hide the old SVG fallback.
$( this ).css( 'display', 'none' );
} );
}
// If MathPlayer is installed we show the MathML rendering.
if ( navigator.userAgent.indexOf( 'MathPlayer' ) > -1 ) {
$( '.mwe-math-mathml-a11y' ).removeClass( 'mwe-math-mathml-a11y' );
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).css( 'display', 'none' );
return;
}
// We verify whether SVG as
is supported and otherwise use the
// PNG fallback. See https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js
if ( !document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) {
insertImg( true );
} else if ( $.client.profile().name.match( /msie|edge/ ) ) {
// For all IE versions the meta tags are rendered blurry, while img tags are rendered fine.
insertImg( false );
}
}( jQuery ) );
Math/modules/ext.math.css 0000644 0001746 0001746 00000002733 12727636110 015637 0 ustar extdist extdist /*
* Document : ext.math
* Created on : 23.09.2013, 13:55:00
* Author : Physikerwelt (Moritz Schubotz)
* Description: Shows browser-dependent math output.
*/
@namespace m url('http://www.w3.org/1998/Math/MathML');
/* Default style for MathML. */
.mwe-math-mathml-inline { display: inline !important; }
.mwe-math-mathml-display { display: block !important; margin-left: auto; margin-right: auto; }
.mwe-math-mathml-a11y {
/* We try to hide the MathML formula in a way that still makes it accessible to accessibility tools. */
clip: rect(1px, 1px, 1px, 1px);
overflow: hidden;
position: absolute;
width: 1px;
height: 1px;
opacity: 0;
}
m|math {
/* Try some popular OpenType MATH fonts before the WOFF fallback */
font-family: Cambria Math, Latin Modern Math, STIX Math, LatinModernMathWOFF, serif;
}
/* Default style for the image fallback. */
/* Note: We had to use !important rules because of conflicts with the style
generated by Mathoid. See https://gerrit.wikimedia.org/r/#/c/166213/ */
.mwe-math-fallback-image-inline { display: inline-block; vertical-align: middle; }
.mwe-math-fallback-image-display { display: block; margin-left: auto !important; margin-right: auto !important; }
/* Default style for the source fallback. */
.mwe-math-fallback-source-inline { display: inline; vertical-align: middle; }
.mwe-math-fallback-source-display { display: block; margin-left: auto; margin-right: auto; }
/* PNG related styles from core */
img.tex {
vertical-align: middle;
}
Math/modules/LatinModern/ 0000755 0001746 0001746 00000000000 12727636110 015604 5 ustar extdist extdist Math/modules/LatinModern/GUST-FONT-LICENSE.txt 0000644 0001746 0001746 00000002660 12727636110 020757 0 ustar extdist extdist % This is a preliminary version (2006-09-30), barring acceptance from
% the LaTeX Project Team and other feedback, of the GUST Font License.
% (GUST is the Polish TeX Users Group, http://www.gust.org.pl)
%
% For the most recent version of this license see
% http://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
% or
% http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt
%
% This work may be distributed and/or modified under the conditions
% of the LaTeX Project Public License, either version 1.3c of this
% license or (at your option) any later version.
%
% Please also observe the following clause:
% 1) it is requested, but not legally required, that derived works be
% distributed only after changing the names of the fonts comprising this
% work and given in an accompanying "manifest", and that the
% files comprising the Work, as listed in the manifest, also be given
% new names. Any exceptions to this request are also given in the
% manifest.
%
% We recommend the manifest be given in a separate file named
% MANIFEST-.txt, where is some unique identification
% of the font family. If a separate "readme" file accompanies the Work,
% we recommend a name of the form README-.txt.
%
% The latest version of the LaTeX Project Public License is in
% http://www.latex-project.org/lppl.txt and version 1.3c or later
% is part of all distributions of LaTeX version 2006/05/20 or later.
Math/modules/LatinModern/latinmodern-math.woff 0000644 0001746 0001746 00001660304 12727636110 021744 0 ustar extdist extdist wOFFOTTO ` 2( CFF * gZFFTM p6GDEF 'GPOS mtGSUB B iMATH 0 bBOS/2 V `nocmap % DC head D 3 6_>hhea x ! $hmtx <