3.1. Parsing simple math expressions as MathML

XMLmind XML Editor can parse as MathML simple math expressions typed inside mi and mn elements[5]. For simple equations, using this facility is much more productive than using the MathML tool.

For example, let's suppose you want to insert the famous equation in your document.

  1. Use the "Add MathML equation" button found in the DocBook toolbar and select inlineequation.

  2. The newly inserted element mainly contains an empty mi placeholder. Type "E=m*c^2" in this placeholder.

  3. Press Ctrl+Shift+SPACE to invoke menu item DocBookParse Text As MathML. Doing this displays a popup:

  4. Click in the popup (or press Down then Enter, like for any popup menu) in order to accept what's suggested. Et voilà, your mi element incorrectly containing "E=m*c^2" is replaced by proper MathML markup.

Of course, as we'll see it in Section 3.2, “Sample editing session”, this facility is also very handy when used in conjunction with MathML tool.

Supported expressions

The simple math expressions which can be successfully parsed by Parse Text As MathML can be quickly described as follows:

  • Numbers are parsed as mn.

  • Identifiers starting with a letter, optionally followed by letters and/or digits are parsed as mi. However, the following special, case-sensitive, identifiers are translated to a single math character:

    • Lower-case Greek letters: alpha, beta, gamma, delta, epsilon, zeta, eta, theta, iota, kappa, lambda, mu, nu, xi, omicron, pi, rho, sigma, tau, upsilon, phi, chi, psi, omega.

    • Upper-case Greek letters: Alpha, Beta, Gamma, Delta, Epsilon, Zeta, Eta, Theta, Iota, Kappa, Lambda, Mu, Nu, Xi, Omicron, Pi, Rho, Sigma, Tau, Upsilon, Phi, Chi, Psi, Omega.

    • Miscellaneous symbols: NN (), ZZ (), QQ (), RR (), CC (), emptyset (), infty ().

  • The only operators which are supported are: =, != (not equal), <, <=, >, >=, + (unary or binary), - (unary or binary), * (translated to &InvisibleTimes;), / (means "division", not "fraction"), ^ (exponent) and _ (here underscore means "indice"); all with their usual precedence.

  • You can use parentheses for grouping. However if you do so, these parentheses will show up as mo elements in the MathML. If you do not want to see the parentheses in the MathML, use {} instead of ().

  • Functions such as "f(x, y, z)" are also supported.

  • Whitespace is ignored.

Examples:

TextMathML
2*x <= -y/0.5 <= z^i <= v_j <= w^i_j
z = x^(2*i) + y^{2*i}
cos(pi/2)
sin(-x) = -sin(x)


[5] Parse Text As MathML is disabled (grayed) when the caret is found in the other elements which may contain text, namely: mo, mtext and ms.