Commit graph

52 commits

Author SHA1 Message Date
Chad Horohoe 0404113641 Remove obvious function-level profiling
Change-Id: I41d48da124e38c46ce71aa9d3b756096a424df1c
2015-02-12 12:14:24 -08:00
Timo Tijhof 83da0338ec Minor clean up, optimisations and documentation corrections
* Handle-error-first approach for consistent function body
  termination at the root with the main intend, and less indention.

* __DIR__ instead of dirname( __FILE__ )

* Single quotes.

* Correct pickHost documentation: wgMathMathMLUrl is not an array,
  and is not used in this method, that's at a different level
  of abstraction (via the constructor).

* White spacing.

* require_once is not a function.

Change-Id: Id4bec8415893245e2569a39ab5406a0820238ae4
2015-01-22 10:56:16 -08:00
physikerwelt (Moritz Schubotz) c240a5c477 Remove unused global
Change-Id: I8f5f77015de266f5a5b751fd7cfe424784eb3864
2015-01-13 20:15:52 +00:00
Ori Livneh d9b9b06032 MWException -> Exception
Change-Id: I18da1baeb70387b96e30811a049185a264dec26d
2015-01-09 17:55:54 -08:00
physikerwelt (Moritz Schubotz) d9522b6049 Increase size of the math_mathml in the mathlatexml table
The type text allows text with maximum length of 64k only. Since the
MathML generated by LaTeXML is quite verbose this is too small for
some equations used at Wikipedia.

Bug: 73090
Change-Id: Id09ec6201f68efe63a439f6e85a53876d5c1e521
2014-11-18 12:42:27 +01:00
Frédéric Wang e26d641b85 Make MathML mode work on mobile devices
- load ext.math.css on mobile devices
- move the @font-face rules for the Latin Modern WOFF fonts into a separate
  Desktop-only stylesheet.

Change-Id: Ifca3679185a4675bc31dff99a086fef740b9dab5
2014-10-20 22:40:53 +02:00
Gabriel Wicke c61b8becac Use radio buttons only for math mode selection
While the combination of all redering modes, might
be useful for some power users it will confuse the
average user and makes bug reporting harder.

Therefore, source rendering on the server side is
used when MathJax is enabled on the client side.

Change-Id: I05a20d7c2298115dbf0429db6c107e8132cc15ff
2014-10-13 09:42:37 +02:00
Frédéric Wang 296c79e070 Rename fallback-svg and fallback-png to fallback-image
- Merge fallback-svg and fallback-png into one fallback-image class.
- Move the vertical centering of PNG to MathTexvc and ext.math.js.
- Remove "img" from ext.math.css to reduce CSS specificity and make
  style easier to override by user stylesheets.
- Add a comment about the !important rules for centering in
  display mode.
- Only load ext.math.scripts in MathML mode.

Bug: 71955
Change-Id: If8ee1cf6453257a0a2f6aa186d4007954a8e5d8e
2014-10-12 13:42:01 +02:00
physikerwelt (Moritz Schubotz) ccc4114812 Fine grained options for wgMathDisableTeXFilter
Add new option to filter only new input.
Now the complete list of possible settings is:
MW_MATH_CHECK_ALWAYS  backwards compatible to false
MW_MATH_CHECK_NEVER   backwards compatible to true
MW_MATH_CHECK_NEW     new option

Change-Id: I455b41c8b8d918f4c34f6c115194d227a8394e0a
2014-10-10 18:27:04 +00:00
Frédéric Wang c3894c2c49 Display MathML when MathPlayer is installed
When MathPlayer is installed, we show the MathML instead of the SVG fallback.
This will in particular allow the sync highlighting feature of MathPlayer.
This also introduces a module ext.math.js that could be used to do some
Javascript postprocessing.

Bug: 71748
Change-Id: I438a20032c312d12321ca4c5686bcfd107656b37
2014-10-10 20:20:47 +02:00
physikerwelt (Moritz Schubotz) 68f9e96240 Add new MathHook
* Adds a new hook that is called after the rendering
  this is required to keep the MathIndex up to date
  for the MathSearch extension.
