diff --git a/CHANGELOG.md b/CHANGELOG.md index 72d3f2b9..bb4d0214 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,42 @@ # 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.0] +### Added +- **BREAKING CHANGE:** trust setting to indicate whether input text is trusted (#1794) + - `\href` and `\url` will break without adjusting the trust setting +- Add test for double square brackets to katex-spec (#1956) +- Add option to render only MathML so that its visible (#1966) +- Support {smallmatrix}, {subarray}, and \substack (#1969) +- Enable minRuleThickness in rendering options (#1964) +- Add \plim (#1952) +- Support Unicode \digamma (#2010) +- Support \operatorname* (#1899) +- Support \includegraphics, with appropriate trust setting (#2053) +- Add render-a11y-string add-on (#2062) + +### Changed +- DOC: Fix path to built file (#1976) +- Remove unclosed TODO comment (#1979) +- Add "Tutti Quanti Shelf" app to users page (#1997) +- Document mhchem \cf not supported (use \ce instead) (#2008) +- Replace greenkeeper badge with dependabot badge (#2022) +- Add Unicode digamma to documentation (#2045) +- Add katex-expression to libs page (#2049) +- Suggest in documentation (#2052) +- Unicode characters in math render in text mode (#2040) + +### Fixed +- Improve output of fonts in MathML (#1965) +- Fix \pmb (#1924) +- \color affects following \right, put array cells in their own groups (#1845) +- Improve MathML for classes (#1929) +- Prevent gaps in tall delimiters (#1986) +- Fix \sqrt SVG path (#2009) +- Do not force sizing groups to display inline-block (#2044) +- Fix font choice in operators like \log (e.g. \boldsymbol{\log}) (#2041) +- Fix argument font sizing in \fbox and \raisebox, fix font sizing in \TeX, \LaTeX, \KaTeX (#1787) + ## [v0.10.2] ### Added - Approximate font metrics only when metrics don't exist (#1898) @@ -8,7 +44,7 @@ All notable changes to this project will be documented in this file. This CHANGE - Add symbol double square brackets (#1947, #1954) - Support double-square curly braces (#1953) - ### Changed +### Changed - Upgrade minimum development Node version to v8 (#1861) - Disable @babel/env debug (#1874) - Add issue templates (#1862) @@ -21,7 +57,7 @@ All notable changes to this project will be documented in this file. This CHANGE - Test for duplicate symbols/macros (#1955) - Include extensions mhchem & copy-tex in home-page (#1932) - ### Fixed +### Fixed - Fix \Rho (#1870) - Fix nested \dfrac (#1825) - Improve MathML accents (#1877) @@ -49,7 +85,7 @@ All notable changes to this project will be documented in this file. This CHANGE - Improve MathML for \Bbbk (#1930) - Prevent inadvertent tall delims (#1948) - ### Removed +### Removed - Re-added code for \includegraphics but disabled the function until trust settings is merged (#1951) ## [v0.10.1] diff --git a/README.md b/README.md index 509faefd..e4e58f68 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 d98686e6..90efaebb 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 84326635..35e272e4 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 e7a56f0a..0de2bcc1 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 bf2cddfd..b17fcad7 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 b4c4449c..acfe2ddd 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/package.json b/package.json index d93727ce..53fe305b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "katex", - "version": "0.10.3-pre", + "version": "0.12.0-pre", "description": "Fast math typesetting for the web.", "main": "dist/katex.js", "homepage": "https://katex.org", diff --git a/website/versioned_docs/version-0.11.0/autorender.md b/website/versioned_docs/version-0.11.0/autorender.md new file mode 100644 index 00000000..56b630c8 --- /dev/null +++ b/website/versioned_docs/version-0.11.0/autorender.md @@ -0,0 +1,111 @@ +--- +id: version-0.11.0-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.0/browser.md b/website/versioned_docs/version-0.11.0/browser.md new file mode 100644 index 00000000..138be221 --- /dev/null +++ b/website/versioned_docs/version-0.11.0/browser.md @@ -0,0 +1,119 @@ +--- +id: version-0.11.0-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/versioned_docs/version-0.11.0/font.md b/website/versioned_docs/version-0.11.0/font.md new file mode 100644 index 00000000..a0566f7c --- /dev/null +++ b/website/versioned_docs/version-0.11.0/font.md @@ -0,0 +1,47 @@ +--- +id: version-0.11.0-font +title: Font +original_id: font +--- +By changing the variables in the `fonts.less` file at the [katex-fonts submodule](https://github.com/KaTeX/katex-fonts/), +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, to set to 1.1×: + +```css +.katex { font-size: 1.1em; } +``` + +KaTeX supports all TeX units, including absolute units like `cm` and `in`. +Absolute units are currently scaled relative to the default TeX font size of +10pt, so that `\kern1cm` produces the same results as `\kern2.845275em`. +As a result, relative and absolute units are both uniformly scaled relative +to LaTeX with a 10pt font; for example, the rectangle `\rule{1cm}{1em}` has +the same aspect ratio in KaTeX as in LaTeX. However, because most browsers +default to a larger font size, this typically means that a 1cm kern in KaTeX +will appear larger than 1cm in browser units. + +## Kinds of fonts used + +KaTeX provides fonts in three different formats: `ttf`, `woff`, and `woff2`. + +- `ttf`s are included to support very old browsers and local installation. [Browser support](https://caniuse.com/#feat=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. [Browser support](https://caniuse.com/#feat=woff) +- `woff2`s are included for modern browsers, because they are much smaller and faster to load. [Browser support](https://caniuse.com/#feat=woff2) + +KaTeX will automatically include only necessary fonts for target environments +specified by [Browserslist config](https://github.com/browserslist/browserslist#queries). + +To force a font type to be included or excluded, set `USE_(FONT NAME)` environment +variable to `"true"` or `"false"`, respectively.` + +## 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 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 build` from the top-level directory. +3. Use the newly generated `dist/katex.min.css` file, and place the fonts where you indicated. diff --git a/website/versioned_docs/version-0.11.0/issues.md b/website/versioned_docs/version-0.11.0/issues.md new file mode 100644 index 00000000..cc52bd9a --- /dev/null +++ b/website/versioned_docs/version-0.11.0/issues.md @@ -0,0 +1,47 @@ +--- +id: version-0.11.0-issues +title: Common Issues +original_id: issues +--- +- Be sure to include `` at the top of your HTML file, as + otherwise your browser will render in "[quirks mode](https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode)" + which can cause KaTeX to sometimes render incorrectly. + This header is needed even inside `