Commit graph

59 commits

Author SHA1 Message Date
Moritz Schubotz 349d7cfc16 Use img instead of meta tags for SVGs
* replace meta tag with img tag
* remove js workaround for IE

Bug: T136709
Change-Id: Ifdd75ce51076b098af67a96b5dcb0fc0726d2b00
2016-06-02 12:12:32 +02:00
physikerwelt a5ddbd031d Catch exceptions thrown by restbase
Display the error message on the screen,
but do not throw an exception.
The extension will be available from the error log.

Bug: T134652
Change-Id: I5e88e74df6cd534d138d65251615066bab663368
2016-05-11 02:47:20 -04:00
physikerwelt 6b984122a1 Ensure use of ; to seperate svg styles
It was reported that under certain circumstances a semicolon was
missing from the SVG style.

Bug: T132563
Change-Id: I148433657848fdc74889fcaf6d883078c46a4006
2016-04-21 08:55:21 +00:00
physikerwelt 0d55341ff9 Fix: Convert all array() syntax to []
The signature of the Hook function is not respected.
Thus parameters need to be passed by reference explicitly.
For syntax validation to pass, this requires
mediawiki-codesniffer to 0.6.0

Change-Id: I90b6501000200c1b462407b769113358eb5c762f
2016-04-19 21:41:42 +00:00
physikerwelt 6699724d65 Convert all array() syntax to []
Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Change-Id: I1d2604e3f246ede58ff8245ba2b940f258d2d80c
2016-04-13 10:18:23 -04:00
physikerwelt 2f8c92cb79 Reduce number of Restbase requests
This change reduces the number of Restbase requests to two
by bundling all requests for MathML

Bug: T132096
Change-Id: Idfc29eeeca754738fe78ca0372e6b6725065528d
2016-04-12 15:13:26 +00:00
physikerwelt 9e605e09cd Render all math tags in parallel
Bug: T125543
Change-Id: Ia2febf2c0309e5de514445ad2aad58b7e5ce6837
2016-02-18 02:25:38 +00:00
Umherirrender a810052038 Fix case of Html class
Gives fatal when using $wgAutoloadAttemptLowercase = false

Change-Id: I00069b8b875c5f6c768835a8e072e9eed2541314
2016-02-09 07:35:22 +00:00
physikerwelt 47f530b355 Support for chemical formulae
* Add support for LaTeX package mhchem.
* Add hook <ce>
* Add format <math chem>

See bug description for the details.

Bug: T98306
Change-Id: I2ab80834edc5d071618bc52f133cfb2b7ece5016
2016-02-07 18:55:58 +00:00
physikerwelt c77118d37d Reduce the number or requests sent to Restbase
Currently two post request and one get request is sent
for each formula.
This change gets rid of the second post request.

Change-Id: I805a2c0fa619c9143c38a0cc60e76c9480578ed3
2016-01-29 18:16:05 +01:00
jenkins-bot c900b7bd25 Merge "Ask for the MathML and SVG renders only if the input is valid" 2015-12-14 22:40:38 +00:00
Marko Obrovac 72bdb51be1 Ask for the MathML and SVG renders only if the input is valid
Bug: T121445
Change-Id: I18b1ef4906f98cea99dca21d5a986a79c02cc233
2015-12-14 23:28:40 +01:00
physikerwelt 1ec767791b Make math usable without RESTbase
* Do not contact RESTbase in texvc rendering mode and
  use the well established tex checking that is already build
  into texvc.
* Do not use RESTbase in LaTeXML mode.

Background:
In I1982612e8c6a356e3dbdf447724ac82e5968cc77 RESTbased replaced
texvccheck that was a derivate of texvc designed for people
that wanted to use secure MathML rendering using mathoid.
The integration of mathoid to restbase made this feature obsolete.
However, texvccheck was not only used to check the latex input
that was sent to mathoid, but also the string which was sent to texvc.
Since texvc has already build in tex checking this is not
required and does not improve security.
Finally, users updating from old versions of the math extension
(prior to 2014) that do not have textexvccheck installed,
do not need to compile the texvccheck binary after this change.