* The hook can be used for special modifications of
  the output format.

Change-Id: I7b45b4398c10ffe75f481a82c149ba4f66820338
2014-07-23 16:09:21 +00:00
physikerwelt 65642489ae Separate render and getHtml
Currently the method render always returns
a html string that can be a string that
represents the correct result or a rendered
error message.
This change splits rendering and
fetching of the HTML output.
This simplifies the logic of the rendering
and caching mechanism.
Now the render method returns a boolean that
indicates if the rendering was sucessful or
not.

Step 2/2

Warning: Errors in this change might affect
caching logic and squid caches.

Change-Id: I00502b84212ed70cdf63bd69916a35afbd6fdbc1
2014-06-09 23:21:44 +02:00
physikerwelt 4ca287b43a Improve MathML error handling
This change improves the error handling for MathML.

* Make MathHooks::getMathNames public
* Allow to use the same error messages for LaTeXML and Mathoid
* unify the string delimiter in error messages to "

Change-Id: I6568e6a3c98cb008f45f887d42e446daafe0ed3c
2014-06-04 07:38:48 +00:00
physikerwelt 3cbb5225e3 Add separate database tables for Mathoid
Add the tables needed for Mathoid.

Bug: 65793
Change-Id: Ia8dcb11234dffb7bce67f9ca0e7ebf1279fd7620
2014-05-27 06:53:50 +00:00
physikerwelt 972cee0f98 Add separate database table for LaTeXML (step 2)
Currently the PNG and the LaTeXML rendering mode
use a common table in the database. If both rendering
modes are allowed in a wiki simultaneously this causes
problems, because the fields are continuously overwritten.

This change creates the new database table defined in step 1.

Bug: 65522
Change-Id: I5f125d36b83776ca6f75ff014dc9095d0a737a35
2014-05-21 17:23:42 +00:00
physikerwelt ed570661de Improve mathtable
* Add primary key to mathtable
* Unify naming of database files

Bug: 65525
Change-Id: I4f4d31c281257014734e9e3a8d7f1506855ea6d9
2014-05-21 08:48:34 +00:00
physikerwelt bb9edf4f7a Catch misconfiguration of math default option
If the LocalSettings.php has invalid settings
for $wgDefaultUserOptions['math']
and $wgValidMathModes the user prefrences
pages displays an error. This commit
catches this error and selects the first
rendering option availible.

Bug: 64844
Change-Id: I1e3c468c0dc92378f7dc7b7d81fb4693e70f6b6f
2014-05-06 11:59:02 +00:00
James D. Forrester 60411b9a9f Convert VisualEditor Beta Feature to a normal (non-optional) plugin
Change-Id: I0dd1c85ad92d7e42654e23b6237b30f8f4dfe0fa
2014-04-29 13:34:40 -07:00
Moritz Schubotz (Physikerwelt) 58f913ecb0 $wgMathValidModes and orthogonal MathJax enabler
To adjust the selectable math rendering modes in user preferences $wgMathValidModes
is introduced.

* $wgUseLaTeXML becomes unnecessary use $wgMathValidModes[] = MW_MATH_LATEXML;
  to enable the LaTeXML rendering mode
* add $wgMathValidModes[] = MW_MATH_MATHJAX; to enable MathJax

Currently, MathJax is bound to the MW_MATH_SOURCE rendering mode.
This change makes the base mode user configurable.
That means before MathJax is loaded the png fallback image could
be displayed.

ATTENTION: This change modifies global variables as follows:
* MW_MATH_MATHJAX is deprecated.

Bug: 57981
Change-Id: Ibf705cb66754d04e4c7eafd1e98608b25d7dbb94
2014-04-08 15:29:42 +00:00
jenkins-bot 90d7783e8e Merge "remove armourMath and wgContLang (bug 60799)" 2014-04-08 11:16:23 +00:00
physikerwelt fcd542c2c5 remove armourMath and wgContLang (bug 60799)
* armourMath is no longer needed

