Commit graph

49 commits

Author SHA1 Message Date
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
physikerwelt (Moritz Schubotz) 77069f6e5f Add width and height to SVG image
Beginning from Mathoid 0.2.5 the specification
of a height and width attribute of the image will be required.
This patch gets those information from the SVG and copies
them to the img tag.

See also
Bug: 20202
Bug: 68295
Change-Id: I93e26a9f538acf21aea1501144bb1dd886ae0410
2014-07-26 15:31:08 +02:00
Frédéric Wang f590974c25 Add default display options
In some cases for example if the vagrant role
mobilefrontend is enabled the stylesheets are not
processed on mobile devices.
Without a default setting for the display attribute
all elements are displayed at the same time.

Change-Id: Ic0e95effaf0b413ec4c5878e1cfd5c269daa44c3
2014-07-25 17:19:30 +00:00
physikerwelt (Moritz Schubotz) 5e2c1c5101 Displaystyle in Mathoid 0.2.5
Beginning from mathoid 0.2.5 displaystyle is the default
option. This property has to be removed as default.

Change-Id: I3c176f4227f32709f6db4014e1e3b435c3c853c4
2014-07-20 00:00:43 +00:00
Frédéric Wang 382454a979 Update modules/ext.math.css
Currently, the PNG fallback is hidden in the MathML mode and the MathML & SVG
are respectively hidden and visible by default; the visibility of the
SVG/MathML output is only changed for Gecko. This does not work well for
IE < 9, which does not support SVG. This commit tries to improve the selection
of PNG, SVG or MathML according to the browser capatibility.

Change-Id: Ie9b0fdb66c51fbf6be98df092ce4de29fbba6068
2014-06-30 10:52:59 +00:00
physikerwelt (Moritz Schubotz) cbbf5453d1 Enable MathML rendering mode
This change allows to registered users
to test the new MathML rendering mode.
Invalid settings for math rendering mode
will default to MathMathML.

Change-Id: I75f24cb762609d6728247e3758fcc18f2ebfc6e6
2014-06-11 13:21:34 +02:00
physikerwelt (Moritz Schubotz) 034d1d4fa7 fix: typo in MathMathML:setAllowedRootElements
Change-Id: I282b248e3b271b8de7a9dd0c41e7496204a17463
2014-06-10 11:57:24 +02: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 c390f6479a Add getHtmlOutput method
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 adds a mechanism that allows
to fetch the HTML output.
In a followup commit the rendering function
is changed to return a boolean value rather
than the rendering result.
This will simplify the error handling and caching.

Change-Id: I80760493e391911c41eb69d75a93c6a34db8852e
2014-06-06 21:52:35 +02:00
physikerwelt (Moritz Schubotz) 52656990b4 MathMathML
The LaTeXML class contains some code that is
not specific to LaTeXML but to MathML.
This code can be shared between LaTeXML and Mathoid.
This change introduces a new class called MathMathML
and moves the shared code from the LaTeXML class to this
new class.

Bug: 65973
Change-Id: I50517ba83f9a0d2aa8e237f062f18e4319ddbac8
2014-06-05 09:06:33 +00:00