math_spec.typeset.markdown
GitHub-flavoured Markdown. The format that renders where the docs already live.
Markdown has no math of its own — GitHub delegates to MathJax, which eats
LaTeX — so this is not a third spelling: it forwards every math method to
:class:LatexFormat and writes only the document layer.
Forwarding rather than subclassing, deliberately. Inheritance would silently
inherit a method later added to LatexFormat, and the two differ precisely
in the document methods, so the silent case is a \paragraph in a
Markdown file. Written out, a new seam method is simply missing until someone
decides which side it belongs on.
It exists because docs/examples/ would otherwise write its math by hand with
nothing checking it against the model beside it — see
test_the_gallery_math_is_current.
MarkdownFormat
#
See :class:math_spec.typeset.format.Format. Math is LaTeX's; prose is not.
dash = '—'
class-attribute
#
notation = 'latex'
class-attribute
#
operators = {**LatexFormat.operators, 'forall': '\\forall\\thinspace', 'such_that': '\\thinspace:\\thinspace'}
class-attribute
#
suffix = '.md'
class-attribute
#
apply(function, argument)
#
cardinality(inner)
#
cases(arms)
#
LaTeX's block, with TeX's own row primitive in place of \\.
Markdown's escape pass eats one of the two backslashes, so MathJax
would receive a single one and never break the row. \\cr is what
\\ expands to anyway, and carries no punctuation to escape.
Source code in src/math_spec/typeset/markdown.py
document(blocks, *, standalone)
#
Markdown has no preamble, so standalone only adds a heading.
A fragment is meant to be pasted under a heading the page already has.
Source code in src/math_spec/typeset/markdown.py
equations(lines, *, numbered)
#
One display block per equation, with the name outside the math.
Not LaTeX's aligned, for two reasons that only show up in a
browser: a name is not math (\text{total\_cost} renders its
\_ escape literally under MathJax, where a backtick span outside
the math does not), and aligned columns align across rows, which
a page showing one equation per heading has nothing to line up against.
numbered is accepted and ignored — aligned cannot carry numbers,
and producing something that looks numbered and is not would be worse.
Source code in src/math_spec/typeset/markdown.py
escape(prose)
#
fraction(numerator, denominator)
#
glossary(title, entries)
#
greek(name)
#
italic(name)
#
joined(parts, operator)
#
a op b op c, with \enspace as the bare separator.
LaTeX's ,\ would be safe here too — a backslash before a space
is not a Markdown escape — but spelling it \enspace says why
without the reader having to know that.