This commit is contained in:
Emily Eisenberg 2015-09-01 19:45:38 -07:00
parent 8accf0f18a
commit 2e773e2f83
86 changed files with 76 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "KaTeX",
"version": "0.6.0-pre",
"version": "0.5.1",
"main": [
"dist/katex.min.js",
"dist/katex.min.css"

66
dist/README.md vendored Normal file
View File

@ -0,0 +1,66 @@
# [<img src="https://khan.github.io/KaTeX/katex-logo.svg" width="130" alt="KaTeX">](https://khan.github.io/KaTeX/) [![Build Status](https://travis-ci.org/Khan/KaTeX.svg?branch=master)](https://travis-ci.org/Khan/KaTeX)
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
* **Fast:** KaTeX renders its math synchronously and doesn't need to reflow the page. See how it compares to a competitor in [this speed test](http://jsperf.com/katex-vs-mathjax/).
* **Print quality:** KaTeXs layout is based on Donald Knuths TeX, the gold standard for math typesetting.
* **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 supports all major browsers, including Chrome, Safari, Firefox, Opera, and IE 8 - IE 11. A list of supported commands can be on the [wiki](https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX).
## Usage
You can [download KaTeX](https://github.com/khan/katex/releases) and host it on your server or include the `katex.min.js` and `katex.min.css` files on your page directly from a CDN:
```html
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min.js"></script>
```
#### In-browser rendering
Call `katex.render` with a TeX expression and a DOM element to render into:
```js
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element);
```
If KaTeX can't parse the expression, it throws a `katex.ParseError` error.
#### 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`:
```js
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}");
// '<span class="katex">...</span>'
```
Make sure to include the CSS and font files, but there is no need to include the JavaScript. Like `render`, `renderToString` throws if it can't parse the expression.
#### Rendering options
You can provide an object of options as the last argument to `katex.render` and `katex.renderToString`. 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`, KaTeX will throw a `ParseError` when it encounters an unsupported command. If `false`, KaTeX will render the unsupported command as text in the color given by `errorColor`. (default: `true`)
- `errorColor`: `string`. A color string given in the format `"#XXX"` or `"#XXXXXX"`. This option determines the color which unsupported commands are rendered in. (default: `#cc0000`)
For example:
```js
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, { displayMode: true });
```
#### Automatic rendering of math on a page
Math on the page can be automatically rendered using the auto-render extension. See [the Auto-render README](contrib/auto-render/README.md) for more information.
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
## License
KaTeX is licensed under the [MIT License](http://opensource.org/licenses/MIT).

1
dist/contrib/auto-render.min.js vendored Normal file
View File

@ -0,0 +1 @@
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.renderMathInElement=e()}})(function(){var e,t,r;return function n(e,t,r){function a(o,l){if(!t[o]){if(!e[o]){var f=typeof require=="function"&&require;if(!l&&f)return f(o,!0);if(i)return i(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var s=t[o]={exports:{}};e[o][0].call(s.exports,function(t){var r=e[o][1][t];return a(r?r:t)},s,s.exports,n,e,t,r)}return t[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,r){var n=e("./splitAtDelimiters");var a=function(e,t){var r=[{type:"text",data:e}];for(var a=0;a<t.length;a++){var i=t[a];r=n(r,i.left,i.right,i.display||false)}return r};var i=function(e,t){var r=a(e,t);var n=document.createDocumentFragment();for(var i=0;i<r.length;i++){if(r[i].type==="text"){n.appendChild(document.createTextNode(r[i].data))}else{var o=document.createElement("span");var l=r[i].data;try{katex.render(l,o,{displayMode:r[i].display})}catch(f){if(!(f instanceof katex.ParseError)){throw f}console.error("KaTeX auto-render: Failed to parse `"+r[i].data+"` with ",f);n.appendChild(document.createTextNode(r[i].rawData));continue}n.appendChild(o)}}return n};var o=function(e,t,r){for(var n=0;n<e.childNodes.length;n++){var a=e.childNodes[n];if(a.nodeType===3){var l=i(a.textContent,t);n+=l.childNodes.length-1;e.replaceChild(l,a)}else if(a.nodeType===1){var f=r.indexOf(a.nodeName.toLowerCase())===-1;if(f){o(a,t,r)}}}};var l={delimiters:[{left:"$$",right:"$$",display:true},{left:"\\[",right:"\\]",display:true},{left:"\\(",right:"\\)",display:false}],ignoredTags:["script","noscript","style","textarea","pre","code"]};var f=function(e){var t,r;for(var n=1,a=arguments.length;n<a;n++){t=arguments[n];for(r in t){if(Object.prototype.hasOwnProperty.call(t,r)){e[r]=t[r]}}}return e};var d=function(e,t){if(!e){throw new Error("No element provided to render")}t=f({},l,t);o(e,t.delimiters,t.ignoredTags)};t.exports=d},{"./splitAtDelimiters":2}],2:[function(e,t,r){var n=function(e,t,r){var n=r;var a=0;var i=e.length;while(n<t.length){var o=t[n];if(a<=0&&t.slice(n,n+i)===e){return n}else if(o==="\\"){n++}else if(o==="{"){a++}else if(o==="}"){a--}n++}return-1};var a=function(e,t,r,a){var i=[];for(var o=0;o<e.length;o++){if(e[o].type==="text"){var l=e[o].data;var f=true;var d=0;var s;s=l.indexOf(t);if(s!==-1){d=s;i.push({type:"text",data:l.slice(0,d)});f=false}while(true){if(f){s=l.indexOf(t,d);if(s===-1){break}i.push({type:"text",data:l.slice(d,s)});d=s}else{s=n(r,l,d+t.length);if(s===-1){break}i.push({type:"math",data:l.slice(d+t.length,s),rawData:l.slice(d,s+r.length),display:a});d=s+r.length}f=!f}i.push({type:"text",data:l.slice(d)})}else{i.push(e[o])}}return i};t.exports=a},{}]},{},[1])(1)});

BIN
dist/fonts/KaTeX_AMS-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_AMS-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_AMS-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_AMS-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Caligraphic-Bold.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Caligraphic-Bold.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Caligraphic-Bold.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Caligraphic-Bold.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Caligraphic-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Caligraphic-Regular.ttf vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Bold.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Bold.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Bold.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Bold.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Fraktur-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Bold.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Bold.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Bold.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Bold.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Italic.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Italic.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Italic.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Italic.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Main-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-BoldItalic.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-BoldItalic.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-BoldItalic.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-BoldItalic.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Italic.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Italic.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Italic.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Italic.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Math-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Bold.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Bold.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Bold.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Bold.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Italic.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Italic.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Italic.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Italic.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_SansSerif-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Script-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Script-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Script-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Script-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size1-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size1-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size1-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size1-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size2-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size2-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size2-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size2-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size3-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size3-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size3-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size3-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size4-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size4-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size4-Regular.woff vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Size4-Regular.woff2 vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Typewriter-Regular.eot vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Typewriter-Regular.ttf vendored Normal file

Binary file not shown.

BIN
dist/fonts/KaTeX_Typewriter-Regular.woff vendored Normal file

Binary file not shown.

Binary file not shown.

1
dist/katex.min.css vendored Normal file

File diff suppressed because one or more lines are too long

6
dist/katex.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "katex",
"version": "0.6.0-pre",
"version": "0.5.1",
"description": "Fast math typesetting for the web.",
"main": "katex.js",
"repository": {