Bug: 60799

Change-Id: I1134d34d403b527821a1f7ccd370e78cf6197d71
(cherry picked from commit 2c555baf4f)
2014-04-07 15:02:18 +00:00
Derk-Jan Hartman c787eb34e7 Move betafeatures images into the images dir.
It's not really nice to have this lying around in the root of the
extension. Even if it's for beta, better to use a proper subdir, so the
directory is somewhat 'readable'

Change-Id: Ib6e6b27b2169626a4f9028fa0f772bbdab16a40c
2014-04-07 14:41:09 +02:00
jenkins-bot ea48a4442f Merge "Editbutton for math" 2014-04-07 09:33:56 +00:00
Moritz Schubotz 9f7a1e51c4 Editbutton for math
Move the code that creates the Editbutton for math from core,
where it is removed in Ib17aa47c7d647e1ed293541adbdd1aa77e25e59e.

Imported button image from:
ssh://gerrit.wikimedia.org:29418/mediawiki/core.git/skins/common/button_math.png

We don't need to vary the icon per language, because there is not a
single language that has a non default icon.

Bug: 60471
Change-Id: I3d126c1c252c27fa65ab8fb42ffab66a2d99cfa8
2014-04-07 09:26:16 +00:00
Moritz Schubotz (Physikerwelt) c5b0b15d8f Fix MathJax centers equations
* Removes the MathJax heuristics that decides
  if equations are centered or left-aligned.
* Introduces the attribute display to specify
  if the math element is rendered in inline,
  display, or inline-displaystyle.
* add css rules for display / inline math images

Bug: 61051
Change-Id: Iba69903f781f0cb1606b8ddcffb90fb86c9b229b
2014-04-06 21:58:30 +00:00
Roan Kattouw fcf045f832 Add VisualEditor support
Moved from the VisualEditor extension, where it was removed in Iab0c56246626de1e0f

Change-Id: I8e582ee6deadc2750d30b49f0c6de31ed9c16a50
2014-03-20 01:29:25 +00:00
physikerwelt 94b035b26a Coverage tests for the Math extension
* Include generated tests for a better test coverage
of the Math extension.
* Compiles texvc in testsuite (if required)
* Test generator now included
* Replaces the old parser tests
* Fixes whitspace issues

Bug: 61090
Change-Id: Iff7eeb5ee72137492c3f6659e4d4d106e5715586
2014-03-11 15:35:07 +00:00
physikerwelt 52d206c4b4 Remove call to deprecated ParserOptions::getMath
Since math has been moved from core to an extension
it should take care of the caching by its own.
Therefore, a call to the parserOptions::getMath is removed
and own caching logic is introduced, once getMath is removed
from core.

Bug: 14202
Change-Id: Ifa847b61264f8d640c9886fd374eb3d6cf482c0c
2014-01-29 09:10:05 +00:00
physikerwelt 6a0af8f3b4 Validate TeX input for all renderers, not just texvc
The user input specified in the math tag a. la
<math>E=m <script>alert('attacked')</script>^2 </math>
is verified in PNG rendering mode, but not in plaintext, MathJax
or LaTeXML rendering mode. This is a potential security issue.

Furthermore, the texvc specific commands such as $\reals$
that is expanded to $\mathbb{R}$ might be rendered differently
depended on the rendering mode.

Therefore, the security checking and rewriting portion of texvc
have been extracted from the texvc source
(see I1650e6ec2ccefff6335fbc36bbe8ca8f59db0faa) and are
now available as a separate executable (texvccheck).

This commit will now enable this enhancement in security and
provide even more compatibility among the different rendering
modes.

Bug: 49169
Change-Id: Ida24b6bf339508753bed40d2e218c4a5b7fe7d0c
2014-01-22 10:07:27 +00:00
Reedy 9af76a77eb Remove db2 support, core MW did this a while ago
Change-Id: I78124660e7bad31c81726e8723d73ce92af42e4d
2014-01-02 15:13:45 +00:00
Max Semenik 4d68c31de1 Add profiling
Change-Id: I9066f6b2606044412a9b91ca395e841550d7e787
2013-11-18 14:46:00 +04:00
physikerwelt 927340d345 New rendering option LaTeXML
Introduces a new rending option to render TeX to MathML
via LaTeXML.

