Hello Sergiu
I have committed today the first implementation of a new XWiki feature:
rendering mathematical equations into images. It is available as a
standalone component, and as a syntax 2.0 macro.
Nice job, I did not try it as I have no concrete use now, but anyway,
that's a really nice feature as equations are always hard to write for
nice display.
About the functionality.
Equations are written in the TeX/LaTeX syntax, which is pretty simple,
and seems to be the syntax of choice for mathematical equations in other
wikis, too. The macro can distinguish between inline and block equations
and render them accordingly. The output can be either PNG (the default
one), GIF or JPEG. While PNG is definitely the best, I kept the other
two in case somebody really wants to use ancient browsers that only
understand GIF.
Q: Should I leave just PNG as the output format?
I think, at least png and jpg should be kept. Png as default, and jpg as
optional (there are still a lot of jpg fans i guess), for the GIF
format, i don't think it is necessary.
Another feature is that the font size can be
specified, in order to
render larger or smaller equations. All the font size commands from
LaTeX (from \tiny to \Huge) have an equivalent. I renamed them to a more
easy to understand name (also because the configuration is case
insensitive, so there's no difference between large and LARGE).
By default images are generated so that the font looks relatively OK
This new cache might increase the memory
requirements, but fortunately it is easy to configure.
The rendering macro is located in
platform/core/xwiki-rendering/xwiki-renderig-macros/xwiki-rendering-macro-equation,
and the macro can be used with
{{equation}}\sum_{i=0}^{\infty}{{/equation}}.
Q: Is the macro name appropriate? Do you know of a better one?
I don't think you can find a better one...
Future work:
- make sure that there are no security issues with the Native backend
- add support for MathML display for the clients that understand it
- improve the alignment of images (especially for the Native backend),
as right now they are a bit raised above the text baseline
Many thanks to Guillaume Legris who provided the starting point for this
component.
Keep up the good work...
And thanks for this nice feature.
Jean
--
----
Jean Couteau
Code Lutin -
http://www.codelutin.com
44 Bd des Pas Enchantés - 44230 St-Sébastien/Loire
Tél : 02 40 50 29 28 - Fax : 09 59 92 29 28