Update katex to latest 0.15.3 (#6671)

* feat: update snippet fields

https://github.com/Jermolene/TiddlyWiki5/discussions/6670

* chore: upgrade files

* docs: update readme

* fix: usage of mhchem

* fix: add back katex.without-font-face.min.css

https://github.com/Jermolene/TiddlyWiki5/pull/6671#issuecomment-1116287404

* style: format json with 4 space

* style: format json with 1 space

* style: restore old format

* feat: update css by using new one and delete font face

* update developer info

* move implementation notes to plugin

* update TW style tiddler

* update katexdemo edition

* chore: delete unused files

* Update developer.tid

* Update developer.tid

Co-authored-by: pmario <pmariojo@gmail.com>
This commit is contained in:
lin onetwo 2022-07-09 15:37:47 +08:00 committed by GitHub
parent 0112d04033
commit 2f817e4293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
83 changed files with 141 additions and 19400 deletions

View File

@ -0,0 +1,8 @@
created: 20220504131459155
modified: 20220504131522349
title: $:/DefaultTiddlers
type: text/vnd.tiddlywiki
HelloThere
KaTeX
$:/plugins/tiddlywiki/katex/developer

View File

@ -1,5 +0,0 @@
title: $:/DefaultTiddlers
HelloThere
KaTeX
ImplementationNotes

View File

@ -1,4 +1,7 @@
created: 20220504124110967
modified: 20220504124250020
title: HelloThere
type: text/vnd.tiddlywiki
This is a TiddlyWiki plugin for mathematical and chemical typesetting based on KaTeX from Khan Academy.
@ -6,7 +9,7 @@ It is completely self-contained, and doesn't need an Internet connection in orde
! Installation
To add the plugin to your own TiddlyWiki5, just drag this link to the browser window:
To add the plugin to your own wiki, just //drag the following link to your ~TiddlyWiki browser window//.
[[$:/plugins/tiddlywiki/katex]]

View File

@ -0,0 +1,8 @@
created: 20220504123802219
modified: 20220504123918414
title: LaTeX
type: text/vnd.tiddlywiki
<<<https://en.wikipedia.org/wiki/LaTeX
LaTeX is widely used in academia for the communication and publication of scientific documents in many fields, including mathematics, computer science, engineering, physics, chemistry, economics, linguistics, quantitative psychology, philosophy, and political science.
<<<

View File

@ -0,0 +1,8 @@
created: 20220504123347104
modified: 20220504123400803
title: TiddlyWiki
type: text/vnd.tiddlywiki
TiddlyWiki is a rich, interactive tool for manipulating complex data with structure that doesn't easily fit into conventional tools like spreadsheets or wordprocessors.
Learn more at: https://tiddlywiki.com

View File

@ -0,0 +1,6 @@
created: 20220504123412027
modified: 20220504123416593
title: TiddlyWiki5
type: text/vnd.tiddlywiki
{{TiddlyWiki}}

View File

@ -1,8 +1,8 @@
title: ImplementationNotes
title: $:/plugins/tiddlywiki/katex/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:
The ''original CSS from KaTeX'' includes a number of font definitions in this format:
```
@font-face {
@ -16,7 +16,7 @@ The [[original CSS from KaTeX|https://github.com/Khan/KaTeX/blob/master/static%2
}
```
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:
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 in $:/plugins/tiddlywiki/katex/styles
```
@font-face {

View File

@ -0,0 +1,58 @@
title: $:/plugins/tiddlywiki/katex/developer
!! How to upgrade
# Download latest release zip file from [[Github release|https://github.com/KaTeX/KaTeX/releases]]
# Backup existing files
#* `plugins/tiddlywiki/katex/files/tiddlywiki.files` file and
#* `katex.without-font-face.min.css` file
#* Learn more at: $:/plugins/tiddlywiki/katex/ImplementationNotes
# Rename extracted folder to "files" and
#* copy it to `plugins/tiddlywiki/katex/files`
#* (maybe delete the old folder first, to make a full overwrite)
#* delete unused files in it, like `*.mjs` files and `*.md` files
# Create `plugins/tiddlywiki/katex/files/tiddlywiki.files`
#* (or use the old one) and
#* register all needed files
# Register in `files/tiddlywiki.files`
#* `katex.without-font-face.min.css` ''as''
#* `$:/plugins/tiddlywiki/katex/katex.min.css`
#* so fonts are loaded properly in tw environment
!! How to test
To create a new "test edition" type the following command in a console window:
<<<
```
node tiddlywiki test-katex --init katexdemo
```
<<<
>It will create a new directory //test-katex// and clones the //katexdemo// edition.<br>The output should be:
<<<
`Copied edition 'katexdemo' to test-katex`
<<<
Type:
<<<
```
node tiddlywiki test-katex --listen
```
<<<
>It should output
<<<
`syncer-server-filesystem: Dispatching 'save' task: $:/StoryList
Serving on http://127.0.0.1:8080
(press ctrl-C to exit)
`
<<<
Test the new version in the browser at: [[http://127.0.0.1:8080]]
Make sure all equations of math and chemistry are rendered properly.

View File

@ -1,119 +0,0 @@
# [<img src="https://katex.org/img/katex-logo-black.svg" width="130" alt="KaTeX">](https://katex.org/)
[![npm](https://img.shields.io/npm/v/katex.svg)](https://www.npmjs.com/package/katex)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![CI](https://github.com/KaTeX/KaTeX/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/master/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX)
[![Discussions](https://img.shields.io/badge/Discussions-join-brightgreen)](https://github.com/KaTeX/KaTeX/discussions)
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex)
![katex.min.js size](https://img.badgesize.io/https://unpkg.com/katex/dist/katex.min.js?compression=gzip)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/KaTeX/KaTeX)
[![Financial Contributors on Open Collective](https://opencollective.com/katex/all/badge.svg?label=financial+contributors)](https://opencollective.com/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://www.intmath.com/cg5/katex-mathjax-comparison.php).
* **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 is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11.
KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html).
Try out KaTeX [on the demo page](https://katex.org/#demo)!
## Getting started
### Starter template
```html
<!DOCTYPE html>
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.css" integrity="sha384-zTROYFVGOfTw7JV7KUu8udsvW2fx4lWOsCEDqhBreBwlHI4ioVRtmIvEThzJHGET" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.js" integrity="sha384-GxNFqL3r9uRJQhR+47eDxuPoNE7yLftQM8LcxzgS4HT73tp970WS/wV5p8UzCOmb" crossorigin="anonymous"></script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
</head>
...
</html>
```
You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself.
For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html).
### API
Call `katex.render` to render a TeX expression directly into a DOM element.
For example:
```js
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
throwOnError: false
});
```
Call `katex.renderToString` to generate an HTML string of the rendered math,
e.g., for server-side rendering. For example:
```js
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
throwOnError: false
});
// '<span class="katex">...</span>'
```
Make sure to include the CSS and font files in both cases.
If you are doing all rendering on the server, there is no need to include the
JavaScript on the client.
The examples above use the `throwOnError: false` option, which renders invalid
inputs as the TeX source code in red (by default), with the error message as
hover text. For other available options, see the
[API documentation](https://katex.org/docs/api.html),
[options documentation](https://katex.org/docs/options.html), and
[handling errors documentation](https://katex.org/docs/error.html).
## Demo and Documentation
Learn more about using KaTeX [on the website](https://katex.org)!
## Contributors
### Code Contributors
This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md).
<a href="https://github.com/KaTeX/KaTeX/graphs/contributors"><img src="https://contributors-svg.opencollective.com/katex/contributors.svg?width=890&button=false" alt="Code contributors" /></a>
### Financial Contributors
Become a financial contributor and help us sustain our community.
#### Individuals
<a href="https://opencollective.com/katex"><img src="https://opencollective.com/katex/individuals.svg?width=890" alt="Contribute on Open Collective"></a>
#### Organizations
Support this project with your organization. Your logo will show up here with a link to your website.
<a href="https://opencollective.com/katex/organization/0/website"><img src="https://opencollective.com/katex/organization/0/avatar.svg" alt="Organization 1"></a>
<a href="https://opencollective.com/katex/organization/1/website"><img src="https://opencollective.com/katex/organization/1/avatar.svg" alt="Organization 2"></a>
<a href="https://opencollective.com/katex/organization/2/website"><img src="https://opencollective.com/katex/organization/2/avatar.svg" alt="Organization 3"></a>
<a href="https://opencollective.com/katex/organization/3/website"><img src="https://opencollective.com/katex/organization/3/avatar.svg" alt="Organization 4"></a>
<a href="https://opencollective.com/katex/organization/4/website"><img src="https://opencollective.com/katex/organization/4/avatar.svg" alt="Organization 5"></a>
<a href="https://opencollective.com/katex/organization/5/website"><img src="https://opencollective.com/katex/organization/5/avatar.svg" alt="Organization 6"></a>
<a href="https://opencollective.com/katex/organization/6/website"><img src="https://opencollective.com/katex/organization/6/avatar.svg" alt="Organization 7"></a>
<a href="https://opencollective.com/katex/organization/7/website"><img src="https://opencollective.com/katex/organization/7/avatar.svg" alt="Organization 8"></a>
<a href="https://opencollective.com/katex/organization/8/website"><img src="https://opencollective.com/katex/organization/8/avatar.svg" alt="Organization 9"></a>
<a href="https://opencollective.com/katex/organization/9/website"><img src="https://opencollective.com/katex/organization/9/avatar.svg" alt="Organization 10"></a>
## License
KaTeX is licensed under the [MIT License](http://opensource.org/licenses/MIT).

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,7 +27,7 @@
"prefix": "(function(document) {\n",
"suffix": "\n})(!$tw.browser ? $tw.fakeDocument : window.document)\n"
},{
"file": "mhchem.min.js",
"file": "contrib/mhchem.min.js",
"fields": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/katex/mhchem.min.js",
@ -37,4 +37,4 @@
"suffix": "})(require);\n"
}
]
}
}

View File

@ -3,5 +3,5 @@
"name": "KaTeX",
"description": "KaTeX library for mathematical typography",
"list": "readme usage config",
"library-version": "v0.13.18"
"library-version": "v0.15.3"
}

View File

@ -1,6 +1,6 @@
title: $:/plugins/tiddlywiki/katex/readme
This is a TiddlyWiki plugin for mathematical and chemical typesetting based on [ext[KaTeX from Khan Academy|http://khan.github.io/KaTeX/]] (v0.13.18) and [ext[mhchem|https://github.com/mhchem/MathJax-mhchem]] through a [ext[Katex extension|https://github.com/KaTeX/KaTeX/tree/master/contrib/mhchem]].
This is a TiddlyWiki plugin for mathematical and chemical typesetting based on [ext[KaTeX from Khan Academy|https://katex.org/]] (v0.15.3) and [ext[mhchem|https://github.com/mhchem/MathJax-mhchem]] through a [ext[Katex extension|https://github.com/KaTeX/KaTeX/tree/master/contrib/mhchem]].
It is completely self-contained, and doesn't need an Internet connection in order to work. It works both in the browser and under Node.js.

View File

@ -1,4 +1,8 @@
title: $:/plugins/tiddlywiki/katex/snippets/logo
tags: $:/tags/KaTeX/Snippet
caption: KaTeX Logo
description: Display a Logo of KaTeX
preview: $$\KaTeX$$
icon: $:/plugins/tiddlywiki/katex/katex-logo
$$\KaTeX$$

View File

@ -0,0 +1,8 @@
title: $:/plugins/tiddlywiki/katex/snippets/math
tags: $:/tags/KaTeX/Snippet
caption: KaTeX mathematical formula
description: create a math block
preview: $$i = \sqrt{-1}$$
icon: $:/plugins/tiddlywiki/katex/katex-logo
$$\KaTeX$$

View File

@ -1,5 +1,6 @@
title: $:/plugins/tiddlywiki/katex/styles
tags: [[$:/tags/Stylesheet]]
code-body: yes
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline
@ -90,6 +91,13 @@ tags: [[$:/tags/Stylesheet]]
font-style: normal;
}
@font-face {
font-family: KaTeX_Math;
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-BoldItalic.woff'>>) format('woff');
font-weight: 700;
font-style: italic;
}
@font-face {
font-family: KaTeX_Math;
src: url(<<datauri '$:/plugins/tiddlywiki/katex/fonts/KaTeX_Math-Italic.woff'>>) format('woff');

View File

@ -5,14 +5,24 @@ title: $:/plugins/tiddlywiki/katex/usage
# Mathematical typesetting: [ext[https://katex.org/docs/supported.html]]
# Chemical typesetting: [ext[https://mhchem.github.io/MathJax-mhchem/]]
<hr>
!! Syntax
The usual way to include ~LaTeX is to use `$$`. For example:
The usual way to include ~LaTeX is to use `$$` (when copying code examples from the references above, you will need to change from `$` to `$$`). For example:
```
$$\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$$
chemical:
```
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
```
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
Single line equations will render in inline mode. If there are newlines between the `$$` delimiters, the equations will be rendered in display mode.
The underlying widget can also be used directly, giving more flexibility:
@ -21,4 +31,10 @@ The underlying widget can also be used directly, giving more flexibility:
<$latex text="f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi" displayMode="true"></$latex>
```
<$latex text="f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi" displayMode="true"></$latex>
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.
!! Macro
Tiddlers with tag `$:/tags/KaTeX/Macro` will be recognized as global KaTeX macros. You can create new macro using the form in the [[config|$:/plugins/tiddlywiki/katex/config]].