Module Text.Markdown

Library to translate markdown documents into HTML or LaTeX. The slightly restricted subset of the markdown syntax recognized by this implementation is documented in this page.

Author: Michael Hanus

Version: November 2023

Summary of exported operations:

fromMarkdownText :: String -> [MarkdownElem]  Non-deterministic 
Parse markdown document from its textual representation.
removeEscapes :: String -> String  Deterministic 
Remove the backlash of escaped markdown characters in a string.
markdownEscapeChars :: String  Deterministic 
Escape characters supported by markdown.
markdownText2HTML :: HTML a => String -> [a]  Non-deterministic 
Translate a markdown text into a (partial) HTML document.
markdownText2CompleteHTML :: String -> String -> String  Non-deterministic 
Translate a markdown text into a complete HTML text that can be viewed as a standalone document by a browser.
markdownText2LaTeX :: String -> String  Non-deterministic 
Translate a markdown text into a (partial) LaTeX document.
markdownText2LaTeXWithFormat :: (String -> String) -> String -> String  Non-deterministic 
Translate a markdown text into a (partial) LaTeX document where the first argument is a function to translate the basic text occurring in markdown elements to a LaTeX string.
markdownText2CompleteLaTeX :: String -> String  Non-deterministic 
Translate a markdown text into a complete LaTeX document that can be formatted as a standalone document.
formatMarkdownInputAsPDF :: String -> IO ()  Non-deterministic 
Format the standard input (containing markdown text) as PDF.
formatMarkdownFileAsPDF :: String -> String -> IO ()  Non-deterministic 
Format a file containing markdown text as PDF.

Exported datatypes:


MarkdownDoc

A markdown document is a list of markdown elements.

Type synonym: MarkdownDoc = [MarkdownElem]


MarkdownElem

The data type for representing the different elements occurring in a markdown document.

Constructors:

  • Text :: String -> MarkdownElem : a simple text in a markdown document
  • Emph :: String -> MarkdownElem : an emphasized text in a markdown document
  • Strong :: String -> MarkdownElem : a strongly emphaszed text in a markdown document
  • Code :: String -> MarkdownElem : a code string in a markdown document
  • HRef :: String -> String -> MarkdownElem : a reference to URL u with text s in a markdown document
  • Par :: MarkdownDoc -> MarkdownElem : a paragraph in a markdown document
  • CodeBlock :: String -> MarkdownElem : a code block in a markdown document
  • UList :: [MarkdownDoc] -> MarkdownElem : an unordered list in a markdown document
  • OList :: [MarkdownDoc] -> MarkdownElem : an ordered list in a markdown document
  • Quote :: MarkdownDoc -> MarkdownElem : a quoted paragraph in a markdown document
  • HRule :: MarkdownElem : a hoirzontal rule in a markdown document
  • Header :: Int -> String -> MarkdownElem : a level l header with title s in a markdown document

Exported operations:

fromMarkdownText :: String -> [MarkdownElem]  Non-deterministic 

Parse markdown document from its textual representation.

removeEscapes :: String -> String  Deterministic 

Remove the backlash of escaped markdown characters in a string.

markdownEscapeChars :: String  Deterministic 

Escape characters supported by markdown.

Further infos:
  • solution complete, i.e., able to compute all solutions

markdownText2HTML :: HTML a => String -> [a]  Non-deterministic 

Translate a markdown text into a (partial) HTML document.

markdownText2CompleteHTML :: String -> String -> String  Non-deterministic 

Translate a markdown text into a complete HTML text that can be viewed as a standalone document by a browser. The first argument is the title of the document.

markdownText2LaTeX :: String -> String  Non-deterministic 

Translate a markdown text into a (partial) LaTeX document. All characters with a special meaning in LaTeX, like dollar or ampersand signs, are quoted.

markdownText2LaTeXWithFormat :: (String -> String) -> String -> String  Non-deterministic 

Translate a markdown text into a (partial) LaTeX document where the first argument is a function to translate the basic text occurring in markdown elements to a LaTeX string. For instance, one can use a translation operation that supports passing mathematical formulas in LaTeX style instead of quoting all special characters.

markdownText2CompleteLaTeX :: String -> String  Non-deterministic 

Translate a markdown text into a complete LaTeX document that can be formatted as a standalone document.

formatMarkdownInputAsPDF :: String -> IO ()  Non-deterministic 

Format the standard input (containing markdown text) as PDF.

formatMarkdownFileAsPDF :: String -> String -> IO ()  Non-deterministic 

Format a file containing markdown text as PDF.