Ornate 0.6 Manual

Math

The default theme can use MathJax to render math notation. All required resources are embedded in the generated site but the rendering is done on the client side with JavaScript. Only a [math] placeholder will be visible if JavaScript is disabled.

MathJax config files and options for a MathJax.Hub.Config call can be specified in the theme’s global configuration (under theme.default.global for the default theme):

# Configuration options for MathJax
mathJax {
  # The config files to preload:
  loadConfig = ["TeX-MML-AM_CHTML-full"]
  # A configuration object to put into the generated HTML files
  inlineConfig = {
    # The default scheme automatically schedules a `Process` command on startup when
    # this option is set. This avoids running any preprocessors that may have been
    # loaded (but are not needed because Ornate creates `script` tags for MathJax's
    # main processing step).
    skipStartupTypeset: true
  }
}
ornate-reference.conf

This default configuration disables preprocessing (which is not needed if you use Ornate’s math syntax extensions) and preloads a config file with everything that is needed for rendering TeX, AsciiMath and MathML. Since Ornate only adds MathJax to pages that actually need it, the use of a -full config file is recommended. If you only need AsciiMath notation, you can use the smaller AM_CHTML-full configuration.

Fenced Code Blocks

Fenced code blocks whose info string starts with the language codes texmath, asciimath (or simply math) and mathml are treated as display math instead of passing them on to the standard highlighter.

TeX example:

```texmath
\begin{array}{lcll}
\{a, A\} \;\vec{+}\; B &=& a, (A \;\vec{+}\; B)  &{\bf if} \; a \not\in B \\\\
                       &=& A \;\vec{+}\; B       &{\bf if} \; a \in B
\end{array}
```

This is rendered as:

[math]

AsciiMath example:

```math
sum_(i=1)^n i^3=((n(n+1))/2)^2
```

This is rendered as:

[math]

mathSyntax extension

The mathSyntax extension enables special syntax for inline and display (block) math. There is no single standard notation for math in Markdown, therefore it can be customized to support several common notations:

extension.mathSyntax {
  # The following options control the supported delimiters for inline and display (block)
  # math syntax. Each can be set to one of "tex", "asciimath" or null (disabled).
  dollarInline     = null # Single dollar inline, like Pandoc's tex_math_dollars
  dollarBlock      = null # Double dollar blocks
  singleBackslash  = null # Single backslash `\(inline\)` and `\[display\]`
  doubleBackslash  = null # Double backslash `\\(inline\\)` and `\\[display\\]`
  dollarInlineCode = null # Single dollar at beginning and end of inline code
  dollarFenced     = null # Single dollar for inline math in fenced code blocks
}
ornate-reference.conf

The mathSyntax extension is enabled by default but all notations are disabled.

  • dollarInline: Standard TeX inline math notation, with the same syntax as Pandoc’s tex_math_dollars extension: Anything between two $ characters is treated as math. The opening $ must have a non-space character immediately to its right, while the closing $ must have a non-space character immediately to its left, and must not be followed immediately by a digit. If for some reason you need to enclose text in literal $ characters, backslash-escape them and they won’t be treated as math delimiters.

    Example:

    Here is some inline math $a+b$ but neither is `$a+b$` nor $20,000 and $30,000, nor \$a+b\$.
    

    This is rendered as:

    Here is some inline math [math] but neither is $a+b$ nor $20,000 and $30,000, nor $a+b$.

    Note that the inline math notation is parsed before any other inline notation, in particular before inline code. This can have unwanted side effects when using the single dollar syntax. For example, when placing another inline code section `$a+b$` at the end of the previous paragraph, everything from $20,000 to the first $ of the inline code section would be recognized as inline math.

  • dollarBlock: Standard TeX display math notation. Blocks delimited by $$ are treated as display math.

    Example:

    $$ \lim_{x \to \infty} \exp(-x) = 0 $$
    

    This is rendered as:

    [math]
  • singleBackslash: Standard LaTeX notation for \(inline\) and \[display\] math.

  • doubleBackslash: MultiMarkdown’s adaptation of LaTeX notation for \\(inline\\) and \\[display\\] math.

  • dollarInlineCode: Inline code blocks with $ characters at the beginning and end like `$a+b$` are parsed as inline math. The initial $ can be escaped as \$ to prevent math parsing.

  • dollarFenced: Standard TeX inline math notation (like with dollarInline) in fenced code blocks. The usual highlighting will be applied to such blocks. In order to minimize unwanted interaction of the highlighter with the unexpected math notation, inline math appears as a regular ASCII identifier to the highlighter. The real math notation is spliced back in after highlighting. This setting can be configured individually for each fenced code block with dollarMath=tex|asciimath|null in the info string.

    For example:

    ```scala dollarMath=tex
    def copy[$\mathit{tps}\,$]($\mathit{ps}'_1\,$)$\ldots$($\mathit{ps}'_n$): $c$[$\mathit{tps}\,$] = new $c$[$\mathit{Ts}\,$]($\mathit{xs}_1\,$)$\ldots$($\mathit{xs}_n$)
    ```
    

    This is rendered as:

    def copy[[math]]([math])[math]([math]): [math][[math]] = new [math][[math]]([math])[math]([math])