![]() |
Converters for Html and MathML | ![]() |
TeXmacs supports reasonably good converters to Html and MathML. A document can be exported to Html using File\(\rightarrow\)Export\(\rightarrow\)Html. TeXmacs makes moderate use of Css in order to improve the presentation of the generated Html.
The way in which mathematical formulas are exported is chosen using Edit\(\rightarrow\)Preferences\(\rightarrow\)Converters\(\rightarrow\)TeXmacs->Html\(\rightarrow\)Mathematical formulas:
Formulas are typeset by TeXmacs at the time of the export and written as Svg in the page, in the fonts of the document and in the environment where they are, together with their source, for importing the page back, and a hidden MathML version for screen readers. The page needs no scripts or web fonts.
Formulas are written in LaTeX and typeset by the MathJax script when the page is read in a browser.
Formulas are exported as MathML. Notice that this requires you to save the generated documents using the .xhtml extension.
This is the default. If your destination file is called name.html, then the images are stored in the same directory in files name-1.png, name-2.png and so on.
TeXmacs does its best in order to render formulas using existing Html/Css primitives.
Even when formulas are not exported as images, notice that all graphics drawn using TeXmacs are exported in this way. In particular, the exportation of a TeXmacs file with pictures may give rise to the creation of additional image files. You may also force arbitrary content to be exported as an image using Format\(\rightarrow\)Specific\(\rightarrow\)Image.
TeXmacs also provides a facility for the creation of entire websites. For this, you just have to regroup the files for your website into a single directory. Using Tools\(\rightarrow\)Web\(\rightarrow\)Create website you may now convert all TeXmacs files in this directory to Html files in a new directory. The conversion procedure recursively traverses all subdirectories and all non-TeXmacs files are simply copied.
The following TeXmacs environment variables can be used to customize the Html generation:
The title of your exported document.
A cascaded style sheet for your exported document.
An external Javascript file to be executed before the body.
A Javascript script to be executed before the body.
A “favicon” for your webpage.
You may also use the following macros:
Associate a CSS class to the content body, optionally inside a separate div tag.
Associate a CSS style to the content body, optionally inside a separate div tag.
Execute a Javascript script from the file src.
Execute the Javascript script code.
In addition, given a macro my-tag, you may customize the rendering of the tag when exporting to Html by defining a macro tmhtml-my-tag with the same number of arguments. For instance, by putting the declaration
<assign|tmhtml-strong|<macro|body|<with|color|red|font-series|bold|body>>> |
inside your style file, all strong text will be exported to Html using a bold red font.
TeXmacs also contains an input converter for Html/Mathml. Most of HTML 2.0 and parts of HTML 3.0 are currently supported, and standalone or embedded MathML are reasonably well supported. Entire Html and/or Mathml documents can be imported with File\(\rightarrow\)Import\(\rightarrow\)Html.
When importing HTML documents, files whose names start with http: or ftp: will be downloaded from the web using wget. If you compiled TeXmacs yourself, then you can download wget from
ftp://ftp.gnu.org/pub/gnu/wget/
In the binary distributions, we have included wget.
With most web browsers, interesting fragments of a web page can easily be imported into TeXmacs without saving the page to a file: Using the browser's "inspect" contextual menu it is easy to spot the desired fragment in the xml tree, copy it, and then paste it into TeXmacs using Edit\(\rightarrow\)Paste from\(\rightarrow\)Html. When copying Mathml formulas, the entire <math> element should be selected. In some browsers, the "inspect" functionaly needs to be activated in the preferences.