PS5: Also treats the case where VisualEditor is not installed.

Bug: T121173
Change-Id: I1bd076b09206869b5ed75280d22e1b36bfb8d8ad
2015-12-11 22:04:12 +01:00
physikerwelt cfdec7e814 Do not cache MathML results in database
* Currently the Math extension stores the rendering result from restbase
  in the database.
* This creates unnecessary write operations on the database

Change-Id: I5f07474fbf8017e39e94ac2b17676db1c3e92e72
2015-12-09 14:18:03 +00:00
physikerwelt 0f8f9cff93 Use Restbase rendering in MathML mode
* For tex input, the only form of Math input that
  is accepted on WMF wikis, we retrieve MathML and SVG
  image from Restbase without using the database cache.

Change-Id: Ief1b6345c17db41f92684e00233d57240e97599f
2015-12-04 17:27:40 +00:00
paladox df8ad1c799 Add php code sniffer to composer
Add support for php code sniffer

Change-Id: I7dcdd88be4f1f8219f71ab770979284761e09bae
2015-09-23 10:46:14 +01:00
physikerwelt f93333686d Fix: Set default MathStyle to inlineDisplaystyle
Redo Ibf6bdbd4ea36b4905445d5878f32f7e0b2bc8bac, which was
reverted by I029328849f05ec2afcabf38d2b79b337cb54cbd5.

In addition this patch simplifies the tex sent to the mathoid
server. Instead of {\displaystyle {\textstyle ... } } only
{\textstyle is sent (which overwrites \displaystyle anyway).

Change-Id: I16d6f67215c2f85ecd1d3a0bddacfc1700681557
2015-08-05 12:35:30 +02:00
physikerwelt (Moritz Schubotz) 248ea7ea91 Disable overwriting of the fallback image
The style information for the fallback image is quite sophisticated
and should not be changed.

Bug: 72626
Change-Id: I553cf7209d87517b8c8841cc25df74ebd4c683f4
2015-07-31 08:40:55 +00:00
physikerwelt bc52c77d24 Use extension.json, empty PHP entry point
* Use string constants instead of integers
* Derive new names from old via conversion of constant
  naming convention to CamelCase.
* Replace old constant string e.g. 'MW_MATH_ABC_DEF'
  with new string 'abcDef'
* Replace old constant value with new string.
* Tests to demonstrates what is actually done.
* Rename constants

Bug: T106630
Bug: T106631
Bug: T87941
Change-Id: I6d1094ece79e912d9ddbef6681a25196c7a6e801
2015-07-30 22:01:20 +00:00
physikerwelt b938099820 Fix: Undefined variable passed to hook
* This problem was introduced in
  I6fad69b5d9b9ca8a7d12c7e410d3ae6180fbddbf
* The $render variable is undefined in that context
* $this should be used instead

Change-Id: I70e0a03e41f0312a458d1dd27b766452ae093093
2015-07-16 10:33:34 -04:00
physikerwelt 5c12ed983f Remove useless debug functionality
* MathDebug was intended to provide advanced debugging functionality
  for the math extension. However, the interesting debugging and
  logging feature never made it from the debug branch to the master.
* The current debug functionality is mostly useless. Only some values
  are written to memory and never used thereafter.
* This change moves the existing functionality to the MathSearch
  extension and introduced the required hook for that.

Details:
* $wgMathDebug is removed
* A new Hook MathRenderingResultRetrieved is created
* The math rendering object is printed to the svg error
  page if wgDebugComments is active (instead of wgMathDebug)

Change-Id: I6fad69b5d9b9ca8a7d12c7e410d3ae6180fbddbf
2015-07-14 10:34:37 -04:00
Kunal Mehta 241800f80d Use namespaced \MediaWiki\Logger\LoggerFactory
Change-Id: I78fca87d87379a694662c1a4ecc42e9401fd4c2c
2015-04-16 07:33:29 +00:00
Bryan Davis 23ff28d71d PSR-3 logging cleanup
* Limit levels to MediaWiki recommended debug, info, warning, error
* Don't add trailing newlines
* Capitalize messages

Change-Id: I211357b1cc014d6bed1717f22e2bf8ebfc4f386f
2015-03-18 12:13:05 -06:00
physikerwelt 5e46586ada Update to PSR-3 logging
Change-Id: I8b61cec606e75a3cf2143b1fa54e5dff2cfa3c7f
2015-03-18 17:26:01 +00:00
physikerwelt 6742dedda4 Code style cleanup
Cleanup whitespace and quoting, mostly related to logging function
usage.

Change-Id: I82ff6a31cd191119ec0c71c32eeb9570afd629db
2015-03-18 15:41:04 +00:00
physikerwelt (Moritz Schubotz) 77e82d89af Ignore missing SVG attribute
In some cases the SVG property of the mathoid JSON result
seems to be empty.
In that case we ignore the SVG rendering.


Bug: T87379
Change-Id: I98398ec59e1d0205ee32cca137ad29dbc9dddec9
2015-02-20 07:35:26 +00:00
Chad Horohoe eab415ef71 Math: tidy up error message handling
- We don't localize errors and debug logs like this, it makes them
  impossible to decipher
- Also remove some 1.21 and below back-compat while we're here

Change-Id: Idb23fe5b434fa9fa3518672d57ec6e5466d005ac
2015-02-19 16:22:46 -08:00
Chad Horohoe 0404113641 Remove obvious function-level profiling
Change-Id: I41d48da124e38c46ce71aa9d3b756096a424df1c
2015-02-12 12:14:24 -08:00
physikerwelt (Moritz Schubotz) 1c9383d985 LaTeXML: prevent automatic rerendering of SVG
MathMathML::renderingRequired called the getSvg
function in MathLaTeXML that caused an automatic
rerendering of the SVG image if it was not cached.
That this rendering is triggered from the function
renderingRequired is contra intutive and should be
avoided.

Change-Id: Ifa14f50193a05b3058624a18974c56897fcec09e
2015-02-08 16:28:04 +00:00
jenkins-bot 8477bdb059 Merge "Minor clean up, optimisations and documentation corrections" 2015-01-22 19:39:56 +00:00
physikerwelt (Moritz Schubotz) 31c38bdf76 MathMathML, MathTexvc: Improve PhpDoc
Change-Id: I84af65e15bdae81f69f0444afdd9ffa5fe9fc326
2015-01-22 19:13:11 +00: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) 9141a9e5ed Remove Undesired spaces after math expressions
The linebreak after the math fallback image caused
the additional space.

