From 0d9c9f99e04e47510174ff0cfc6f969c6b064635 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Wed, 12 May 2021 14:14:06 -0400 Subject: fix external image flaws in Web/MathML/Authoring (zh-cn, zh-tw) --- files/zh-cn/web/mathml/authoring/index.html | 44 +++-- files/zh-tw/web/mathml/authoring/index.html | 251 ++++++++++++++++------------ 2 files changed, 166 insertions(+), 129 deletions(-) (limited to 'files') diff --git a/files/zh-cn/web/mathml/authoring/index.html b/files/zh-cn/web/mathml/authoring/index.html index 5e247f1680..48fe7f24bf 100644 --- a/files/zh-cn/web/mathml/authoring/index.html +++ b/files/zh-cn/web/mathml/authoring/index.html @@ -10,7 +10,7 @@ translation_of: Web/MathML/Authoring

这个页面解释了如何利用 MathML 语言书写数学公式。就像 HTML,MathML 是用标签和属性描述的。当你的文档包含了高级结构比如说列表或表格的时候,HTML 会变得很冗长,但是幸好还有很多来自简单记号法的生成器,“所见即所得”编辑器以及别的内容管理系统可以帮助你编写 Web 网页。

-

数学公式记号法在结构方面更加复杂,像分数、平方根或者矩阵,很可能需要它们自己的标签。结果是,好的 MathML 编辑工具很重要,我们在下面描述一些工具。值得一说的是,Mozilla MathML 工作小组已经开发出了 TeXZilla,这是一个基于 JavaScript、支持 Unicode 编码的 LaTeX 转 MathML 转换器,is intended to be used in many scenarios described here。当然了,这个列表并不详尽,我们建议你自己去查看 W3C MathML软件列表,你可以在那里找到很多别的工具。

+

数学公式记号法在结构方面更加复杂,像分数、平方根或者矩阵,很可能需要它们自己的标签。结果是,好的 MathML 编辑工具很重要,我们在下面描述一些工具。值得一说的是,Mozilla MathML 工作小组已经开发出了 TeXZilla,这是一个基于 JavaScript、支持 Unicode 编码的 LaTeX 转 MathML 转换器,is intended to be used in many scenarios described here。当然了,这个列表并不详尽,我们建议你自己去查看 W3C MathML软件列表,你可以在那里找到很多别的工具。

注意,根据设计,MathML 在 HTML5 中是完美整合的,而且你可以使用寻常的 Web 功能,比如说 CSS、DOM、JavaScript 或 SVG。这超出这个文档的范围了,但是任何拥有基础 Web 语言知识的人都能够轻松地学会用 MathML 综合这些功能。请阅读我们的文档以及 MathML 参考以了解详情。

@@ -41,7 +41,7 @@ translation_of: Web/MathML/Authoring </body> </html> -

浏览器不支持转换 MathML 的内容。建议在发布网页之前,把你的 MathML 内容标记转换成 MathML 表达式,比如说利用 ctop.xsl 样式表作为辅助。本页提到的工具可以生成 MathML 表达式。

+

浏览器不支持转换 MathML 的内容。建议在发布网页之前,把你的 MathML 内容标记转换成 MathML 表达式,比如说利用 ctop.xsl 样式表作为辅助。本页提到的工具可以生成 MathML 表达式。

对不支持 MathML 的浏览器的后备计划

@@ -49,7 +49,7 @@ translation_of: Web/MathML/Authoring
<script src="http://fred-wang.github.io/mathml.css/mspace.js"></script>
-

如果你需要更多复杂的结构,你需要考虑使用更重一些的 MathJax 库作为一个MathML polyfill:

+

如果你需要更多复杂的结构,你需要考虑使用更重一些的 MathJax 库作为一个MathML polyfill:

