diff --git a/CHANGELOG.md b/CHANGELOG.md index bb4d0214..e1b96fda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Changelog All notable changes to this project will be documented in this file. This CHANGELOG roughly follows the guidelines from [www.keepachangelog.com](https://keepachangelog.com/en/1.0.0/). +## [v0.11.1] +### Changed +- [Security] Bump mixin-deep from 1.3.1 to 1.3.2 (#2090) +- [Security] Bump eslint-utils from 1.3.1 to 1.4.2 (#2089) + +### Fixed +- Fix parse timing by separating consume() into fetch() and consume() (#2054) +- Use current font for accents (#2066) +- Fix \gray's macro definition (#2075) + ## [v0.11.0] ### Added - **BREAKING CHANGE:** trust setting to indicate whether input text is trusted (#1794) diff --git a/README.md b/README.md index e4e58f68..5868416e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [](https://gitter.im/KaTeX/KaTeX?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://dependabot.com) [](https://www.jsdelivr.com/package/npm/katex) - + KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. @@ -29,13 +29,13 @@ Try out KaTeX [on the demo page](https://katex.org/#demo)!
- + - + - ... diff --git a/contrib/copy-tex/README.md b/contrib/copy-tex/README.md index 90efaebb..5701fdd0 100644 --- a/contrib/copy-tex/README.md +++ b/contrib/copy-tex/README.md @@ -21,8 +21,8 @@ provided by this extension). Without this CSS, partially selected equations will just get the usual HTML copy/paste behavior. ```html - - + + ``` See [index.html](index.html) for an example. @@ -38,7 +38,7 @@ statement with `require('katex/contrib/copy-tex/katex2tex.js')`. ### Known Issues diff --git a/contrib/mathtex-script-type/README.md b/contrib/mathtex-script-type/README.md index 35e272e4..308ad89e 100644 --- a/contrib/mathtex-script-type/README.md +++ b/contrib/mathtex-script-type/README.md @@ -12,7 +12,7 @@ Load the extension by adding the following line to your HTML file. This extension should be loaded *after* all `script type=math/tex` blocks that you want to render. ```html - + ``` You can download the script and use it locally, or from a local KaTeX installation instead. @@ -23,12 +23,12 @@ After we're done writing `math/tex` scripts, we load this extension. ```html - - + + - + ``` @@ -36,5 +36,5 @@ After we're done writing `math/tex` scripts, we load this extension. diff --git a/contrib/mhchem/README.md b/contrib/mhchem/README.md index 0de2bcc1..b09146b6 100644 --- a/contrib/mhchem/README.md +++ b/contrib/mhchem/README.md @@ -7,7 +7,7 @@ This extension adds to KaTeX the `\ce` and `\pu` functions from the [mhchem](htt This extension isn't part of core KaTeX, so the script should be separately included. Write the following line into the HTML page's ``. Place it *after* the line that calls `katex.js`. ```html - + ``` ### Syntax diff --git a/docs/autorender.md b/docs/autorender.md index b17fcad7..1709218a 100644 --- a/docs/autorender.md +++ b/docs/autorender.md @@ -12,9 +12,9 @@ This extension isn't part of KaTeX proper, so the script needs to be included using a CDN: ```html - - - + ``` @@ -31,9 +31,9 @@ want to use a `defer` or `onload` attribute. For example: ```html - - - + + + ``` diff --git a/docs/browser.md b/docs/browser.md index acfe2ddd..9b6619ef 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -11,13 +11,13 @@ title: Browser - + - + - ... @@ -29,15 +29,15 @@ If you include the `katex.js` directly, the `katex` object will be available as a global variable. ```html - - + + ``` KaTeX also provides minified versions: ```html - - + + ``` The examples above load the script [deferred using the `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes) @@ -81,22 +81,22 @@ for more detail. ```html - + ``` ### ECMAScript module ```html - - + + ``` > Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes) diff --git a/website/versioned_docs/version-0.11.1/autorender.md b/website/versioned_docs/version-0.11.1/autorender.md new file mode 100644 index 00000000..4a065806 --- /dev/null +++ b/website/versioned_docs/version-0.11.1/autorender.md @@ -0,0 +1,111 @@ +--- +id: version-0.11.1-autorender +title: Auto-render Extension +original_id: autorender +--- +This is an extension to automatically render all of the math inside of text. It +searches all of the text nodes within a given element for the given delimiters, +ignoring certain tags like ``, and renders the math in place. + +## Usage +This extension isn't part of KaTeX proper, so the script needs to be included +(via a ` + +``` + +> Above, the [`defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes) +indicates that the script doesn't need to execute until the page has loaded, +speeding up page rendering; and the `onload` attribute calls +`renderMathInElement` once the auto-render script loads. + +Alternatively, you can call the `renderMathInElement` when (or after) the +[`DOMContentLoaded` event](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded) +fires on the document or in another deferred script. +This approach is useful for specifying or computing options, or if you don't +want to use a `defer` or `onload` attribute. +For example: + +```html + + + + +``` + +ECMAScript module is also available: +```html + + +``` + +> You can use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes) +to provide a fallback for older browsers that do not support ES modules. --> + +## API +This extension exposes a single function, `window.renderMathInElement`, with +the following API: + +```js +function renderMathInElement(elem, options) +``` + +`elem` is an HTML DOM element. The function will recursively search for text +nodes inside this element and render the math in them. + +`options` is an optional object argument that can have the same keys as [the +object passed to `katex.render`](https://github.com/KaTeX/KaTeX/#rendering-options), +in addition to two auto-render-specific keys: + +- `delimiters`: This is a list of delimiters to look for math. Each delimiter + has three properties: + + - `left`: A string which starts the math expression (i.e. the left delimiter). + - `right`: A string which ends the math expression (i.e. the right delimiter). + - `display`: A boolean of whether the math in the expression should be + rendered in display mode or not. + + The default value is: + + ```js + [ + {left: "$$", right: "$$", display: true}, + {left: "\\(", right: "\\)", display: false}, + {left: "\\[", right: "\\]", display: true} + ] + ``` + +- `ignoredTags`: This is a list of DOM node types to ignore when recursing + through. The default value is + `["script", "noscript", "style", "textarea", "pre", "code"]`. + +- `ignoredClasses`: This is a list of DOM node class names to ignore when + recursing through. By default, this value is not set. + +- `errorCallback`: A callback method returning a message and an error stack + in case of an critical error during rendering. The default uses `console.error`. + +- `preProcess`: A callback function, `(math: string) => string`, used to process + math expressions before rendering. + +The `displayMode` property of the options object is ignored, and is +instead taken from the `display` key of the corresponding entry in the +`delimiters` key. + +The same `options.macros` object (which defaults to an empty object `{}`) +is passed into several calls to `katex.render`, so that consecutive equations +can build up shared macros by `\gdef`. diff --git a/website/versioned_docs/version-0.11.1/browser.md b/website/versioned_docs/version-0.11.1/browser.md new file mode 100644 index 00000000..c8ff47b5 --- /dev/null +++ b/website/versioned_docs/version-0.11.1/browser.md @@ -0,0 +1,119 @@ +--- +id: version-0.11.1-browser +title: Browser +original_id: browser +--- +> KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 9–11. + +## Starter template + +```html + + + + + + + + + + + + + ... + +``` + +## Loading as Global +If you include the `katex.js` directly, the `katex` object will be available as +a global variable. + +```html + + +``` + +KaTeX also provides minified versions: + +```html + + +``` + +The examples above load the script [deferred using the `defer` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes) +to speed up page rendering. The `katex` object will be available after +[`DOMContentLoaded` event is fired on the `document`](https://developer.mozilla.org/ko/docs/Web/Reference/Events/DOMContentLoaded). +If you do not use `defer`, `katex` object will be available after the corresponding +`script` tag. + +If KaTeX is not used immediately or not critical, it is possible to load KaTeX +asynchronously. Add [`async` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes) +to `script` and use [`rel="preload"` and `onload` attribute](https://github.com/filamentgroup/loadCSS) +on `link`. + +You can prefetch KaTeX fonts to prevent FOUT or FOIT. Use [Font Loading API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Font_Loading_API) +or [Web Font Loader](https://github.com/typekit/webfontloader): + +```html + + +``` + +You can also use [`rel="preload"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content). +Add `` +to `head`. Note that [only few browsers support it](https://caniuse.com/#feat=link-rel-preload) +and they all support WOFF2 so preloading WOFF2 fonts is enough. + +See [Google Web Fundamentals - Web Font Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization) +for more detail. + +## Module Loaders +### AMD +```html + + +``` + +### ECMAScript module +```html + + + +``` + +> Use [`nomodule` attribute](https://developer.mozilla.org/en/HTML/Element/script#Attributes) +to provide a fallback for older browsers that do not support ES modules. + +## Download & Host Things Yourself +Download a [KaTeX release](https://github.com/KaTeX/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 or import it 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 to install KaTeX and import it](node.md) 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. diff --git a/website/versions.json b/website/versions.json index 6669b20f..843d07e0 100644 --- a/website/versions.json +++ b/website/versions.json @@ -1,4 +1,5 @@ [ + "0.11.1", "0.11.0", "0.10.2", "0.10.1",