Module: texme

Exported module of TeXMe.

Source:

Members

(static) tokenLiteral :string

Enumeration of special literals. Currently there is only one.

Type:
  • string
Properties:
Name Type Description
MASK string

Mask literal used to mask math content. All mathematical snippets detected in the content are replaced with this mask literal before performing Markdown rendering on it. This prevents from the Markdown renderer from seeing and processing any math content.

Source:

(static) tokenType :number

Enumeration of texme.tokenTypes.

Type:
  • number
Properties:
Name Type Description
MARK number

Markdown token

MASK number

Math token or mask-literal token

Source:

Methods

(static) main()

Set up dependencies and set page.

Source:

(static) mask(tokens) → {Object}

Construct Markdown text from the specified tokens such that any LaTeX tokens and mask-literal tokens are masked. The returned string is a masked string containing only Markdown text and no LaTeX code at all. All LaTeX code in it is masked with mask-literal. So the returned text can now be used to render the Markdown content in it to HTML without affecting any LaTeX code.

Parameters:
Name Type Description
tokens Array.<Array.<string>>

An array of tokens returned by the tokenize function.

Source:
Returns:

An object with two properties: text with the masked string as its value and tokenValues with its value as an array of original tokens that were replaced with masks in the masked string.

Type
Object

(static) protectMathAndRenderMarkdown(s) → {string}

Render Markdown content while ensuring that LaTeX content is not interpreted and rendered as Markdown.

Parameters:
Name Type Description
s string

Markdown + LaTeX content.

Source:
Returns:

Rendered HTML.

Type
string

(static) render(s)

Render Markdown and/or LaTeX content into HTML.

If the configuration option protectMath is true (the default), then LaTeX content is protected from Markdown renderer. Otherwise, the entire content is rendered as Markdown.

Parameters:
Name Type Description
s string

Markdown + LaTeX content.

Source:

(static) renderMarkdown(s) → {string}

Render Markdown content to HTML.

Parameters:
Name Type Description
s string

Markdown content.

Source:
Returns:

Rendered HTML.

Type
string

(static) renderPage()

Set page to display the rendered content as HTML.

Source:

(static) setDefaultOptions()

Set default configuration options.

Source:

(static) setOption(key, val)

Set configuration option.

Parameters:
Name Type Description
key string

Configuration option name

val object

Configuration value object

Source:

(static) tokenize(s) → {Array.<Array.<string>>}

Tokenize input text containing Markdown and LaTeX code.

Parameters:
Name Type Description
s string

Text with Markdown and LaTeX code.

Source:
Returns:

An array of tokens of the form [ [<type>, <value>], [<type>, [value], ...] ] where each token of the form [<type>, <value>] is an array of two values: tokenType and token value (string).

Type
Array.<Array.<string>>

(static) unmask(s, tokens) → {string}

Replace mask-literal tokens with the corresponding content.

Parameters:
Name Type Description
s string

A string containing mask-literals.

tokens Array.<string>

Arary of token values that were masked by the mask function. This array is available as the value of tokenValues property of the object returned by the mask function.

Source:
Returns:

Unmasked text with mask-literal tokens replaced with the original token values.

Type
string