Technical blog

16 Oct 2012

This feature is available from WIRIS editor release 3.5 or superior. For this article we assume you are familiar with content MathML and presentation MathML.

WIRIS editor works natively with presentation MathML because it captures all the design features that authors might need.

WIRIS editor can also input and output content MathML. Formulas can be imported/exported to content MathML provided they are well formed according to a WIRIS editor build-in grammar.

For example, are valid formulas

«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«mfrac»«mn»1«/mn»«mn»2«/mn»«/mfrac»«mo»§nbsp;«/mo»«mo»§nbsp;«/mo»«mo»§nbsp;«/mo»«mn»3«/mn»«mo»+«/mo»«mn»2«/mn»«/math»

whereas the following are not

Content MathML is related to evaluation of formulas. Check the WIRIS editor decimal evaluation.

Enabling syntax checker

First of all, it is worth to enable the syntax checker in order to prevent users to write wrong formulas. The syntax checker highlights any formula that is not well formed and, thus, cannot be converted to content MathML.

The 3+ is not a well formed formula according to WIRIS editor.

Remember that you can embed WIRIS editor to any Web page. To enable the syntax checking, when initializing WIRIS editor,

editor = com.wiris.jsEditor.JsEditor.newInstance({'checkSyntax': 'true'});

or any time after the editor is created

editor.setParams({'checkSyntax': 'true'})

Setting content MathML to the editor

The Web based WIRIS editor accepts directly both presentation MathML and content MathML. The different render engines also accepts content MathML (for example, when generating PNG images).

Getting content MathML

WIRIS editor user interface (JavaScript) can only output presentation MathML. To obtain content MathML, a Web service or a direct call using Java or .NET is required to do the conversion from presentation MathML to content MathML.

Getting content MathML with Web service

A call to the Web service with both GET and POST methods are possible. In general it is preferable the POST method in order to avoid size limitations. The call has the form:

www.wiris.net/demo/editor/mathml2content?mml=presentation-mathml

where content-mathml is the content MathML. For example,

www.wiris.net/demo/editor/mathml2content?mml=<math><mn>1</mn><mo>-</mo><mn>2</mn></math>

Getting content MathML with a direct call with Java or .NET

To use this method you will need a license to download and run the WIRIS editor - server components. Available for Java and .NET.

The source code in Java:

PublicServicesInterface ps = PublicServices.getInstance();
Properties p = new Properties();
String content = ps.mathml2content(
   "<math><mn>1</mn><mo>+</mo><mn>2</mn></math>",p);

For c#:

PublicServicesInterface ps = PublicServices.getInstance();
Dictionary<string,string> d = new Dictionary<string,string>();
string content = ps.mathml2content(
   "<math><mn>1</mn><mo>+</mo><mn>2</mn></math>",d);

You will need to add the WIRISeditor.jar in the classpath (or the WIRISeditor.dll for .NET).

Converting from content MathML to presentation MathML

The Web based editor accepts content MathML, so in most scenarios you will not need to convert from content MathML to presentation MathML.

In case you need so, you can use the service or the method called content2mathml in a similar way to when converting to content MathML.

http://www.wiris.net/demo/editor/content2mathml?mml=<math><apply><minus/><cn>1</cn><cn>2</cn></apply></math>

24 Apr 2012

This article explains the requirements that an HTML editor should accomplish in order to be able to integrate WIRIS editor with it. You only need to check this requirements list if there is no WIRIS plugin for your HTML editor. Check the complete list at WIRIS plugins

For details of how to proceed with that integration visit WIRIS plugin for generic HTML editor.

Terminology

  • Web application. The collection of web pages that includes an HTML editor to generate new richly formatted content.
  • HTML editor. A Web component that allows editing rich HTML content. It usually substitutes a simple textarea with a more sophisticated user graphical interface that includes a toolbar and a frame where you can, for example, change font styling and insert images.
  • WIRIS editor/plugin. The WIRIS formula and equation editor and plugin.

There are two mandatory requirements

  1. Server side scripting. Allow executing server side scripting. WIRIS plugins already provide such scripts in Java, PHP, ASP.NET and ASP. This is more a Web application requirement than an HTML editor.
  2. Add a button. Allow inserting a new button in the toolbar of the HTML editor that executes a custom JavaScript code in the on click event. In addition is necessary to load a JavaScript file provided by WIRIS editor/plugin and to allow it to run some initialization code. The initialization method is the responsible to add the mouse events used to reedit a formula.

For features like LaTeX, storing “full MathML in the database” and WIRIS cas, two other requirements must be met:

  1. Post set HTML event. After the initial content is set in the HTML editor and before the user edition starts, a script of the WIRIS editor must called in order to transform the HTML.
  2. Pre get HTML event. Before the content is retrieved to be stored, a script of the WIRIS editor must be called in order to transform the HTML.

If the above requirements are not met, the Web application has still the change to do direct calls to the WIRIS editor/plugin.

Finally, two optional requirements help promote good practices and easy to maintain code:

  1. Auto-load of plugin JavaScripts. The HTML editor handles the load of the JavaScript required by WIRIS editor/plugin (it adds any necessary <script> tags by itself). If this requirement is not met, the Web application is the responsible to include the JavaScript file of the WIRIS editor/plugin whenever the editor is required.
  2. Initialization event. The HTML editor calls an initialization event of the WIRIS editor/plugin. If this requirement is not met, the Web application is the responsible to call the initialization method which might be tricky to achieve.
     
