Technologies ›

Wolfram Notebook Technology

File Extensions and MIME Types

Wolfram Notebooks are structured interactive documents that may contain text, graphics, sound, calculations, typeset expressions, and user interface elements. Notebooks have the file extension .nb and can be accessed and edited on the desktop, mobile, and cloud devices. Files of this type are automatically associated with Wolfram Language applications, such as Mathematica, on systems where Wolfram Language applications are installed. To view the complete documentation for the Wolfram Language on the web, go to the Wolfram Language & System Documentation Center.

CDF files are a specially created subset of notebooks to be used with Wolfram CDF Player. (CDF files also work in other Wolfram Language products.) CDF Player is a freely downloadable player. CDF files are "signed" versions of Wolfram Notebooks.

.nb file extension for Wolfram Notebooks
.cdf file extension for CDF Player files
File extensions for notebooks.

There are two MIME types for Wolfram Notebooks and CDF files. Altering these can effectively change the application in which notebook files are opened. It is possible to configure your web browser to automatically launch notebook files in Mathematica by associating Mathematica with these MIME types.

.nb application/vnd.wolfram.mathematica
.cdf application/vnd.wolfram.cdf.text
MIME types for file extensions.

File Format and Specifications

Wolfram Notebooks contain only printable, 7-bit ASCII characters and are viewable and largely human-readable in any text editor. On the desktop, one can determine the version of Mathematica or other Wolfram Language application that created a notebook by opening the notebook in a text editor and finding the line near the top that reads, for instance:

(* CreatedBy='Mathematica 10.2' *)

The notebook file format is a cross-platform format, meaning that a Wolfram Language installation on any supported platform can read and display a notebook that has been created on any other Wolfram Language installation on any other platform.

Newline Characters

Different platforms use different conventions for newline characters: LF (Mac OS X and Unix/Linux), and CR+LF (Windows). These conventions are supported in Wolfram Notebooks; the Wolfram Language interprets these newline conventions in the same way.

Caching Mechanism

A file outline cache in notebook files is used for incremental loading. The cache is automatically generated when a notebook is saved, and is stored in the file inside code comments to prevent the notebook expression from being altered. Wolfram Language code comments are delimited by (* and *).

Cache information is denoted in a notebook by lines such as the following, at the beginning and end of the file.

(* Internal Cache Information *)

If you edit a notebook in a text editor, for example, invalid cache data might be used. To prevent this, be sure to delete the line near the beginning of the file that specifies the CacheID when editing a notebook outside Wolfram Language-based products.

(*CacheID: xxx*)

Alternatively, you can choose to omit the file outline cache by changing the value of the PrivateNotebookOptions-> {"FileOutlineCache"} option.

Format Conversions and File Transfer

Wolfram Notebooks can be converted to many formats. A complete list of formats is available.

Conversion to Plain Text

To convert a notebook to plain text in desktop versions of Mathematica, open the notebook, choose File > Save As, and select Plain Text from the drop-down menu. This can be useful for making a notebook available to a document indexer, for example. Plain text conversion is scriptable using the built-in Wolfram Language functions Export and NotebookImport.

Conversion to Other Formats

Wolfram Notebooks can be converted to many other formats, such as HTML and PDF. To do this in desktop versions of Mathematica, open the notebook, choose File > Save As, and use the drop-down menu to view the various formats available. Conversions to other formats are also scriptable using the built-in Wolfram Language functions Export and NotebookImport.

Binary File Transfer

Since the Wolfram Language interprets newline conventions from all supported platforms the same way, transferring notebooks via binary file transfer has no effect on the notebook.

File Transfer as ASCII Text

Since Wolfram Notebooks are ASCII text files, they can be transferred directly via email attachment, via FTP in text mode, or using any application that transfers data in text mode.

Security

The Wolfram Language includes dynamic interactivity features that allow code to be evaluated immediately upon opening a notebook or as sections of the notebook are incrementally loaded. The Wolfram Language includes security systems that advise the user when such an evaluation is about to take place for the first time in a given notebook and allow the user to intervene and prevent any dynamic evaluations in that notebook.

Security options are defined in the front end as suboptions of the Notebook Security options. The "TrustedPath" and "UntrustedPath" suboptions define paths for notebook files in which dynamic evaluations should always be considered trusted or a security risk. The default "TrustedPath" option contains directories used directly by the Wolfram Language, including the installation directory and directories where applications are typically installed. The "UntrustedPath" option contains, by default, directories that are typically used for email attachments and web downloads. The "TrustByDefault" option determines the behavior for any notebook file that is opened from a path not listed in "TrustedPath" or "UntrustedPath".

By default, "TrustByDefault" is set to Automatic, which indicates that the front end should scan Dynamic code for symbols that are potentially dangerous, such as those that can lead to file system operations. Any dynamic evaluation containing dangerous symbols is interrupted, and the user prompted.

"TrustByDefault" can also be set to True, which causes the Wolfram Language to trust all dynamic code without flagging the user, or False, which causes the Wolfram Language to prompt the user when evaluating any dynamic code, even if the code appears to contain no dangerous symbols.

Because the notebook file format is plain text, it is mostly human-readable. However, there are ways to obfuscate the code in notebook files by using inline compression. If malicious code is hidden in an initialization cell, it is possible that the Wolfram Language will evaluate the cell immediately when the notebook is opened. To avoid this potential issue, it is highly recommended that users set the front end option InitializationCellEvaluation to False or Automatic and the option "GlobalInitializationCellWarning" to True when opening notebooks from untrusted sources.

Documentation

For additional details, see the Notebook Basics guide in the Wolfram Language & System Documentation Center.

Further Information

For more information on notebooks and Wolfram Language-compatible applications, contact Wolfram Research:

web: http://www.wolfram.com
email: info@wolfram.com
phone: +1-217-398-0700 (US)
For more information about Wolfram Language-related products and services, visit http://www.wolfram.com/products.

To download the free CDF Player, visit http://www.wolfram.com/cdf.

de es fr ja ko pt-br