Commit graph

65 commits

Author SHA1 Message Date
Brad Jorsch 1c3dd4fb0d Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: Ib31f3bbffdd6b25ad9a21498294644e4dde33bd1
2017-01-31 22:54:07 -05:00
Moritz Schubotz c877e564fc Add scrollbars to displaystyle formulae
Add mwe-math-element class attribute to the outermost element
holding mathematical expressions. Add a css rule that adds a
scrollbar to the element in case it's a div, which is the case
for displaystyle formulae.

Note, there will be no scroll bar if long formulae are not
explicitly marked up das displaystyle formulae.ƒ

Bug: T134281
Change-Id: Iba462601bb15f8667d1284282ba4f6c2020a02b9
2017-01-11 10:49:40 -08:00
Physikerwelt 797c8ddfc9 Revert "Add class mwe-math-element to math elements"
This reverts commit e674d7e73b.
That commit does not help to solve T134281.
It adds a CSS class name which is configurable
by a global variable to various math elements, which is confusing.

Change-Id: Iea5f231e0cea1221dc717b3409b36c0baf11bb24
2017-01-03 23:57:46 +00:00
tameeshb e674d7e73b Add class mwe-math-element to math elements
This is the fix for the bug that makes the whole page scroll when long 
equations are present in the wiki article.

Bug: T134281
Change-Id: I29f8df027384098cd0923bcfa23a914c8d887bba
2016-12-21 23:03:18 +00:00
Moritz Schubotz 9326e7459b Add alt tag for SVG image
We use the checked version of the TeX string and
not the original user input string to ensure that
the layout is the same and no mediawiki specific
macros such as \reals is needed to render the alt
text with a regular LaTeX installation.

Bug: T136915
Change-Id: I40cdf4ec49a4d071773af6943dbe101b8d41ed87
2016-06-06 16:08:15 +00:00
Marko Obrovac d722bc51f4 Send a no-cache content request on mathpurge=true
When the user specifies the mathpurge=true query parameter, the Math
extension needs to prompt RESTBase to regenerate the renders for all
formulae on the page and consequently issue Varnish purge requests. This
behaviour is achieved by including the `Cache-Control: no-cache` header
when requesting a render. Since RESTBase regenerates all of the renders
when it receives the header, send it only for the first content request;
if subsequent content requests are made, RESTBase will already have the
new renders.

Bug: T136205
Change-Id: I44482ccc1d8afdf6d40dcf8965d8debe83ef7e17
2016-06-03 14:10:57 +02:00
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