Bug: 72806
Change-Id: Id7117f84ddb4cbe2eb4d6b8abeecf38b4f7e3c6d
2014-11-03 01:10:43 +01:00
Gabriel Wicke d7954691c1 Use more consistent background image scaling
Chrome in particular would end up with fairly small and inconsistent
background sizes when using background-size: contain;. This makes sense
according to the docs at
https://developer.mozilla.org/en-US/docs/Web/CSS/background-size, which
doesn't specify that the background actually has to fill the entire element.

background-size: 100% 100%; does force full-size scaling, which is what we
want. Verified to work as expected in Chrome 38 on Linux.

Change-Id: I508e08dac1480491efcd1d27cfac16187bfbd4fe
2014-10-15 17:05:53 +00:00
Gabriel Wicke 97d6f8ff89 Work around tidy by using a meta element instead of an empty span
HTML tidy will strip empty spans, so don't use one for the fallback image. We
use a meta element instead, as that does not normally render at all & doesn't
have any default styling coming with it.

Change-Id: I5bcbbc9468433e3c8722c09ce813a6f5ac741333
2014-10-15 13:13:41 +00:00
Frédéric Wang d4e928a486 SVG images should not be loaded when MathML is used
- Use span with a background-image instead of <img> for the fallback SVG so
  that they don't load in Gecko.
- Make the image fallback a span inline-block so that it can have a dimension.

Bug: 71929
Change-Id: I7f820cd5766db1fece452ebfc72915a55e42c82e
2014-10-12 23:00:55 +00: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
Frédéric Wang d1eef046af Cleanup MathMathML.php after the PNG fallback removal.
- Remove the special handling for the PNG fallback in
  getFallbackImageUrl, getFallbackImage and getClassName.