Bug: 43222
Change-Id: I5d29e219c0d3b907e22ea0bb3b30f000d8a7a9f8
2013-05-26 12:12:51 +00:00
physikerwelt b6faed7363 remove unused code
This code is never used and will not be used in the future.
Adressing the equation for search will be handled by the
MathSearch extension. There will be a hook function to label
the equations.

Change-Id: Ia2149460134b361fb44f8ad85660793b1951d988
2013-04-26 14:17:37 +00:00
Matthew Flaschen aa8a0eaf19 Write cache unless there *is* a cache hit:
Moves writeCache call back to hooks (changed in 9ba4ef269d)
 and makes it unconditional, so only one part of the code decides
whether to write to the cache.

Bug: 45973
Change-Id: I6b387795304ff15c960fcf0f5354a9ac939e1212
2013-03-12 00:38:45 -04:00
Ori Livneh 9ba4ef269d Only update the cache on cache miss
Change I9b1d68c4faa8d177d8d0088fa1a5879caed4f1fe added an indiscriminant call
to writeCache(). I assume that it was supposed to be regulated by the check for
$this->isRecall() (which is a getter for '$this->recall'), but there was no
concomitant change to ensure that recall is set true on cache hits.

My fix does not set recall to true. The style of "pass-by-attribute" is tricky
and should be factored out by a subsequent change. This change moves the call
to writeCache() so that it is only called on cache miss.

Change-Id: I9b690e55001859c97fd40330272791d49ec6de75
2013-02-21 17:39:17 -08:00
Moritz Schubortz c869831f45 Add and register PHP unit tests for MathSource class
This change adds test cases for the MathSource class and registers a
hook for loading these tests. Also adds documentation about how to run
these tests in README.

Change-Id: Ie58a273326e0353dfa4437b3de21a2393adb5a87
2013-02-17 20:23:50 +00:00
Physikerwelt 926db7c3bd Restructuring Math classes
The Math.body file which contains the MathRender class was split in the following way:
- Math.base contains the base class with the database related stuff and provides an abstract interface
- Math.source and Math.MathJax handle the plain tex string output. There are two classes since they
  will differntiate in the future I think.
- Math.texvc contains the "old" implementation of png generation with all the file handling related stuff
- Other implementation of math renderer can be added in the same style.
- Cleanup to better follow coding conventions.
- Changed LockManager to 'fsLockManager'

The first attempt restructure the class layout and introduce LaTeXML at the same
time was dropped. Instead this was split up into two phases.
This commit only deals about the restructuring of the math module design.

Change-Id: I9b1d68c4faa8d177d8d0088fa1a5879caed4f1fe
2013-02-07 20:35:45 -08:00
Siebrand Mazeland 22a09c87d3 Replace remaining wfMsg* call.
Also remove some trailing whitespace.

Change-Id: Ic7a706a894dd07ca638173f2fc6e1695a05f914b
2012-10-04 19:42:13 +02:00
Siebrand Mazeland 7b2b7301e0 Maintenance for Math extension.
* Replace deprecated wfMsg* calls with alternatives.
* Add FIXME for occurrence I don't know how to replace.
* Update some docs.
* Sprinkle a few semi-colons over the JavaScript.

Change-Id: I755a95f8bba48a23ef8c432e232adfaef4caae70
2012-08-31 01:25:48 +02:00
Brion Vibber 829372f32d update copyright notice years for 2012 2012-03-05 22:25:09 +00:00
Brion Vibber 2af7057b05 Set up MathJax as a selectable option in math preferences 2012-03-05 20:34:29 +00:00
Brion Vibber a36b0e04d8 Initial experimental import of MathJax source into Math extension as a client-side rendering supplement to the PNG rendering.
* Pulled in MathJax 1.1 (minus the 112 megabytes of PNG "fonts")
* Pulled in some of <https://en.wikipedia.org/wiki/User:Nageh/mathJax> bits for initialization

