mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-27 09:24:45 +00:00
First pass at KaTeX plugin
Finally fixes #458 thanks to the KaTeX plugin from Khan Academy
This commit is contained in:
parent
d047ccdc84
commit
96b7d0eeba
5
editions/katexdemo/tiddlers/DefaultTiddlers.tid
Normal file
5
editions/katexdemo/tiddlers/DefaultTiddlers.tid
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
title: $:/DefaultTiddlers
|
||||||
|
|
||||||
|
HelloThere
|
||||||
|
KaTeX
|
||||||
|
ImplementationNotes
|
59
editions/katexdemo/tiddlers/HelloThere.tid
Normal file
59
editions/katexdemo/tiddlers/HelloThere.tid
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
title: HelloThere
|
||||||
|
|
||||||
|
This is a TiddlyWiki plugin for mathematical typesetting based on KaTeX from Khan Academy.
|
||||||
|
|
||||||
|
! Installation
|
||||||
|
|
||||||
|
To add the plugin to your own TiddlyWiki5, just drag this link to the browser window:
|
||||||
|
|
||||||
|
[[$:/plugins/tiddlywiki/katex]]
|
||||||
|
|
||||||
|
! Using KaTeX
|
||||||
|
|
||||||
|
The KaTeX widget is provided under the name `<$latex>` and is also available under the alias `<$katex>`. It's better to use the generic `<$latex>` name unless you are running multiple LaTeX plugins and wish to specifically target KaTeX.
|
||||||
|
|
||||||
|
! Examples
|
||||||
|
|
||||||
|
These examples are taken from http://khan.github.io/KaTeX/
|
||||||
|
|
||||||
|
!! Example 1
|
||||||
|
|
||||||
|
```
|
||||||
|
$$\displaystyle f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi$$
|
||||||
|
```
|
||||||
|
|
||||||
|
$$\displaystyle f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi$$
|
||||||
|
|
||||||
|
!! Example 2
|
||||||
|
|
||||||
|
```
|
||||||
|
$$\displaystyle \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }$$
|
||||||
|
```
|
||||||
|
|
||||||
|
$$\displaystyle \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }$$
|
||||||
|
|
||||||
|
!! Example 3
|
||||||
|
|
||||||
|
```
|
||||||
|
$$\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
|
||||||
|
```
|
||||||
|
|
||||||
|
$$\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
|
||||||
|
|
||||||
|
!! Example 4
|
||||||
|
|
||||||
|
```
|
||||||
|
$$\displaystyle 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1.$$
|
||||||
|
```
|
||||||
|
|
||||||
|
$$\displaystyle 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1.$$
|
||||||
|
|
||||||
|
!! Widget Example
|
||||||
|
|
||||||
|
For more flexibility the KaTeX widget can also be used via the full widget syntax:
|
||||||
|
|
||||||
|
```
|
||||||
|
<$latex text="\displaystyle f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi"></$latex>
|
||||||
|
```
|
||||||
|
|
||||||
|
<$latex text="\displaystyle f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi"></$latex>
|
29
editions/katexdemo/tiddlers/ImplementationNotes.tid
Normal file
29
editions/katexdemo/tiddlers/ImplementationNotes.tid
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
title: ImplementationNotes
|
||||||
|
|
||||||
|
! CSS Handling
|
||||||
|
|
||||||
|
The [[original CSS from KaTeX|https://github.com/Khan/KaTeX/blob/master/static%2Ffonts.css]] includes a number of font definitions in this format:
|
||||||
|
|
||||||
|
```
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_AMS';
|
||||||
|
src: url('fonts/KaTeX_AMS-Regular.eot');
|
||||||
|
src: url('fonts/KaTeX_AMS-Regular.eot?#iefix') format('embedded-opentype'),
|
||||||
|
url('fonts/KaTeX_AMS-Regular.woff') format('woff'),
|
||||||
|
url('fonts/KaTeX_AMS-Regular.ttf') format('truetype');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
These definitions are currently removed manually from [[$:/plugins/tiddlywiki/katex/katex.min.css]] so that they can be redefined as data URIs using TiddlyWiki's macro notation:
|
||||||
|
|
||||||
|
```
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_AMS';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_AMS-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
6
editions/katexdemo/tiddlers/KaTeX.tid
Normal file
6
editions/katexdemo/tiddlers/KaTeX.tid
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
title: KaTeX
|
||||||
|
|
||||||
|
~KaTeX is a ~JavaScript library for mathematics typesetting from Khan Academy:
|
||||||
|
|
||||||
|
http://khan.github.io/KaTeX/
|
||||||
|
|
3
editions/katexdemo/tiddlers/SiteSubtitle.tid
Normal file
3
editions/katexdemo/tiddlers/SiteSubtitle.tid
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
title: $:/SiteSubtitle
|
||||||
|
|
||||||
|
a demo of the KaTeX plugin for TiddlyWiki5
|
3
editions/katexdemo/tiddlers/SiteTitle.tid
Normal file
3
editions/katexdemo/tiddlers/SiteTitle.tid
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
title: $:/SiteTitle
|
||||||
|
|
||||||
|
KaTeX Demo
|
15
editions/katexdemo/tiddlywiki.info
Normal file
15
editions/katexdemo/tiddlywiki.info
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"tiddlywiki/katex"
|
||||||
|
],
|
||||||
|
"themes": [
|
||||||
|
"tiddlywiki/vanilla",
|
||||||
|
"tiddlywiki/snowwhite"
|
||||||
|
],
|
||||||
|
"includeWikis": [
|
||||||
|
],
|
||||||
|
"build": {
|
||||||
|
"index": [
|
||||||
|
"--rendertiddler","$:/core/save/all","katexdemo.html","text/plain"]
|
||||||
|
}
|
||||||
|
}
|
42
plugins/tiddlywiki/katex/files/README.md
Normal file
42
plugins/tiddlywiki/katex/files/README.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# [<img src="https://khan.github.io/KaTeX/katex-logo.svg" width="130" alt="KaTeX">](http://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
|
||||||
|
|
||||||
|
Download the built files from [the releases page](https://github.com/khan/katex/releases). Include the `katex.min.js` and `katex.min.css` files on your page:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<link rel="stylesheet" type="text/css" href="/path/to/katex.min.css">
|
||||||
|
<script src="/path/to/katex.min.js" type="text/javascript"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
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);
|
||||||
|
```
|
||||||
|
|
||||||
|
To generate HTML on the server, 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.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
KaTeX is licenced under the [MIT License](http://opensource.org/licenses/MIT).
|
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_AMS-Regular.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_AMS-Regular.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_AMS-Regular.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_AMS-Regular.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_AMS-Regular.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_AMS-Regular.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Bold.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Bold.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Bold.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Bold.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Bold.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Bold.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Italic.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Italic.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Italic.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Italic.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Italic.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Italic.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Regular.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Regular.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Regular.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Regular.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Regular.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Main-Regular.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-BoldItalic.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-BoldItalic.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-BoldItalic.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-BoldItalic.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-BoldItalic.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Italic.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Italic.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Italic.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Italic.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Italic.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Italic.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Regular.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Regular.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Regular.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Regular.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Regular.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Math-Regular.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size1-Regular.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size1-Regular.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size1-Regular.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size1-Regular.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size1-Regular.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size1-Regular.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size2-Regular.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size2-Regular.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size2-Regular.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size2-Regular.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size2-Regular.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size2-Regular.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size3-Regular.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size3-Regular.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size3-Regular.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size3-Regular.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size3-Regular.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size3-Regular.woff
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size4-Regular.eot
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size4-Regular.eot
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size4-Regular.ttf
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size4-Regular.ttf
Normal file
Binary file not shown.
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size4-Regular.woff
Normal file
BIN
plugins/tiddlywiki/katex/files/fonts/KaTeX_Size4-Regular.woff
Normal file
Binary file not shown.
1
plugins/tiddlywiki/katex/files/katex.min.css
vendored
Normal file
1
plugins/tiddlywiki/katex/files/katex.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
3
plugins/tiddlywiki/katex/files/katex.min.js
vendored
Normal file
3
plugins/tiddlywiki/katex/files/katex.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
plugins/tiddlywiki/katex/files/katex.without-font-face.min.css
vendored
Normal file
2
plugins/tiddlywiki/katex/files/katex.without-font-face.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
84
plugins/tiddlywiki/katex/files/tiddlywiki.files
Normal file
84
plugins/tiddlywiki/katex/files/tiddlywiki.files
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
"tiddlers": [
|
||||||
|
{
|
||||||
|
"file": "fonts/KaTeX_AMS-Regular.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_AMS-Regular.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Main-Bold.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Bold.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Main-Italic.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Italic.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Main-Regular.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Regular.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Math-BoldItalic.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-BoldItalic.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Math-Italic.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-Italic.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Math-Regular.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-Regular.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Size1-Regular.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size1-Regular.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Size2-Regular.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size2-Regular.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Size3-Regular.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size3-Regular.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "fonts/KaTeX_Size4-Regular.woff",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/font-woff",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size4-Regular.woff"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "katex.without-font-face.min.css",
|
||||||
|
"fields": {
|
||||||
|
"type": "text/plain",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/katex.min.css"
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
"file": "katex.min.js",
|
||||||
|
"fields": {
|
||||||
|
"type": "application/javascript",
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex/katex.min.js",
|
||||||
|
"module-type": "library"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
61
plugins/tiddlywiki/katex/latex-parser.js
Normal file
61
plugins/tiddlywiki/katex/latex-parser.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/katex/latex-parser.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: wikirule
|
||||||
|
|
||||||
|
Wiki text inline rule for LaTeX. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
$$latex-goes-here$$
|
||||||
|
```
|
||||||
|
|
||||||
|
This wikiparser can be modified using the rules eg:
|
||||||
|
|
||||||
|
```
|
||||||
|
\rules except latex-parser
|
||||||
|
\rules only latex-parser
|
||||||
|
```
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.name = "latex-parser";
|
||||||
|
exports.types = {inline: true};
|
||||||
|
|
||||||
|
exports.init = function(parser) {
|
||||||
|
this.parser = parser;
|
||||||
|
// Regexp to match
|
||||||
|
this.matchRegExp = /\$\$(?!\$)/mg;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.parse = function() {
|
||||||
|
// Move past the match
|
||||||
|
this.parser.pos = this.matchRegExp.lastIndex;
|
||||||
|
var reEnd = /\$\$/mg;
|
||||||
|
// Look for the end marker
|
||||||
|
reEnd.lastIndex = this.parser.pos;
|
||||||
|
var match = reEnd.exec(this.parser.source),
|
||||||
|
text;
|
||||||
|
// Process the text
|
||||||
|
if(match) {
|
||||||
|
text = this.parser.source.substring(this.parser.pos,match.index);
|
||||||
|
this.parser.pos = match.index + match[0].length;
|
||||||
|
} else {
|
||||||
|
text = this.parser.source.substr(this.parser.pos);
|
||||||
|
this.parser.pos = this.parser.sourceLength;
|
||||||
|
}
|
||||||
|
return [{
|
||||||
|
type: "latex",
|
||||||
|
attributes: {
|
||||||
|
text: {
|
||||||
|
type: "text",
|
||||||
|
value: text
|
||||||
|
}}
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
5
plugins/tiddlywiki/katex/plugin.info
Normal file
5
plugins/tiddlywiki/katex/plugin.info
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"title": "$:/plugins/tiddlywiki/katex",
|
||||||
|
"description": "Mathematics typesetting plugin wrapping KaTeX",
|
||||||
|
"author": "JeremyRuston"
|
||||||
|
}
|
178
plugins/tiddlywiki/katex/styles.tid
Normal file
178
plugins/tiddlywiki/katex/styles.tid
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/katex/styles
|
||||||
|
tags: [[$:/tags/Stylesheet]]
|
||||||
|
|
||||||
|
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline
|
||||||
|
|
||||||
|
/* KaTeX styles */
|
||||||
|
|
||||||
|
{{$:/plugins/tiddlywiki/katex/katex.min.css}}
|
||||||
|
|
||||||
|
/* Override font URLs */
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_AMS';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_AMS-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Caligraphic';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Caligraphic-Bold.woff'>>) format('woff');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Caligraphic';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Caligraphic-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Fraktur';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Fraktur-Bold.woff'>>) format('woff');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Fraktur';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Fraktur-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Greek';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Greek-Bold.woff'>>) format('woff');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Greek';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Greek-BoldItalic.woff'>>) format('woff');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Greek';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Greek-Italic.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Greek';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Greek-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Main';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Bold.woff'>>) format('woff');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Main';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Italic.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Main';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Main-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Math';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-BoldItalic.woff'>>) format('woff');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Math';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-Italic.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Math';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_SansSerif';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_SansSerif-Bold.woff'>>) format('woff');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_SansSerif';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_SansSerif-Italic.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_SansSerif';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_SansSerif-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Script';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Script-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Size1';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size1-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Size2';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size2-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Size3';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size3-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Size4';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Size4-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'KaTeX_Typewriter';
|
||||||
|
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Typewriter-Regular.woff'>>) format('woff');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
69
plugins/tiddlywiki/katex/wrapper.js
Normal file
69
plugins/tiddlywiki/katex/wrapper.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/katex/wrapper.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: widget
|
||||||
|
|
||||||
|
Wrapper for `katex.min.js` that provides a `<$latex>` widget. It is also available under the alias `<$katex>`
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var katex = require("$:/plugins/tiddlywiki/katex/katex.min.js"),
|
||||||
|
Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||||
|
|
||||||
|
var KaTeXWidget = function(parseTreeNode,options) {
|
||||||
|
this.initialise(parseTreeNode,options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Inherit from the base widget class
|
||||||
|
*/
|
||||||
|
KaTeXWidget.prototype = new Widget();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Render this widget into the DOM
|
||||||
|
*/
|
||||||
|
KaTeXWidget.prototype.render = function(parent,nextSibling) {
|
||||||
|
// Housekeeping
|
||||||
|
this.parentDomNode = parent;
|
||||||
|
this.computeAttributes();
|
||||||
|
this.execute();
|
||||||
|
// Get the source text
|
||||||
|
var text = this.getAttribute("text",this.parseTreeNode.text || "");
|
||||||
|
// Render it into a span
|
||||||
|
var span = this.document.createElement("span");
|
||||||
|
katex.render(text,span);
|
||||||
|
// Insert it into the DOM
|
||||||
|
parent.insertBefore(span,nextSibling);
|
||||||
|
this.domNodes.push(span);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Compute the internal state of the widget
|
||||||
|
*/
|
||||||
|
KaTeXWidget.prototype.execute = function() {
|
||||||
|
// Nothing to do for a katex widget
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||||
|
*/
|
||||||
|
KaTeXWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
|
var changedAttributes = this.computeAttributes();
|
||||||
|
if(changedAttributes.text) {
|
||||||
|
this.refreshSelf();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.latex = KaTeXWidget;
|
||||||
|
exports.katex = KaTeXWidget;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user