13 Mar 2012

The WIRIS plugins integrates the WIRIS editor into the HTML editors. From release 3.0, it is possible to write LaTeX inside the HTML editor using the $$ notation. In any case, formulas will be converted and stored as MathML.

LaTeX is disabled in the WIRIS plugin for Moodle if the filter of TeX is enabled in order to avoid conflicts.

How to edit using LaTeX

For example, if you type $$\frac12$$ in your HTML editor and you save the page, you will get a page with the fraction «math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«mfrac»«mn»1«/mn»«mn»2«/mn»«/mfrac»«/math». The WIRIS editor icon WIRIS editor icon is never clicked for this purpose but means that the WIRIS plugin is installed and works behind the scenes to cope with LaTeX.

Editing LaTeX in an HTML editor
Editing LaTeX in an HTML editor

The browser displays the formula
The browser displays the formula

When you reedit the page, you will see again $$\frac12$$. Thus, during edition you get the LaTeX and you see the image of the formula in display time.

A nice feature provided by the WIRIS plugin is that you can still use the WIRIS editor with LaTeX formulas. If the caret is inside a formula, you can click the WIRIS editor icon to edit it. After submitting the WIRIS editor form, the old LaTeX is replaced by the new LaTeX formula.

Using the WIRIS editor to modify a LaTeX formula
Using the WIRIS editor to modify a LaTeX formula
 

LaTeX is manipulated as MathML

Above is described the user experience, but what is important to note is that formulas are actually stored and displayed using MathML.

Upon submit the HTML editor, the WIRIS plugins searches all $$ and converts the LaTeX into MathML. During this process, the plugin stores the MathML and the original LaTeX text written by the author. Thus, when displaying formulas, the MathML mechanism takes place.

MathML is used internally whatever you do with LaTeX
MathML is used internally whatever you do with LaTeX

LaTeX is stored inside a MathML using a standard tag called <semantics>. Following the previous example:

<math xmlns="http://www.w3.org/1998/Math/MathML">
   <semantics>
      <mfrac><mn>1</mn><mn>2</mn></mfrac>
      <annotation encoding="LaTeX">\frac12</annotation>
   </semantics>
</math>

When the HTML editor is opened again, the stored LaTeX is recovered from the <semantics> tag and is displayed in the HTML editor area for further edition. What it is important to note is that it works even when the LaTeX cannot be converted into MathML while it is possible still to edit the erroneous LaTeX to fix any possible error.

Which LaTeX is supported?

The supported LaTeX depends on the effectiveness when translating from/to MathML. The limits are due to the following facts:

  1. Some formulas have no equivalence with MathML.
  2. LaTeX is an extensible language with a lot of non-official packages. To do things worse, LaTeX has its own programming language.

Some examples about the current LaTeX supported can be found here.


 

18 Nov 2011

Motivation

WIRIS cas "hosting in your server" is only officially released for a Linux server. Some users have requested a Windows version so we provide a workaround to install the WIRIS cas server components into a Windows server.

WIRIS cas can be installed in a Windows server following the same architecture as the Linux case:

  1. It requires the installation of Java and a Java Application Server like Tomcat. A java Web application must be deployed (war file).
  2. The daemon engine must be launched somehow. At present there is no Windows service to do this task.

Installation procedure

  1. Follow the same instructions as the Linux components.
  2. Download and copy the WIRIS cas windows kernel at the folder <wiris>/kernel in such a way that the following file must exist <wiris>/kernel/windows/OmegaKernel.exe (where <wiris> is the folder where the WIRIS cas daemon engine was copied). There is no need to remove the Linux kernel because the WIRIS cas server will detect automatically that is running under Windows.

Launching the daemon engine

From the command line,

cd <wiris>/server
java -Xmx128m Server

note that the java program should be in the command path. 

Using omega_start.sh script to launch the daemon has the benefit to run it in background, however it will need that cygwin is installed.

14 Oct 2010

What follows are informal instructions to integrate WIRIS Plugin into a Drupal installation with CKEditor.

We do not support the integration officially since there are some minor issues to be solved. Please contact us if you are interested in such integration.

  1. Install wysiwyg module with CKeditor
  2. Install WIRIS Plugin for CKeditor at sites/all/libraries/ckeditor/plugins/
  3. Edit file modules/wysiwyg/editors/ckeditor.inc
    In function wysiwyg_ckeditor_plugins add one more element to $plugins
    $plugins = array(
      'default' => array(
         ...
      ),
      'ckeditor_wiris' => array(
         'path' => $editor['library path'] . '/plugins/ckeditor_wiris',
         'buttons' => array(
           'ckeditor_wiris_formulaEditor' => 'WIRIS Formula Editor',
           'ckeditor_wiris_CAS' => 'WIRIS cas'
         ),
         'internal' => TRUE,
         'load' => TRUE
       )
      );
    
  4. Open http://your_server/drupal_path/admin/settings/wysiwyg/profile
    Click on 'Edit' for each Input format. Inside the edition page include the desired buttons, upon which you will find WIRIS editor and WIRIS cas butons.