This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

 Documentation /  Mathematica /  Eingebaute Funktionen /  Neu in Version 3.0 /  Eingabe und Ausgabe /

Compile (geändert)TeXSave

HTMLSave

FilledSmallSquare HTMLSave["datei.html"] speichert eine HTML-Version des aktuell in der Benutzeroberfläche gewählten Notebooks.

FilledSmallSquare HTMLSave["datei.html", "quelle.nb"] speichert eine HTML-Version des Notebooks aus der Datei quelle.nb.

FilledSmallSquare HTMLSave["datei.hmtl", notebook] speichert eine HTML-Version des Notebooks, das dem spezifizierten Notebook-Objekt entspricht.

FilledSmallSquare HTMLSave hat Optionen, mit denen Eigenschaften spezifiziert werden können, wie man zum Beispiel Formeln mit einbezieht, ob Links für geschlossene Zellen-Gruppen gemacht werden sollen und welche Verbindung zwischen Notebook-Stilen und HTML-Marken konstruiert werden sollen.

FilledSmallSquare HTMLSave speichert Grafik normalerweise in separaten Bild-Dateien.

FilledSmallSquare Auf HTMLSave kann häufig über einen Befehl im Menü Speichern unter (spezial) (Save As Special) in der Notebook-Benutzeroberfläche zugegriffen werden.

FilledSmallSquare Siehe Das Mathematica Buch: 1.11.7.

FilledSmallSquare Siehe auch: TeXSave, Display.

Additional Information

Introduction

Mathematica can translate notebooks, as well as cells, lists of cells, boxes, or other notebook elements into HTML. HTMLSave wraps the input in a notebook before conversion. Therefore, the output of HTMLSave is always a complete HTML document, and not merely a fragment of HTML.

Invoking HTMLSave

You may invoke HTMLSave from the File Save As Special menu command in the notebook front end. You may also invoke HTMLSave from the kernel if it is connected to a notebook front end. The front end converts typeset expressions or graphs to GIFs and provides document settings (such as style sheet information) to HTMLSave.

HTMLSave Options

When you invoke HTMLSave from the kernel, you may set the option ConversionOptions.

The option ConversionOptions for HTMLSave.

HTMLSave Output

The output produced by HTMLSave conforms to the HTML 4 standard. The output consists of one or more HTML files and two directories, Images and Links. When using the Save As Special menu command, a dialog box appears for specifying the name of the file. When using the kernel, you name the output via the first argument to HTMLSave. If you do not provide an extension to the name given to the output (for example, index.html), HTMLSave creates a directory by the name you provided. This directory then contains the HTML files and the Images and Links directories.

HTMLSave writes out nearly all inline typeset expressions and many block-level typeset expressions as GIF files. There are two general exceptions:

1. Choosing HTMLSave from the File Save As Special submenu (or using MathOutput -> MathML option from the kernel) writes out the expression marked up with MathML tags.

2. If a GridBox is the top level of a cell, an HTML table will be generated.

Hyperlinks

HTMLSave uses hyperlinks in your Mathematica notebook to generate HTML links and produce additional HTML documents. For example, if you have a link to a notebook called notebook2.nb in the notebook you are converting via HTMLSave, Mathematica converts the Mathematica hyperlink to an HTML hyperlink and converts the notebook notebook2.nb to HTML.

There is one exception: links to online Mathematica documentation generate an empty hyperlink in the HTMLSave output file. If Mathematica were to convert all linked documentation, you would quickly have several hundred megabytes of HTML documentation, due to the extensive cross referencing in the online documentation. Much of the online documentation is available in HTML form on the web at www.wolfram.com.

HTMLSave also generates hyperlinks from closed cell groups. The head cell of the group becomes the hyperlink, and the remainder of the group becomes a separate HTML document.

Tables

HTMLSave writes out top-level GridBoxes as tables. GridBoxes are counted as top-level if they are in the topmost box or if they are wrapped in non-layout boxes, which are StyleBox, TagBox, and InterpretationBox.

HTML tables are block-level elements, which means that they have an explicit break or return at both the beginning and end. Since HTML tables are never block-level elements, Mathematica inline GridBoxes cannot be rendered as tables and are saved as GIFs.

