Documentation
¶
Overview ¶
Package katex renders TeX math to HTML and MathML with KaTeX, with no browser and no Node.js.
The package embeds the minified script of one KaTeX release and runs it in goja, a JavaScript engine in pure Go. Render returns the same markup that katex.renderToString returns in a browser. The markup has two parts: HTML that looks the same in each browser, and MathML for screen readers. Thus a page shows its math with JavaScript off.
The HTML part needs the style sheet and the fonts of the same release. Assets returns them. Serve them next to the pages, and link the style sheet from each page.
Run go generate to change the release. The generator checks the tarball from npm against its published integrity.
Index ¶
Constants ¶
const Timeout = 5 * time.Second
Timeout is the longest time that one call of Render can take.
const Version = "0.19.1"
Version is the KaTeX release that the package embeds.
Variables ¶
This section is empty.
Functions ¶
func Assets ¶
Assets returns the files that the HTML of Render needs: katex.min.css, the fonts in fonts/ and the licence of KaTeX.
func MathML ¶
MathML returns the MathML element of a rendering of Render, for a browser that implements MathML Core. MathML Core draws mathvariant only as normal, so each letter and digit of a math alphabet, for example the R of \mathbb{R}, becomes its character in the Mathematical Alphanumeric Symbols block. A prime in a superscript, as in f', follows its base, because the prime glyph of a math font is already raised. Text in a math alphabet keeps its letters and gets the weight and the slant in a style. The result is "" when out has no MathML element.
Types ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer renders formulas with one set of macros. It keeps the result of each formula, so a formula that a site uses many times costs one render. Its methods are safe for concurrent use, but one Renderer renders one formula at a time.