- Make these functions private and remove useless parameters.

Bug: 71912
Change-Id: I569f2dd3d32a0c9690a5d9674a1c6ae0b8698f08
2014-10-11 16:13:04 +02:00
Frédéric Wang 0ddd3afaea Cleanup after the removal of the PNG fallback
- remove the default "display: none" style on the SVG fallback
- remove the IE CSS hacks from ext.math.css
- add a client-side implementation of the PNG fallback

Bug: 71912
Change-Id: I91b11313aae25c4d05f8f2333d2f21537c9b8887
2014-10-11 13:21:59 +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
Gabriel Wicke b762bef909 Bug 71857: Strip position style in all math modes
Change-Id: Ib965e687ae4e7afe86f92b497ffcbc349950fecf
2014-10-09 18:37:48 +00:00
Gabriel Wicke b7bd5196f2 Fix style stripping by adding missing /g flag
Change-Id: I6cd4b853638010d60809cecc87499113bd189d4c
2014-10-09 11:09:57 -07:00
jenkins-bot 9774aceb4b Merge "Bug 71857: Strip positioning from SVG fallback image styles" 2014-10-09 16:23:23 +00:00
Gabriel Wicke fd7fcc6ada Remove PNG image fallback image references
- These images currently return server errors

- We don't really want to load PNG images for browsers that support MathML or
  SVG. 

Bug: 69702
Change-Id: Idd339623efd19a0726b43a6c4adc2fcd832511f6
2014-10-09 05:50:04 +00:00
Gabriel Wicke f2e9dbe70c Bug 71857: Strip positioning from SVG fallback image styles
Change-Id: Ie664b421ee40c3d278605bd03cb669509319d862
2014-10-09 00:49:39 +00:00
Frédéric Wang 9f6257c329 Improve the way mathematical formulas are exposed to screen readers.
- Mark the png and svg fallback as aria-hidden="true".
- For browsers without good enough MathML visual rendering, 
  hide the <math> tag in a way that still makes it accessible to 
  screen readers.

Bug: 66537
Change-Id: I7ecf07a4da669d927e11265fd497a813786c6410
2014-10-05 17:48:41 +00:00
physikerwelt (Moritz Schubotz) 4459c5c452 Avoid unnecessary database reads
Use the cached function isInDatabase rather than readFromDatabase to
 avoid unnecessary read operations on the database.

 Currently, readFromDatabase is usually called only once during instance
 livetime. But after I455b41c8b8d918f4c34f6c115194d227a8394e0a has bben
 merged chances are that it's called twice.

Change-Id: I6434195ad1d323a578a8fdca1b4555e11ab30a15
2014-09-06 02:34:30 +00:00
physikerwelt db3026d5e1 Error reporting for Mathoid
Currently the error reporting in MathML mode is
misleading.

The old error message suggested that the MathML
produced is not well formed.
This change displays the actual error
message occurred during the conversion process.

Change-Id: I6a8201107f9280f0cba97509f19b97d8e248c99f
2014-08-28 13:16:35 -04:00
physikerwelt 05c437d89a MathML in default style
In the default style MathML was rendered as inline and
not as display-style which was consistent to the current
behaviour of the PNG rendering.

By using the 'inline-TeX' rendering type the
display rendering is done independent of the rendering
of the surrounding block layout.

Change-Id: I87e669d5dc71d6937d4cc987d306b3c4648773c4
2014-08-25 20:09:14 +00:00
physikerwelt 27ce24e736 Improve PNG fallback
The PNG fallback for old IE versions worked
only if the PNG image was already stored in the
database.
This change enables the Specialpage that displays
the PNG images to create new PNG images and to
show them directly.

To test this commit you need an old IE version
(IE<9). If you don't have access you can use
an online service such as http://netrenderer.com.

Change-Id: I74163da94e2d7a2f07d78bfe0f5ce134564ba97f
2014-07-30 19:00:57 +00:00