From Markdown - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Worksheet

  

FromMarkdown

  

convert a markdown document to a Maple worksheet

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

FromMarkdown(str)

FromMarkdown(str, opts)

Parameters

str

-

the Markdown source as a string or symbol, or the path to a file that contains the Markdown source

opts

-

(optional) equation(s) of the form source = s or output = o, where s is one of string, file, or auto and o is one of xml, insert, or display

Description

• 

The FromMarkdown command converts a Markdown file to a Maple worksheet.

• 

The source document can be given as a string directly in the command, or as the name of a file that contains the source. This is determined by the source = s option:

– 

When the option source = string is given, Maple interprets str itself as the Markdown source.

– 

When the option source = file is given, Maple interprets str as the path to a file containing the Markdown source.

– 

When the option source = auto is given, Maple checks if there is a file named str (using FileTools:-Exists). If so, it acts as if source = file was given. If not, it acts as if source = string was given.

– 

The default behavior is given by the option source = auto.

• 

The result can be returned as XML, inserted into the current worksheet, or displayed as a new worksheet. This is determined by the output = o option:

– 

When the option output = xml is given, this command returns the resulting worksheet as XML. This is the only value of the output option that can be used in the command-line version of Maple.

– 

When the option output = insert is given, this command inserts the resulting worksheet into the current worksheet using the DocumentTools:-InsertContent command.

– 

When the option output = display is given, this command shows the resulting worksheet as a new, separate worksheet.

– 

The default behaviour is given by the option output = xml.

Examples

withWorksheet:

Here is how you can parse a simple Markdown string to an XML representation of a worksheet.

docThis is some *markdown*.

docThis is some *markdown*.

(1)

FromMarkdowndoc

_XML_Worksheet_XML_Groupview=presentation,hide-input=false,hide-output=false,inline-output=false,drawlabel=true,_XML_Input_XML_Text-fieldalignment=left,style=Text,layout=Normal,This is some ,_XML_Fontitalic=true,size=12,mathsize=12,mathvariant=normal,style=Text,background=[255,255,255],mathbackground=[255,255,255],foreground=[0,0,0],mathcolor=[0,0,0],family=Times New Roman,markdown,.

(2)

To insert this into the current worksheet, run this code instead.

FromMarkdowndoc,output=insert

This is some markdown.

To use a source file instead of a string, do the following. First, print the contents of the file so you can see what it looks like.

fileFileTools:-JoinPathexample,markdown.md,:-base=:-datadir:

lineFileTools:-Text:-ReadLinefile:

whilelineNULLdoprintf%s\n,line;lineFileTools:-Text:-ReadLinefileenddo:

A big heading
=============

Here is a paragraph of text with *italics* and **bold text**.

## A smaller heading

Another paragraph. Note that line
breaks and multiple      spaces are ignored. Here is a
[link](https://www.maplesoft.com/)
to Maplesoft's home page, and here is the Markdown logo:
![logo](https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Markdown-mark.svg/320px-Markdown-mark.svg.png "the logo").

Here is a third paragraph.

## Another small heading

Note that the Markdown parser also supports limited LaTeX formulas, like $(x + y)/z^2$.

FileTools:-Text:-Closefile

Now parse the file and display it as a new worksheet.

FromMarkdownfile,output=display

Error, (in Python:-ImportModule) unable to start Python: could not create process, mpython

Compatibility

See Also

DocumentTools:-InsertContent

Worksheet

Worksheet:-Display