Commit Graph

22 Commits

Author SHA1 Message Date
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) c7197bee19 Add separate database table for LaTeXML (step 5)
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 is patch changes the logic of the rendering
engine to use the specific database.
The caching logic is now simpler to understand.
A entry is written to the database if the changed field
of the MathRenderer class is true. Is is triggered by the
setters of the database relevant fields.


Bug: 65522
Change-Id: Ief9de889b9292b21c9d1529a8b1797f38196edad
2014-05-31 10:34:21 +00:00
physikerwelt bf33d51320 Add separate database table for LaTeXML (step 3)
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 adds the method getMathTableName that will
allow renderers to access their specific table in the
database.

Change-Id: I8b11ffd0a39fadd7d3c8de1e94e74ff5f490430d
2014-05-27 05:33:20 +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
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
Aaron Schulz 078347b35e Update the DB output hash if outdated according to texvc
* Otherwise all future <math> hits will check the wrong file
  (which may not exist), recreate the png, and store over the
  proper file (even if it was already there). Update the DB to
  point to the right hash instead.

bug: 60997
Change-Id: Ib833ad32ff1e4506e9b8ab2cc1b72516cb072cd5
2014-02-14 23:42:17 +00:00
Moritz Schubotz ff83048597 fix: texvccheck is not idempotent
The output of texvccheck is not only "checked" but also
rewritten to another form.
(For example $\R$ is transformed to $\mathbb{R}$.)
But the output might not be a valid input for the thexvccheck
part of texvc, like it happened in for the example given in the bug
description.
See also I599c4390da9b8f36d800f379a33ad5ce90f5096c
Bug: 61012
Change-Id: Iae5e350cb78c0e637e574390c586fbdb8dc38496
2014-02-07 10:27:21 +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
vishnu 0ab1280d6b Fix depreciation warnings in FileBackend construction
Added wikiId and lockManager was changed to an object
Bug: 58615

Change-Id: Id3bdc7e6bc3951db4753553da03193783f0bd7c8
2013-12-27 23:27:32 +05:30
Aaron Schulz f0f19007c5 Buffer png writes and flush them all at once
* This should half the time to render pages with many formulas

bug: 56769
Change-Id: I5edf979c31fe12098eba1d1df52c9cd3251bd115
2013-12-27 10:42:27 +00:00
Max Semenik 4d68c31de1 Add profiling
Change-Id: I9066f6b2606044412a9b91ca395e841550d7e787
2013-11-18 14:46:00 +04:00
Ori Livneh 679ce7fe2f Log texvc errors in 'texvc' log channel
This patch adds wfDebugLog() calls for conditions related to texvc invocations.
The logs are grouped under a 'texvc' group, added for this purpose. The reason
for logging into a separate channel is that the Math channel is too verbose for
production use on the Wikimedia cluster.

Change-Id: I05a17a0230f49f5d698b91617d06b3e3f838b67d
2013-10-14 15:59:21 -07:00
physikerwelt 90d678782f Fix: PHP Style corrections
* Explicit function visibility
* Uniform constant definition

Change-Id: I5f064d2eac0dedd4c8cc94f442c65f0e338ebbf4
2013-06-07 15:37:56 +00:00
Matthew Flaschen 32e2f4d4f5 Use i18n params for errors than appending raw string, with test
* Remove parameters/append that are never outputted by texvc.ml
* Add missing math_output_error to i18n file
* Improve a few qqq descriptions

Change-Id: Iea5139682fbe8389e578549f5f62e5505f4c0b48
2013-05-18 01:48:16 -04:00
physikerwelt 5245d0f555 Introduce getter and setter for the MathRenderer
Adds a new method isChanged() for determining if a value was changed.
This is done in preparation for a more elaborated caching method that is
handled inside the abstract base class.

Change-Id: Ica15f77d96453d30edd3a117c7185c694ad3691e
2013-05-03 21:12:36 +00:00
physikerwelt 08b93eebd6 renaming of read and write methods for database access
readFromBB->readFromDatabase
writeDBEntry->writeToDatabase

Change-Id: I426be5dc479ad789d0e85b149a989a581945c9be
2013-04-24 06:03: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
Matthew Flaschen 3916ac167c Revert "(Bug 45973) Fix check for avoiding re-cache"
Revert unreviewed self-merge with pending issues.

This reverts commit f5422cf85a.

Change-Id: I17471e2adccf54b79a9d8185c4a6f4b6937ce622
2013-03-12 00:24:43 -04:00
Ori Livneh f5422cf85a (Bug 45973) Fix check for avoiding re-cache
If the request could not be served from the cache, we *do* want to cache it.

Change-Id: Id58dac55ce79f568e4b4a42a155235af5a46bf7f
2013-03-12 04:16:21 +00: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
Matthew Flaschen 8a04254e6d Change default LockManager back to nullLockManager.
* This was changed in 926db7c3bd as a workaround for a testing issue.
* See 8cbd679aac781bdd73038064261736a937645fc1 , which fixes the test harness in core .

Change-Id: Ib57cafee35a699ce875ee4bc8951781e1a37553a
2013-02-08 13:59:26 -05: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