<script src="http://fred-wang.github.io/mathjax.js/mpadded-min.js"></script>
@@ -125,7 +125,7 @@ m|math {

电子邮件和即时通讯客户端中的 MathML

-

Modern mail clients may send and receive emails in the HTML5 format and thus can use MathML expressions. Be sure to have the "send as HTML" and "view as HTML" options enabled. In Thunderbird, you can use the "Insert HTML" command to paste your HTML+MathML code. MathBird is a convenient add-on for Thunderbird to insert such MathML expressions using the AsciiMath input syntax. Moreover, a LaTeX-to-MathML input box has also been integrated into SeaMonkey since version 2.28 and into Thunderbird since version 31. Again, the way MathML is handled and the quality of the MathML rendering depend on the mail clients. Even if your browser supports MathML, your Webmail may prevent you to send or receive mails with MathML inside.

+

Modern mail clients may send and receive emails in the HTML5 format and thus can use MathML expressions. Be sure to have the "send as HTML" and "view as HTML" options enabled. In Thunderbird, you can use the "Insert HTML" command to paste your HTML+MathML code. MathBird is a convenient add-on for Thunderbird to insert such MathML expressions using the AsciiMath input syntax. Moreover, a LaTeX-to-MathML input box has also been integrated into SeaMonkey since version 2.28 and into Thunderbird since version 31. Again, the way MathML is handled and the quality of the MathML rendering depend on the mail clients. Even if your browser supports MathML, your Webmail may prevent you to send or receive mails with MathML inside.

Gecko-based instant messaging clients can integrate a Javascript-based text-to-MathML converter (mentioned below) and then render the MathML expressions generated from the (plaintext) instant messages. For example, there is an Instantbird add-on that handles LaTeX expressions.

@@ -177,7 +177,7 @@ m|math {

and get it automatically converted into MathML. This is still a work-in-progress, but could be improved in the future thanks to Web Components and shadow DOM. Alternatively, you can use the more traditional Javascript parsing of expressions at load time as all the other tools in this section do.

-

One simple client-side conversion tools is ASCIIMathML. Just download the ASCIIMathML.js script and copy it to your Web site. Then on your Web pages, add a <script> tag to load ASCIIMathML and the mathematical expressions delimited by ` (grave accent) will be automatically parsed and converted to MathML:

+

One simple client-side conversion tools is ASCIIMathML. Just download the ASCIIMathML.js script and copy it to your Web site. Then on your Web pages, add a <script> tag to load ASCIIMathML and the mathematical expressions delimited by ` (grave accent) will be automatically parsed and converted to MathML:

<html>
 <head>
@@ -191,7 +191,7 @@ m|math {
 ...
 
-

LaTeXMathML is a similar script that allows to parse more LaTeX commands. The installation is similar: copy LaTeXMathML.js and LaTeXMathML.standardarticle.css, add links in the header of your document and the LaTeX content of your Web page marked by the "LaTeX" class will be automatically parsed and converted to HTML+MathML:

+

LaTeXMathML is a similar script that allows to parse more LaTeX commands. The installation is similar: copy LaTeXMathML.js and LaTeXMathML.standardarticle.css, add links in the header of your document and the LaTeX content of your Web page marked by the "LaTeX" class will be automatically parsed and converted to HTML+MathML:

<head>
 ...
@@ -223,9 +223,9 @@ This is a sample LaTeXML document.
 </div>
 ...
-

jqMath is another script to parse a simple LaTeX-like syntax but which also accepts non-ASCII characters like  √{∑↙{n=1}↖{+∞} 6/n^2} = π  to write n = 1 + 6 n 2 = π . The installation is similar: download and copy the relevant Javascript and CSS files on your Web site and reference them in your page header (see the COPY-ME.html file from the zip archive for an example). One of the advantage of jqMath over the previous scripts is that it will automatically add some simple CSS rules to do the mathematical layout and make the formulas readable on browsers with limited MathML support.

+

jqMath is another script to parse a simple LaTeX-like syntax but which also accepts non-ASCII characters like  √{∑↙{n=1}↖{+∞} 6/n^2} = π  to write n = 1 + 6 n 2 = π . The installation is similar: download and copy the relevant Javascript and CSS files on your Web site and reference them in your page header (see the COPY-ME.html file from the zip archive for an example). One of the advantage of jqMath over the previous scripts is that it will automatically add some simple CSS rules to do the mathematical layout and make the formulas readable on browsers with limited MathML support.

-

Another way to work around the lack of MathML support in some browsers is to use MathJax. However, note that you may find conflicts and synchronization issues between MathJax and the Javascript libraries previously mentioned. So if you really want to use MathJax as a MathML polyfill, you'd better use its own LaTeX/ASCIIMath parsers too. Note that on the one hand MathJax has better parsing and rendering support but on the other hand it is much bigger, more complex and slower than the previous Javascript libraries. Fortunately, you can use MathJax's CDN so that you don't need to install it on your Web server. Also, the slowest part of MathJax is currently its HTML-CSS / SVG output modes so we recommend to use the Native MathML output for Gecko-based browsers. Hence a typical configuration to use the AMS-LaTeX input is:

+

Another way to work around the lack of MathML support in some browsers is to use MathJax. However, note that you may find conflicts and synchronization issues between MathJax and the Javascript libraries previously mentioned. So if you really want to use MathJax as a MathML polyfill, you'd better use its own LaTeX/ASCIIMath parsers too. Note that on the one hand MathJax has better parsing and rendering support but on the other hand it is much bigger, more complex and slower than the previous Javascript libraries. Fortunately, you can use MathJax's CDN so that you don't need to install it on your Web server. Also, the slowest part of MathJax is currently its HTML-CSS / SVG output modes so we recommend to use the Native MathML output for Gecko-based browsers. Hence a typical configuration to use the AMS-LaTeX input is:

...
     <script type="text/x-mathjax-config">
@@ -267,7 +267,7 @@ This is a sample LaTeXML document.
 
 

TeXZilla can be used from the command line and will essentially have the same support as itex2MML described below. However, the stream filter behavior is not implemented yet.

-

If you only want to parse simple LaTeX mathematical expressions, you might want to try tools like itex2MML or Blahtex. The latter is often available on Linux distributions. Let's consider the former, which was originally written by Paul Gartside at the beginning of the Mozilla MathML project and has been maintained by Jacques Distler since then. It's a small stream filter written in C/C++ and generated with flex and bison ; in particular it is very fast. Install flex/bison as well as the classical compiler and make tools. On Unix, you can then download itex2MML, build and install it:

+

If you only want to parse simple LaTeX mathematical expressions, you might want to try tools like itex2MML or Blahtex. The latter is often available on Linux distributions. Let's consider the former, which was originally written by Paul Gartside at the beginning of the Mozilla MathML project and has been maintained by Jacques Distler since then. It's a small stream filter written in C/C++ and generated with flex and bison ; in particular it is very fast. Install flex/bison as well as the classical compiler and make tools. On Unix, you can then download itex2MML, build and install it:

wget http://golem.ph.utexas.edu/~distler/blog/files/itexToMML.tar.gz; \
 tar -xzf itexToMML.tar.gz; \
@@ -301,12 +301,12 @@ sudo make install
 
 

Note that tex4ebook relies on TeX4ht to generate EPUB documents.

-

LaTeXML is another tool that can generate HTML5 and EPUB documents. Windows users can watch this video tutorial. Given a foo.tex LaTeX file, you can use these simple commands:

+

LaTeXML is another tool that can generate HTML5 and EPUB documents. Windows users can watch this video tutorial. Given a foo.tex LaTeX file, you can use these simple commands:

  latexmlc --dest foo.html foo.tex # Generate a HTML5 document foo.html
   latexmlc --dest foo.epub foo.tex # Generate an EPUB document foo.epub
-

To handle the case of browsers without MathML support, you can use the --javascript parameter to tell LaTeXML to include one of the fallback scripts:

+

To handle the case of browsers without MathML support, you can use the --javascript parameter to tell LaTeXML to include one of the fallback scripts:

  latexmlc --dest foo.html --javascript=http://fred-wang.github.io/mathml.css/mspace.js foo.tex  # Add the CSS fallback
   latexmlc --dest foo.html --javascript=http://fred-wang.github.io/mathjax.js/mpadded-min.js foo.tex # Add the MathJax fallback
@@ -332,7 +332,7 @@ sudo make install
  
 
 
-

TeXZilla can be used as a Web server in order to perform server-side LaTeX-to-MathML conversion. LaTeXML can also be used as a deamon to run server-side. Mathoid is another tool based on MathJax that is also able to perform additional MathML-to-SVG conversion.

+

TeXZilla can be used as a Web server in order to perform server-side LaTeX-to-MathML conversion. LaTeXML can also be used as a deamon to run server-side. Mathoid is another tool based on MathJax that is also able to perform additional MathML-to-SVG conversion.

Instiki is a Wiki that integrates itex2MML to do server-side conversion. In future versions, MediaWiki will support server-side conversion too.

@@ -340,27 +340,25 @@ sudo make install

Input Box

-

TeXZilla has several interfaces, including a CKEditor plugin used on MDN, an online demo, a Firefox add-on or a FirefoxOS Webapp. It has also been integrated into SeaMonkey since version 2.28 and into Thunderbird since version 31. Abiword contains a small equation editor, based on itex2MML. Finally, Bluegriffon has an add-on to insert MathML formulas in your document, using ASCII/LaTeX-like syntax.

+

TeXZilla has several interfaces, including a CKEditor plugin used on MDN, an online demo, a Firefox add-on or a FirefoxOS Webapp. It has also been integrated into SeaMonkey since version 2.28 and into Thunderbird since version 31. Abiword contains a small equation editor, based on itex2MML. Finally, Bluegriffon has an add-on to insert MathML formulas in your document, using ASCII/LaTeX-like syntax.

-

BlueGriffon

+

BlueGriffon

所见即所得编辑器

-

Firemath is an extension for Firefox that provides a WYSIWYG MathML editor. A preview of the formula is displayed using the rendering engine of Mozilla. The generated MathML code is available at the bottom. Use the text field for token elements and buttons to build advanced constructions. Once you are done, you can save your document as a XHTML page.

+

Firemath is an extension for Firefox that provides a WYSIWYG MathML editor. A preview of the formula is displayed using the rendering engine of Mozilla. The generated MathML code is available at the bottom. Use the text field for token elements and buttons to build advanced constructions. Once you are done, you can save your document as a XHTML page.

-

LyX is a graphical LaTeX editor, which has built-in support for XHTML+MathML export and can be configured to use similar LaTeX-to-(X)HTML converters. You can for example, you can configure it to use LaTeXML HTML5/EPUB export.

+

LyX is a graphical LaTeX editor, which has built-in support for XHTML+MathML export and can be configured to use similar LaTeX-to-(X)HTML converters. You can for example, you can configure it to use LaTeXML HTML5/EPUB export.

-

OpenOffice and LibreOffice have an equation editor (File → New → Formula). It is semi-WYSIWYG: you enter the source of the formula using the equation panel/keyboard and a preview of the formula is regularly refreshed. The editor uses its own syntax "StarMath" for the source but MathML is also generated when the document is saved. To get the MathML code, save the document as mml and open it with any text editor. Alternatively, you can extract the odf file (which is actually a zip archive) and open an xml file called content.xml.

+

OpenOffice and LibreOffice have an equation editor (File → New → Formula). It is semi-WYSIWYG: you enter the source of the formula using the equation panel/keyboard and a preview of the formula is regularly refreshed. The editor uses its own syntax "StarMath" for the source but MathML is also generated when the document is saved. To get the MathML code, save the document as mml and open it with any text editor. Alternatively, you can extract the odf file (which is actually a zip archive) and open an xml file called content.xml.

-

Open Office Math

+

Open Office Math

-

Amaya is the W3C's web editor, which is able to handle MathML inside XHTML documents. Use the Elements and the Special Chars panels to create various advanced mathematical constructs. Simple text such as a+2 is automatically parsed and the appropriate MathML markup is generated. Once you are done, you can directly save your XHTML page and open it in Mozilla.

+

Amaya is the W3C's web editor, which is able to handle MathML inside XHTML documents. Use the Elements and the Special Chars panels to create various advanced mathematical constructs. Simple text such as a+2 is automatically parsed and the appropriate MathML markup is generated. Once you are done, you can directly save your XHTML page and open it in Mozilla.

可选的字符、手写识别

-

Inftyreader is able to perform some Optical Character Recognition, including translation of mathematical equations into MathML. Other tools can do handwriting recognition such as the Windows Math Input Panel

- -

Windows Math Input Panel

+

Inftyreader is able to perform some Optical Character Recognition, including translation of mathematical equations into MathML. Other tools can do handwriting recognition such as the Windows Math Input Panel

or the online converter Web Equation.

@@ -370,6 +368,6 @@ sudo make install
  • 作者:Frédéric Wang
  • 其他贡献者:Florian Scholz
  • -
  • 版权信息:Portions of this content are © 2010 by individual mozilla.org contributors; content available under a Creative Commons license | Details.
  • +
  • 版权信息:Portions of this content are © 2010 by individual mozilla.org contributors; content available under a Creative Commons license | Details.
diff --git a/files/zh-tw/web/mathml/authoring/index.html b/files/zh-tw/web/mathml/authoring/index.html index 1f999fedc1..521584943f 100644 --- a/files/zh-tw/web/mathml/authoring/index.html +++ b/files/zh-tw/web/mathml/authoring/index.html @@ -4,58 +4,58 @@ slug: Web/MathML/Authoring translation_of: Web/MathML/Authoring ---

  這裡我們將會介紹該如何利用 MathML 來表達數學語言。如同 HTML, MathML 也是一種  SGML 語言,因此它是以 tag 和 attribute 描述的。HTML 在你使用了一些諸如 list 或 table 等結構時將會變得很複雜,索性我們有一些 WYSIWYG 編輯器和其他 Content Management Systems 來協助我們進行開發。

-

  數學符號擁有許多更複雜的結構,如除號, 平方根以及矩陣等,他們都需要分別代表他們的 tags。因此,一個好的 MathML 編輯工具是非常重要的,而接下來我們將介紹一些工具給你。限於篇幅的關係,我們的介紹可能不是十分詳盡,你可以到 W3C MathML software list 查看更進一步的訊息,那裡也介紹了其他的工具。

-

Note that by design, MathML is well-integrated in HTML5 and in particular you can use usual Web features like CSS, DOM, Javascript or SVG. This is out of the scope of this document but anyone with basic knowledge of Web languages will easily be able to mix these features with MathML. Check out our demos and MathML references for more details.

+

  數學符號擁有許多更複雜的結構,如除號, 平方根以及矩陣等,他們都需要分別代表他們的 tags。因此,一個好的 MathML 編輯工具是非常重要的,而接下來我們將介紹一些工具給你。限於篇幅的關係,我們的介紹可能不是十分詳盡,你可以到 W3C MathML software list 查看更進一步的訊息,那裡也介紹了其他的工具。

+

Note that by design, MathML is well-integrated in HTML5 and in particular you can use usual Web features like CSS, DOM, Javascript or SVG. This is out of the scope of this document but anyone with basic knowledge of Web languages will easily be able to mix these features with MathML. Check out our demos and MathML references for more details.

Using MathML

MathML in HTML pages

You can use Presentation MathML inside HTML5 documents:

-
<!DOCTYPE html>
-<html>
-<head>
- <title>MathML in HTML5</title>
-</head>
-<body>
+
<!DOCTYPE html>
+<html>
+<head>
+ <title>MathML in HTML5</title>
+</head>
+<body>
 
-  <h1>MathML in HTML5</h1>
+  <h1>MathML in HTML5</h1>
 
-  <p>
+  <p>
     Square root of two:
-    <math>
-      <msqrt>
-        <mn>2</mn>
-      </msqrt>
-    </math>
-  </p>
+    <math>
+      <msqrt>
+        <mn>2</mn>
+      </msqrt>
+    </math>
+  </p>
 
-</body>
-</html>
-

Content MathML is not supported by browsers. It's recommended to convert your Content MathML markup into Presentation MathML before publishing it, for example with the help of the ctop.xsl  stylesheet. Tools mentioned on this page generates Presentation MathML.

+</body> +</html>
+

Content MathML is not supported by browsers. It's recommended to convert your Content MathML markup into Presentation MathML before publishing it, for example with the help of the ctop.xsl  stylesheet. Tools mentioned on this page generates Presentation MathML.

Fallback for Browsers without MathML support

Unfortunately, some browsers are not able to render MathML equations or only have a limited support. Hence you will need to use a MathML polyfill to provide some fallback rendering. If you need only basic mathematical constructions such as those used on this MDN wiki then a small mathml.css stylesheet might be enough. To use it, just insert one line in your document header:

-
<script src="http://fred-wang.github.io/mathml.css/mspace.js"></script>
-

If you need more complex constructions, you might instead consider using the heavier MathJax library as a MathML polyfill:

-
<script src="http://fred-wang.github.io/mathjax.js/mpadded.js"></script>
-

Note that these two scripts perform feature detection of the mspace or mpadded elements (see the browser compatibility table on these pages). If you don't want to use this link to GitHub but instead to integrate these polyfills or others in your own project, you might need the detection scripts to verify the level of MathML support. For example the following function verifies the MathML support by testing the mspace element (you may replace mspace with mpadded):

-
 function hasMathMLSupport() {
-  var div = document.createElement("div"), box;
-  div.innerHTML = "<math><mspace height='23px' width='77px'/></math>";
-  document.body.appendChild(div);
-  box = div.firstChild.firstChild.getBoundingClientRect();
-  document.body.removeChild(div);
-  return Math.abs(box.height - 23) <= 1  && Math.abs(box.width - 77) <= 1;
-}
+
<script src="http://fred-wang.github.io/mathml.css/mspace.js"></script>
+

If you need more complex constructions, you might instead consider using the heavier MathJax library as a MathML polyfill:

+
<script src="http://fred-wang.github.io/mathjax.js/mpadded.js"></script>
+

Note that these two scripts perform feature detection of the mspace or mpadded elements (see the browser compatibility table on these pages). If you don't want to use this link to GitHub but instead to integrate these polyfills or others in your own project, you might need the detection scripts to verify the level of MathML support. For example the following function verifies the MathML support by testing the mspace element (you may replace mspace with mpadded):

+
 function hasMathMLSupport() {
+  var div = document.createElement("div"), box;
+  div.innerHTML = "<math><mspace height='23px' width='77px'/></math>";
+  document.body.appendChild(div);
+  box = div.firstChild.firstChild.getBoundingClientRect();
+  document.body.removeChild(div);
+  return Math.abs(box.height - 23) <= 1  && Math.abs(box.width - 77) <= 1;
+}

Alternatively, the following UA string sniffing will allow to detect the rendering engines with native MathML support (Gecko and WebKit). Note that UA string sniffing is not the most reliable method and might break from version to version:

-
var ua = navigator.userAgent;
-var isGecko = ua.indexOf("Gecko") > -1 && ua.indexOf("KHTML") === -1 && ua.indexOf('Trident') === -1;
-var isWebKit = ua.indexOf('AppleWebKit') > -1 && ua.indexOf('Chrome') === -1;
+
var ua = navigator.userAgent;
+var isGecko = ua.indexOf("Gecko") > -1 && ua.indexOf("KHTML") === -1 && ua.indexOf('Trident') === -1;
+var isWebKit = ua.indexOf('AppleWebKit') > -1 && ua.indexOf('Chrome') === -1;

 

Mathematical fonts

Note: browsers can only use a limited set of mathematical fonts to draw stretchy MathML operators. However, implementation of the OpenType MATH table is in progress in Gecko & WebKit. This will provide a generic support for mathematical fonts and simplify the settings described in this section.

-

To get a good mathematical rendering in browsers, some MathML fonts are required. It's a good idea to provide to your visitors a link to the MDN page that explains how to install MathML fonts. Alternatively, you can just make them available as Web fonts. You can get these fonts from the MathML-fonts add-on ; the xpi is just a zip archive that you can fetch and extract for example with the following command:

-
wget https://addons.mozilla.org/firefox/downloads/latest/367848/addon-367848-latest.xpi -O mathml-fonts.zip; \
-unzip mathml-fonts.zip -d mathml-fonts
+

To get a good mathematical rendering in browsers, some MathML fonts are required. It's a good idea to provide to your visitors a link to the MDN page that explains how to install MathML fonts. Alternatively, you can just make them available as Web fonts. You can get these fonts from the MathML-fonts add-on ; the xpi is just a zip archive that you can fetch and extract for example with the following command:

+
wget https://addons.mozilla.org/firefox/downloads/latest/367848/addon-367848-latest.xpi -O mathml-fonts.zip; \
+unzip mathml-fonts.zip -d mathml-fonts

Then copy the mathml-fonts/resource/ directory somewhere on your Web site and ensure that the woff files are served with the correct MIME type. Finally, include the mathml-fonts/resource/mathml.css style sheet in your Web pages, for example by adding the following rule to the default style sheet of your Web site:

-
@import url('/path/to/resource/mathml.css');
+
@import url('/path/to/resource/mathml.css');

You then need to modify the font-family on the <math> elements and, for Gecko, the on ::-moz-math-stretchy pseudo element too. For example to use STIX fonts:

math {
   font-family: STIXGeneral;
@@ -65,32 +65,32 @@ unzip mathml-fonts.zip -d mathml-fonts
font-family: STIXNonUnicode, STIXSizeOneSym, STIXSize1, STIXGeneral; }
-

Try the MathML torture test to compare the rendering of various fonts and the CSS rules to select them.

+

Try the MathML torture test to compare the rendering of various fonts and the CSS rules to select them.

MathML in XML documents (XHTML, EPUB, etc)

If for some reason you need to use MathML in XML documents, be sure to satisfy the usual requirements: well-formed document, use of correct MIME type, MathML namespace "http://www.w3.org/1998/Math/MathML" on <math> roots. For example, the XHTML version of the previous example looks like this:
 

-
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
-  "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title>XHTML+MathML Example</title>
-</head>
-<body>
+
<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
+  "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>XHTML+MathML Example</title>
+</head>
+<body>
 
-<h1>XHTML+MathML Example</h1>
+<h1>XHTML+MathML Example</h1>
 
-  <p>
+  <p>
     Square root of two:
-    <math xmlns="http://www.w3.org/1998/Math/MathML">
-      <msqrt>
-        <mn>2</mn>
-      </msqrt>
-    </math>
-  </p>
+    <math xmlns="http://www.w3.org/1998/Math/MathML">
+      <msqrt>
+        <mn>2</mn>
+      </msqrt>
+    </math>
+  </p>
 
-</body>
-</html>
+</body> +</html>

Note that if you use MathML as a standalone .mml or .svg documents or inside an EPUB book, it may not always be possible to use MathJax as a polyfill for rendering engines without MathML support. Hence whether MathML can be handled will vary according to the tools used to read these documents.

MathML in email and instant messaging clients

Modern mail clients may send and receive emails in the HTML5 format and thus can use MathML expressions. Be sure to have the "send as HTML" and "view as HTML" options enabled. In Thunderbird, you can use the "Insert HTML" command to paste your HTML+MathML code. MathBird is a convenient add-on for Thunderbird to insert such MathML expressions using the AsciiMath input syntax. Again, the way MathML is handled and the quality of the MathML rendering depend on the mail clients. Even if your browser supports MathML, your Webmail may prevent you to send or receive mails with MathML inside.

@@ -134,29 +134,29 @@ unzip mathml-fonts.zip -d mathml-fonts

TeXZilla has an <x-tex> custom element, that can be used to write things like

<x-tex>\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1</x-tex>

and get it automatically converted into MathML. This is still a work-in-progress, but could be improved in the future thanks to Web Components and shadow DOM. Alternatively, you can use the more traditional Javascript parsing of expressions at load time as all the other tools in this section do.

-

One simple client-side conversion tools is ASCIIMathML. Just download the ASCIIMathML.js script and copy it to your Web site. Then on your Web pages, add a <script> tag to load ASCIIMathML and the mathematical expressions delimited by ` (grave accent) will be automatically parsed and converted to MathML:

-
<html>
-<head>
+

One simple client-side conversion tools is ASCIIMathML. Just download the ASCIIMathML.js script and copy it to your Web site. Then on your Web pages, add a <script> tag to load ASCIIMathML and the mathematical expressions delimited by ` (grave accent) will be automatically parsed and converted to MathML:

+
<html>
+<head>
 ...
-<script type="text/javascript" src="ASCIIMathML.js"></script>
+<script type="text/javascript" src="ASCIIMathML.js"></script>
 ...
-</head>
-<body>
+</head>
+<body>
 ...
-<p>blah blah `x^2 + y^2 = r^2` blah ...
-...
-

LaTeXMathML is a similar script that allows to parse more LaTeX commands. The installation is similar: copy LaTeXMathML.js and LaTeXMathML.standardarticle.css, add links in the header of your document and the LaTeX content of your Web page marked by the "LaTeX" class will be automatically parsed and converted to HTML+MathML:

-
<head>
+<p>blah blah `x^2 + y^2 = r^2` blah ...
+...
+

LaTeXMathML is a similar script that allows to parse more LaTeX commands. The installation is similar: copy LaTeXMathML.js and LaTeXMathML.standardarticle.css, add links in the header of your document and the LaTeX content of your Web page marked by the "LaTeX" class will be automatically parsed and converted to HTML+MathML:

+
<head>
 ...
-<script type="text/javascript" src="LaTeXMathML.js"></script>
-<link rel="stylesheet" type="text/css" href="LaTeXMathML.standardarticle.css" />
+<script type="text/javascript" src="LaTeXMathML.js"></script>
+<link rel="stylesheet" type="text/css" href="LaTeXMathML.standardarticle.css" />
 ...
-</head>
+</head>
 
-<body>
+<body>
 ...
 
-<div class="LaTeX">
+<div class="LaTeX">
 \documentclass[12pt]{article}
 
 \begin{document}
@@ -170,26 +170,26 @@ This is a sample LaTeXML document.
 
 \section{First Section}
 
-  $$ \sum_{n=1}^{+\infty} \frac{1}{n^2} = \frac{\pi^2}{6} $$
+  $ \sum_{n=1}^{+\infty} \frac{1}{n^2} = \frac{\pi^2}{6} $
 
 \end{document}
-</div>
-...
-

jqMath is another script to parse a simple LaTeX-like syntax but which also accepts non-ASCII characters like  √{∑↙{n=1}↖{+∞} 6/n^2} = π  to write n = 1 + 6 n 2 = π . The installation is similar: download and copy the relevant Javascript and CSS files on your Web site and reference them in your page header (see the COPY-ME.html file from the zip archive for an example). One of the advantage of jqMath over the previous scripts is that it will automatically add some simple CSS rules to do the mathematical layout and make the formulas readable on browsers with limited MathML support.

-

Another way to work around the lack of MathML support in some browsers is to use MathJax. However, note that you may find conflicts and synchronization issues between MathJax and the Javascript libraries previously mentioned. So if you really want to use MathJax as a MathML polyfill, you'd better use its own LaTeX/ASCIIMath parsers too. Note that on the one hand MathJax has better parsing and rendering support but on the other hand it is much bigger, more complex and slower than the previous Javascript libraries. Fortunately, you can use MathJax's CDN so that you don't need to install it on your Web server. Also, the slowest part of MathJax is currently its HTML-CSS / SVG output modes so we recommend to use the Native MathML output for Gecko-based browsers. Hence a typical configuration to use the AMS-LaTeX input is:

-
...
-    <script type="text/x-mathjax-config">
-      MathJax.Hub.Config({
-        MMLorHTML: { prefer: { Firefox: "MML" } }
-      });
-    </script>
-    <script type="text/javascript"
-            src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
-   </script>
-  </head>
-  <body>
+</div>
+...
+

jqMath is another script to parse a simple LaTeX-like syntax but which also accepts non-ASCII characters like  √{∑↙{n=1}↖{+∞} 6/n^2} = π  to write n = 1 + 6 n 2 = π . The installation is similar: download and copy the relevant Javascript and CSS files on your Web site and reference them in your page header (see the COPY-ME.html file from the zip archive for an example). One of the advantage of jqMath over the previous scripts is that it will automatically add some simple CSS rules to do the mathematical layout and make the formulas readable on browsers with limited MathML support.

+

Another way to work around the lack of MathML support in some browsers is to use MathJax. However, note that you may find conflicts and synchronization issues between MathJax and the Javascript libraries previously mentioned. So if you really want to use MathJax as a MathML polyfill, you'd better use its own LaTeX/ASCIIMath parsers too. Note that on the one hand MathJax has better parsing and rendering support but on the other hand it is much bigger, more complex and slower than the previous Javascript libraries. Fortunately, you can use MathJax's CDN so that you don't need to install it on your Web server. Also, the slowest part of MathJax is currently its HTML-CSS / SVG output modes so we recommend to use the Native MathML output for Gecko-based browsers. Hence a typical configuration to use the AMS-LaTeX input is:

+
...
+    <script type="text/x-mathjax-config">
+      MathJax.Hub.Config({
+        MMLorHTML: { prefer: { Firefox: "MML" } }
+      });
+    </script>
+    <script type="text/javascript"
+            src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
+   </script>
+  </head>
+  <body>
    \[ \tau = \frac{x}{y} + \sqrt{3} \]
-...
+...

Note that the dollar delimiters are not used by default. To use the ASCIIMathML input instead, just replace TeX-AMS-MML_HTMLorMML by AM-MML_HTMLorMML.  MathJax has many other features, see the MathJax documentation for further details.

Command-line Programs

An alternative way is to parse the simple syntax before publishing your web pages. That is, you use command-line programs to generate them and publish these static pages on your server.

@@ -210,14 +210,49 @@ This is a sample LaTeXML document.

TeXZilla can be used from the command line and will essentially have the same support as itex2MML described below. However, the stream filter behavior is not implemented yet.

-

If you only want to parse simple LaTeX mathematical expressions, you might want to try tools like itex2MML or Blahtex. The latter is often available on Linux distributions. Let's consider the former, which was originally written by Paul Gartside at the beginning of the Mozilla MathML project and has been maintained by Jacques Distler since then. It's a small stream filter written in C/C++ and generated with flex and bison ; in particular it is very fast. Install flex/bison as well as the classical compiler and make tools. On Unix, you can then download itex2MML, build and install it:

-
wget http://golem.ph.utexas.edu/~distler/blog/files/itexToMML.tar.gz; \
+

If you only want to parse simple LaTeX mathematical expressions, you might want to try tools like itex2MML or Blahtex. The latter is often available on Linux distributions. Let's consider the former, which was originally written by Paul Gartside at the beginning of the Mozilla MathML project and has been maintained by Jacques Distler since then. It's a small stream filter written in C/C++ and generated with flex and bison ; in particular it is very fast. Install flex/bison as well as the classical compiler and make tools. On Unix, you can then download itex2MML, build and install it:

+
wget http://golem.ph.utexas.edu/~distler/blog/files/itexToMML.tar.gz; \
 tar -xzf itexToMML.tar.gz; \
 cd itex2MML/itex-src;
 make
-sudo make install
+sudo make install

Now suppose that you have a HTML page with TeX fragments delimited by dollars:

-
input.html
+
input.html
+
+...
+</head>
+<body>
+  <p>$\sqrt{a^2-3c}input.html
+
+...
+</head>
+<body>
+  <p>$\sqrt{a^2-3c}input.html
+
+...
+</head>
+<body>
+  <p>$\sqrt{a^2-3c}input.html
+
+...
+</head>
+<body>
+  <p>$\sqrt{a^2-3c}$</p>
+  <p>$$ {\sum_{i=1}^N i} = \frac{N(N+1)}{2} $$</p>
+</body>
+</html>lt;/p>
+  <p>$ {\sum_{i=1}^N i} = \frac{N(N+1)}{2} $</p>
+</body>
+</html>lt;/p>
+  <p>$ {\sum_{i=1}^N i} = \frac{N(N+1)}{2} $</p>
+</body>
+</html>lt;/p>
+  <p>$ {\sum_{i=1}^N i} = \frac{N(N+1)}{2} input.html
+
+...
+</head>
+<body>
+  <p>$\sqrt{a^2-3c}input.html
 
 ...
 </head>
@@ -225,18 +260,23 @@ sudo make install
<p>$\sqrt{a^2-3c}$</p> <p>$$ {\sum_{i=1}^N i} = \frac{N(N+1)}{2} $$</p> </body> -</html>
+</html>lt;/p> + <p>$ {\sum_{i=1}^N i} = \frac{N(N+1)}{2} $</p> +</body> +</html>lt;/p> +</body> +</html>

Then to generate the HTML page input.html with TeX expressions replaced by MathML expressions, just do

cat input.html | itex2MML > output.html

There are even more sophisticated tools to convert arbitrary LaTeX documents into HTML+MathML. For example TeX4ht is often included in TeX distributions and has an option to use MathML instead of PNG images. This command will generate an XHTML+MathML document foo.xml from a foo.tex LaTeX source:

   mk4ht mzlatex foo.tex # Linux/Mac platforms
    mzlatex foo.tex       # Windows platform
 
-

LaTeXML is another tool that is still actively developed but the release version is rather old, so you'd better install the development version. In particular, this version can generate HTML5 and EPUB documents. Here is the command to execute in order to create a foo.html Web page from the foo.tex LaTeX source:

+

LaTeXML is another tool that is still actively developed but the release version is rather old, so you'd better install the development version. In particular, this version can generate HTML5 and EPUB documents. Here is the command to execute in order to create a foo.html Web page from the foo.tex LaTeX source:

  latexml --dest foo.xml foo.tex
   latexmlpost --dest foo.html --format=html5 foo.xml
 
-

If you want to have a MathJax fallback for non-Gecko browsers, copy the Javascript lines given above into a mathjax.js file and use the --javascript parameter to tell LaTeXML to include that file:

+

If you want to have a MathJax fallback for non-Gecko browsers, copy the Javascript lines given above into a mathjax.js file and use the --javascript parameter to tell LaTeXML to include that file:

  latexmlpost --dest foo.html --format=html5 --javascript=mathjax.js foo.xml
 

If your LaTeX document is big, you might want to split it into several small pages rather putting everything in a single page. This is especially true if you use the MathJax fallback above, since in that case MathJax will take a lot of time to render the equations in non-Gecko browsers. Use the --splitat parameter for that purpose. For example, this will split the pages at the \section level:

@@ -258,20 +298,19 @@ sudo make install -

TeXZilla can be used as a Web server in order to perform server-side LaTeX-to-MathML conversion. LaTeXML can also be used as a deamon to run server-side. Mathoid is another tool based on MathJax that is also able to perform additional MathML-to-SVG conversion.

+

TeXZilla can be used as a Web server in order to perform server-side LaTeX-to-MathML conversion. LaTeXML can also be used as a deamon to run server-side. Mathoid is another tool based on MathJax that is also able to perform additional MathML-to-SVG conversion.

Instiki is a Wiki that integrates itex2MML to do server-side conversion. In future versions, MediaWiki will support server-side conversion too.

Graphical Interface

Input Box

-

TeXZilla has several interfaces, including a CKEditor plugin used on MDN, an online demo, a Firefox add-on or a FirefoxOS Webapp. Abiword contains a small equation editor, based on itex2MML. Bluegriffon is a mozilla-based Wysiwyg HTML editor and has an add-on to insert MathML formulas in your document, using ASCII/LaTeX-like syntax.

-

BlueGriffon

+

TeXZilla has several interfaces, including a CKEditor plugin used on MDN, an online demo, a Firefox add-on or a FirefoxOS Webapp. Abiword contains a small equation editor, based on itex2MML. Bluegriffon is a mozilla-based Wysiwyg HTML editor and has an add-on to insert MathML formulas in your document, using ASCII/LaTeX-like syntax.

+

BlueGriffon

WYSIYWG Editors

-

Firemath is an extension for Firefox that provides a WYSIWYG MathML editor. A preview of the formula is displayed using the rendering engine of Mozilla. The generated MathML code is available at the bottom. Use the text field for token elements and buttons to build advanced constructions. Once you are done, you can save your document as a XHTML page.

-

OpenOffice and LibreOffice have an equation editor (File → New → Formula). It is semi-WYSIWYG: you enter the source of the formula using the equation panel/keyboard and a preview of the formula is regularly refreshed. The editor uses its own syntax "StarMath" for the source but MathML is also generated when the document is saved. To get the MathML code, save the document as mml and open it with any text editor. Alternatively, you can extract the odf file (which is actually a zip archive) and open an xml file called content.xml.

-

Open Office Math

-

Amaya is the W3C's web editor, which is able to handle MathML inside XHTML documents. Use the Elements and the Special Chars panels to create various advanced mathematical constructs. Simple text such as a+2 is automatically parsed and the appropriate MathML markup is generated. Once you are done, you can directly save your XHTML page and open it in Mozilla.

+

Firemath is an extension for Firefox that provides a WYSIWYG MathML editor. A preview of the formula is displayed using the rendering engine of Mozilla. The generated MathML code is available at the bottom. Use the text field for token elements and buttons to build advanced constructions. Once you are done, you can save your document as a XHTML page.

+

OpenOffice and LibreOffice have an equation editor (File → New → Formula). It is semi-WYSIWYG: you enter the source of the formula using the equation panel/keyboard and a preview of the formula is regularly refreshed. The editor uses its own syntax "StarMath" for the source but MathML is also generated when the document is saved. To get the MathML code, save the document as mml and open it with any text editor. Alternatively, you can extract the odf file (which is actually a zip archive) and open an xml file called content.xml.

+

Open Office Math

+

Amaya is the W3C's web editor, which is able to handle MathML inside XHTML documents. Use the Elements and the Special Chars panels to create various advanced mathematical constructs. Simple text such as a+2 is automatically parsed and the appropriate MathML markup is generated. Once you are done, you can directly save your XHTML page and open it in Mozilla.

Optical Character & Handwriting Recognition

-

Inftyreader is able to perform some Optical Character Recognition, including translation of mathematical equations into MathML. Other tools can do handwriting recognition such as the Windows Math Input Panel

-

Windows Math Input Panel

+

Inftyreader is able to perform some Optical Character Recognition, including translation of mathematical equations into MathML. Other tools can do handwriting recognition such as the Windows Math Input Panel

or the online converter Web Equation.

 

Original Document Information

@@ -279,7 +318,7 @@ sudo make install

 

-- cgit v1.2.3-54-g00ecf