mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
Small tweaks to documentation (#1527)
This commit is contained in:
@@ -12,7 +12,7 @@ KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the we
|
||||
* **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources.
|
||||
* **Server side rendering:** KaTeX produces the same output regardless of browser or environment, so you can pre-render expressions using Node.js and send them as plain HTML.
|
||||
|
||||
KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9 - IE 11.
|
||||
KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.
|
||||
|
||||
KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://khan.github.io/KaTeX/docs/supported.html).
|
||||
|
||||
|
@@ -16,8 +16,8 @@ To avoid escaping the backslash (double backslash), you can use
|
||||
katex.render(String.raw`c = \pm\sqrt{a^2 + b^2}`, element);
|
||||
```
|
||||
|
||||
If KaTeX can't parse the expression, it throws a `ParseError`. See [handling errors](error.md)
|
||||
for configuring how to handle errors.
|
||||
If KaTeX can't parse the expression, it throws a `katex.ParseError` by default.
|
||||
See [handling errors](error.md) for configuring how to handle errors.
|
||||
|
||||
## Server side rendering or rendering to a string
|
||||
To generate HTML on the server or to generate an HTML string of the rendered math, you can use `katex.renderToString`:
|
||||
|
@@ -3,8 +3,8 @@ id: autorender
|
||||
title: Auto-render Extension
|
||||
---
|
||||
This is an extension to automatically render all of the math inside of text. It
|
||||
searches all of the text nodes in a given element for the given delimiters, and
|
||||
renders the math in place.
|
||||
searches all of the text nodes within a given element for the given delimiters,
|
||||
ignoring certain tags like `<pre>`, and renders the math in place.
|
||||
|
||||
## Usage
|
||||
This extension isn't part of KaTeX proper, so the script needs to be included
|
||||
|
@@ -2,9 +2,9 @@
|
||||
id: browser
|
||||
title: Browser
|
||||
---
|
||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9 - IE 11.
|
||||
> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11.
|
||||
|
||||
## CDN(Content Delivery Network)
|
||||
## CDN (Content Delivery Network)
|
||||
Use CDN to deliver KaTeX to your project:
|
||||
|
||||
```html
|
||||
@@ -20,15 +20,16 @@ KaTeX also provides minified versions:
|
||||
```
|
||||
|
||||
## Download & Host Things Yourself
|
||||
Download the latest version from [here](https://github.com/Khan/KaTeX/releases),
|
||||
copy `katex.js`, `katex.css`(or `katex.min.js` and `katex.min.css` to use minified
|
||||
versions) and `fonts` from `/katex`, and include like above.
|
||||
Download a [KaTeX release](https://github.com/Khan/KaTeX/releases),
|
||||
copy `katex.js`, `katex.css`
|
||||
(or `katex.min.js` and `katex.min.css` to use minified versions),
|
||||
and the `fonts` directory, and include like above.
|
||||
|
||||
You can also build from source. See [Building from Source](node.md#building-from-source)
|
||||
for more details.
|
||||
|
||||
## Bundler
|
||||
Use [`Node.js` package managers](node.md) to install KaTeX and require it in your
|
||||
Use [Node.js package managers](node.md) to install KaTeX and require it in your
|
||||
project. Then bundle using bundlers like [webpack](https://webpack.js.org/) or
|
||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet(`katex.css`)
|
||||
or include it manually.
|
||||
[rollup.js](https://rollupjs.org/). Note that you have to bundle the stylesheet
|
||||
(`katex.css`) or include it manually.
|
||||
|
@@ -3,19 +3,19 @@ id: cli
|
||||
title: CLI
|
||||
---
|
||||
|
||||
KaTeX installed [using Node.js package managers](node.md) comes with a built-in CLI
|
||||
which can be used to render TeX to HTML from the command line. By default, CLI will
|
||||
take the input from `stdin`.
|
||||
KaTeX installed [using Node.js package managers](node.md) comes with a
|
||||
built-in command-line interface (CLI) which can be used to render TeX to HTML.
|
||||
By default, CLI will take the input from standard input.
|
||||
|
||||
```bash
|
||||
npx katex
|
||||
```
|
||||
|
||||
> Above uses the `npx` command to run the locally installed executable.
|
||||
You can execute with the relative path: `./node_modules/.bin/katex`
|
||||
> Above uses the `npx` command to run the locally installed executable
|
||||
after `npm install katex`. You can also execute with the relative path:
|
||||
`./node_modules/.bin/katex`
|
||||
|
||||
> To use CLI from local clone, you need to build the project first by
|
||||
running `yarn run build`. See [Building from Source](node.md#building-from-source)
|
||||
for more details.
|
||||
> To use the CLI from local Git clone, you need to build the project first.
|
||||
See [Building from Source](node.md#building-from-source) for more details.
|
||||
|
||||
## Options
|
||||
|
@@ -4,7 +4,7 @@ title: Handling Errors
|
||||
---
|
||||
If KaTeX encounters an error (invalid or unsupported LaTeX) and `throwOnError`
|
||||
hasn't been set to `false`, then it will throw an exception of type
|
||||
`ParseError`. The message in this error includes some of the LaTeX
|
||||
`katex.ParseError`. The message in this error includes some of the LaTeX
|
||||
source code, so needs to be escaped if you want to render it to HTML.
|
||||
|
||||
In particular, you should convert `&`, `<`, `>` characters to
|
||||
@@ -15,3 +15,4 @@ attack possible if your LaTeX source is untrusted.)
|
||||
|
||||
Alternatively, you can set `throwOnError` to `false` to use built-in behavior
|
||||
of rendering the LaTeX source code with hover text stating the error.
|
||||
See [rendering options](options.md).
|
||||
|
@@ -8,7 +8,7 @@ several properties of the way fonts are used can be changed.
|
||||
## Font size and lengths
|
||||
By default, KaTeX math is rendered in a 1.21× larger font than the surrounding
|
||||
context, which makes super- and subscripts easier to read. You can control
|
||||
this using CSS, for example:
|
||||
this using CSS, for example, to set to 1.1×:
|
||||
|
||||
```css
|
||||
.katex { font-size: 1.1em; }
|
||||
@@ -27,7 +27,7 @@ will appear larger than 1cm in browser units.
|
||||
|
||||
The default build of KaTeX includes each of the needed fonts in three different formats: `ttf`, `woff`, and `woff2`.
|
||||
|
||||
- `ttf`s are included to support old versions of Chrome, Safari, Firefox, etc. (By old, I mean Firefox 3.5, Chrome <5, Safari <=5.1 all of which are no longer supported: see [woff](http://caniuse.com/#search=woff) vs [ttf](http://caniuse.com/#search=ttf)).
|
||||
- `ttf`s are included to support old versions of Chrome, Safari, Firefox, etc. (Here "old" means Firefox 3.5, Chrome < 5, and Safari <= 5.1, all of which are no longer supported: see [woff](http://caniuse.com/#search=woff) vs. [ttf](http://caniuse.com/#search=ttf)).
|
||||
- `woff` is the format that is most widely supported (all modern browsers support it), so it probably provides the most benefit to being included.
|
||||
- `woff2`s are included for very new versions of Chrome, because they are much smaller and faster to load.
|
||||
|
||||
@@ -37,11 +37,11 @@ For example, if you wanted to create a trimmed down version of KaTeX, you could
|
||||
|
||||
1. Set `@use-ttf`, and `@use-woff2` to `false` at the top of [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less).
|
||||
2. Rebuild KaTeX by running `yarn run build` from the top-level directory.
|
||||
3. Include only the `build/fonts/*.woff2` files in your distribution.
|
||||
3. Include only the `build/fonts/*.woff` files in your distribution.
|
||||
|
||||
## Location of font files
|
||||
|
||||
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as such:
|
||||
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as follows:
|
||||
|
||||
1. At the top of the [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
|
||||
2. Rebuild KaTeX by running `yarn run build` from the top-level directory.
|
||||
|
@@ -13,8 +13,7 @@ title: Common Issues
|
||||
`\\[0.1em]` instead of the standard line separator distance.
|
||||
- KaTeX does not support the `align` environment because LaTeX doesn't support
|
||||
`align` in math mode. The `aligned` environment offers the same functionality
|
||||
but in math mode, so use that instead or define a macro that maps `align` to
|
||||
`aligned`.
|
||||
but in math mode, so use that instead.
|
||||
- MathJax defines `\color` to be like `\textcolor` by default; set KaTeX's
|
||||
`colorIsTextColor` option to `true` for this behavior. KaTeX's default
|
||||
behavior matches MathJax with its `color.js` extension enabled.
|
||||
|
@@ -35,6 +35,6 @@ Then install dependencies and run `build` script:
|
||||
npm install # or yarn install
|
||||
npm run build # or yarn build
|
||||
```
|
||||
<br>
|
||||
|
||||
> You can manually download the package and source code from
|
||||
[GitHub releases](https://github.com/Khan/KaTeX/releases).
|
||||
|
@@ -2,7 +2,7 @@
|
||||
id: options
|
||||
title: Options
|
||||
---
|
||||
You can provide an object of options as the last argument to `katex.render` and `katex.renderToString`. Available options are:
|
||||
You can provide an object of options as the last argument to [`katex.render` and `katex.renderToString`](api.md). Available options are:
|
||||
|
||||
- `displayMode`: `boolean`. If `true` the math will be rendered in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math on the page on its own line. If `false` the math will be rendered in inline mode. (default: `false`)
|
||||
- `throwOnError`: `boolean`. If `true` (the default), KaTeX will throw a `ParseError` when it encounters an unsupported command or invalid LaTeX. If `false`, KaTeX will render unsupported commands as text, and render invalid LaTeX as its source code with hover text giving the error, in the color given by `errorColor`.
|
||||
|
Reference in New Issue
Block a user