-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c74fb3
commit 1eb2820
Showing
58 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bower_components/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# katex-elements | ||
Custom elements for easily using KaTeX | ||
Custom elements for easily using [KaTeX][katex] | ||
|
||
[katex]: https://github.com/Khan/KaTeX | ||
|
||
##Usage | ||
|
||
### 1. Import the elements | ||
|
||
```html | ||
<link rel="import" href="../katex-elements/katex-elements.html"> | ||
``` | ||
|
||
### 2. Use the elements! | ||
|
||
## <katex-inline> | ||
|
||
Renders its text content in inline mode. | ||
|
||
###markup: | ||
|
||
```html | ||
<katex-inline>c = \pm\sqrt{a^2 + b^2}</katex-inline> | ||
``` | ||
|
||
###output: | ||
<img src="readme-katex-inline.png"> | ||
|
||
##<katex-display> | ||
|
||
Renders its text content in display mode, which will put the math in display style (so `\int` and `\sum` are large, for example), and will center the math in a block element. | ||
|
||
###markup: | ||
|
||
```html | ||
<katex-display>c = \pm\sqrt{a^2 + b^2}</katex-display> | ||
``` | ||
|
||
###output: | ||
<img src="readme-katex-display.png"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "katex-elements", | ||
"dependencies": { | ||
"polymer": "Polymer/polymer#0.8-preview" | ||
}, | ||
"devDependencies": { | ||
"webcomponentsjs": "webcomponents/webcomponentsjs" | ||
}, | ||
"version": "0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<link rel="import" href="katex-elements.html"> | ||
<style> | ||
code { | ||
color: #2a2; | ||
} | ||
.tag { | ||
color: #e44; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div> | ||
<h2><katex-inline></h2> | ||
<h3>markup:</h3> | ||
<code> | ||
<span class="tag"><katex-inline></span> | ||
c = \pm\sqrt{a^2 + b^2} | ||
<span class="tag"></katex-inline></span></code> | ||
<h3>output:</h3> | ||
<katex-inline>c = \pm\sqrt{a^2 + b^2}</katex-inline> | ||
</div> | ||
|
||
<div> | ||
<h2><katex-display></h2> | ||
<h3>markup:</h3> | ||
<code> | ||
<span class="tag"><katex-display></span> | ||
c = \pm\sqrt{a^2 + b^2} | ||
<span class="tag"></katex-display></span> | ||
</code> | ||
<h3>output:</h3> | ||
<katex-display>c = \pm\sqrt{a^2 + b^2}</katex-display> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<link rel="import" href="../polymer/polymer.html"> | ||
<link rel="import" href="katex-js.html"> | ||
|
||
<dom-module id="katex-display"> | ||
<style> | ||
:host { | ||
display: block; | ||
} | ||
</style> | ||
<template></template> | ||
</dom-module> | ||
|
||
<script> | ||
(function() { | ||
|
||
Polymer({ | ||
is: 'katex-display', | ||
|
||
ready() { | ||
var children = Array.prototype.slice.call(Polymer.dom(this).childNodes); | ||
var textContent = children.map(function(c) { return c.textContent; }).join(''); | ||
katex.render(textContent, Polymer.dom(this.root), { displayMode: true }); | ||
}, | ||
|
||
}); | ||
|
||
})(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<link rel="import" href="katex-inline.html"> | ||
<link rel="import" href="katex-display.html"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<link rel="import" href="../polymer/polymer.html"> | ||
<link rel="import" href="katex-js.html"> | ||
|
||
<dom-module id="katex-inline"> | ||
:host { | ||
display: inline; | ||
} | ||
<template></template> | ||
</dom-module> | ||
|
||
<script> | ||
(function() { | ||
|
||
Polymer({ | ||
is: 'katex-inline', | ||
|
||
ready() { | ||
var children = Array.prototype.slice.call(Polymer.dom(this).childNodes); | ||
var textContent = children.map(function(c) { return c.textContent; }).join(''); | ||
katex.render(textContent, Polymer.dom(this.root)); | ||
}, | ||
|
||
}); | ||
|
||
})(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<script src="third_party/katex/katex.min.js"></script> | ||
<link rel="stylesheet" href="third_party/katex/katex.min.css"> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# [<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:** KaTeX’s layout is based on Donald Knuth’s 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. | ||
|
||
## 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.2.0/katex.min.css"> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.2.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); | ||
``` | ||
|
||
#### 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. | ||
|
||
#### 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`) | ||
|
||
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). |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.