This doesn't currently override PNG images, but does replace the text-form if you configure it.
2011-12-06 01:17:35 +00:00
Brion Vibber 1042006fd4 Experimental option $wgMathUseMathJax to have Extension:Math load things via MathJax.
If enabled, by default loads MathJax from a CDN and forces all equations through MathJax when JavaScript is available -- the image or source form gets used only as <noscript> fallback.

This has a couple of problems for us:
* if scripts are missing -- such as when viewed via MobileFrontend -- you end up with no math at all, as the <script type="math/tex"> bits get ignored but the <noscript> still hides the images.
* while MathJax is loading things, blank spots on the page may appear and stuff jumps around
* if loading new text in via ajax, it doesn't trigger there

Also using some fairly default config, no idea how appropriate it is. Hoping to get some insight from Nageh who's done some of the MathJax work on Wikipedia so far - <https://en.wikipedia.org/wiki/User_talk:Nageh#MathJax_integration_into_stock_MediaWiki>
2011-11-29 00:37:13 +00:00
Brion Vibber 09679f2f39 Disable the partial HTML and MathML rendering options for Math extension.
MathML mode was so incomplete most people thought it simply didn't work (bug 25646).
HTML modes often rendered poorly (eg req bug 24207 to set default to PNG on some sites)

This may cause regressions in that simple "equations" of just variables that came out as HTML
will now render as PNGs that don't get aligned properly with the text baseline. Fixing this is
covered by bug 32694: <https://bugzilla.wikimedia.org/show_bug.cgi?id=32694> to retrieve the
baseline info from dvipng and position images to fit.

Note that because of the way user options are pulled in to the oarser cache key, some folks
may see cached pages with their old settings until they get redone or they save their prefs
again and have it normalized.
2011-11-28 22:30:33 +00:00
Brion Vibber 6d5b5679fd Followup r97001: fix for Math parser tests image URLs
Setting $wgMathPath to a fixed value during parser test runs so the values are predictable.
2011-09-13 21:03:38 +00:00
Sam Reed 0af538dbbe Improve documentation, remove unused global 2011-07-17 21:11:24 +00:00
Chad Horohoe 2d20c56bb7 Get rid of addNewExtension()/getNewExtensions() method of adding new extensions (added in r81266). Since r85021, this isn't necessary because we run old updates like we should. Fix the 3 extensions using it. Reverts most of r81266, all of r84868, tiny part of r86741. Also ping r89653 which is what caused me to look at this again. 2011-06-07 17:33:34 +00:00
Brian Wolff b75a2171f1 Make the onParserTestTables method static, since the hook is called statically.
Fixes: Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method MathHooks::onParserTestTables() should not be called statically in /var/www/w/phase3/includes/Hooks.php on line 235
2011-05-23 17:05:39 +00:00
Brion Vibber d61409f974 Breaking the 'math' table setup out to Math extension. Should be the last main step in extension-ification of the math options!
The 'math' table will no longer be created on a default install unless you've explicitly enabled the Math plugin at install time; the usual update.php procedure will add it in.

Postgres, Oracle, MSSQL, and DB2 variants are included -- broken out from the core files -- but have not been tested.

I know there has been some code duplication in parser test infrastructure but could only find one instance of the parser test temporary table setup to remove the 'math' table from (the extension adds it back via the hook). If the phpunit-based runner breaks, please track it down and fix it there too.
2011-04-22 21:37:16 +00:00
Brion Vibber 9a767a671a Followup to r85706 and friends: now that Math messages have been moved to extension, move out the settings list and constants.
* MW_MATH_* constants are now defined in Math extension
* Language::getMathNames() is removed
* mathNames section in message files is removed
* A hardcoded preference override in refreshLinks moved to MaintenanceRefreshLinksInit hook
2011-04-09 19:57:35 +00:00