Principles of Notebook Conversion

HTML is a markup language rather than a document layout language. This means that it defines elements by their purpose in the document (for example, title, list element, and so on) rather than their actual appearance (for example, 14-point bold Palatino).

You should always mark up elements according to their purpose. If you must add appearance tags, such as <B> and <FONT>, use them in addition to structural tags, such as <CODE> or <EM>. For the difference between appearance and structural tags, consult any introductory HTML book.

Here is a cell expression that uses the Subsubsection style.

Cell[TextData["Principles of Notebook Conversion"], "Subsubsection"]

This is the corresponding output written to the HTML file after conversion.

<H5>Principles of Notebook Conversion</H5>

The output does not explicitly specify the font choice or other aspects of its appearance. Subsubsection items in Mathematica under the default style sheet appear in 12-point bold Times with a small filled square cell dingbat, but different browsers will display a level 5 heading quite differently.

For cells that contain two-dimensional typeset math expressions, HTMLSave generates a GIF. Selecting HTML/MathML from the File Save As Special menu (or using MathOutput -> MathML option from the kernel) writes out the expression marked up with MathML tags.

Here is a cell expression that uses the Text style and contains aTraditionalForm inline cell.

Cell[TextData[

"The Pythagorean theorem states that ",

Cell[BoxData[

FormBox[

RowBox[

SuperscriptBox["c", "2"], "=", " ",

RowBox[

SuperscriptBox["a",

RowBox["2", " "]], "+", " ",

SuperscriptBox["b", "2"]]], TraditionalForm]]],

"."

], "Text"]

This is what is written to the HTML output file using File Save As Special HTML.

<P> The Pythagorean theorem states that <IMG

SRC="Images/inline1_gr_1.gif"

BORDER="0" ALT="[Graphics:Images/inline1_gr_1.gif]" WIDTH="73"

HEIGHT="17"

ALIGN="absmiddle" >. </P>

This is what is written to the HTML output file using File Save As Special HTML/MathML.

<P> The Pythagorean theorem states that

<math>

<mrow>

<msup>

<mi>c</mi>

<mn>2</mn>

</msup>

<mo>=</mo>

<mrow>

<msup>

<mi>a</mi>

<mrow>

<mn>2</mn>

</mrow>

</msup>

<mo>+</mo>

<msup>

<mi>b</mi>

<mn>2</mn>

</msup>

</mrow>

</mrow>

</math>

. </P>

Adjusting Output via Style Sheets

The output of HTMLSave can be adjusted through ConversionRules, specifying which HTML tags, or nested tags, appear in the HTML document.

Here is the general structure of ConversionRules.

ConversionRules ->

"HTML" -> "inline beginning tags", "inline ending tags",

"block-level beginning tags", "block-level ending tags".

As you can see from the form of the ConversionRule, HTML draws a strong distinction between block-level elements and inline elements. It is important when you add ConversionRules to your style definition cells to include both the inline rule (the first set of tags) as well as the block-level rule (the second set of tags). The block-level rule should have an outermost tag that is block-level, such as <P> or <DIV>. The inline rule should never have an outermost tag that is block-level.

Here is a style definition cell that contains a conversion rule for the InlineFormula style from the default style sheet.

Cell[StyleData["InlineFormula"],

other cell options, ... ,

ConversionRules ->

"HTML" -> "<B><CODE>", "</CODE></B>", "<P><B><CODE>",

"</CODE></B></P>"



]

When HTMLSave converts an item in the InlineFormula style, it wraps the item in bold and code tags if the item is inline, and adds a paragraph tag if the item is block-level.

Here is a cell expression in the InlineFormula style.

Cell[TextData["x = a + b"],

"InlineFormula"]

Here is the appearance of the converted cell in the HTML output file.

<B><CODE>x = a + b</CODE></B>

Getting Updates to the Source Code

Despite the large number of options for adjusting HTMLSave output via style sheet conversion rules, there may be circumstances where you need to make changes at a deeper level. Since HTMLSave is implemented as top-level Mathematica code, the source code is available in Mathematica package format.

The package can be downloaded from the web at www.wolfram.com/support/FrontEnds/Export/HTML/.

Compile (geändert)TeXSave