-
Notifications
You must be signed in to change notification settings - Fork 2
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
1ff0d0b
commit ad064b2
Showing
1 changed file
with
25 additions
and
9 deletions.
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 |
---|---|---|
@@ -1,17 +1,36 @@ | ||
# wypst | ||
Typst math typesetting for the web. | ||
|
||
## Getting started | ||
### Installation | ||
Install wypst with npm: | ||
## Usage | ||
You can load this library either by using a script tag (preferred), or installing it with npm (for advanced usage). | ||
|
||
### Option 1: Script tag | ||
This is simplest way to load, and looks very similar to how you go about it with KaTeX. This is the preferred and simplest method. | ||
|
||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/wypst.min.css" crossorigin="anonymous"> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/wypst.min.js" crossorigin="anonymous"></script> | ||
``` | ||
|
||
Keep in mind that the javascript file is 17M, so if your internet is slow it might take some seconds to load. | ||
|
||
### Option 2: npm package | ||
Sometimes having the wasm inlined in the script file is incovenient. When this is the case, you will have to install the package with npm. | ||
|
||
```bash | ||
npm install wypst | ||
``` | ||
### Importing | ||
You can import wypst as an ECMAScript module: | ||
```javascript | ||
|
||
You may then load the wasm binary | ||
|
||
``` | ||
import wypst from 'wypst'; | ||
import wasm from 'wypst/dist/wypst.wasm'; | ||
wypst.initialize(wasm); | ||
wypst.renderToString("x + y") // Test it out! | ||
``` | ||
|
||
### Rendering Typst Math | ||
To render a Typst math expression, you can use either `render` or `renderToString`, as the example below shows: | ||
```javascript | ||
|
@@ -21,6 +40,3 @@ wypst.renderToString('sum_(n >= 1) 1/n^2 = pi^2/6'); // Renders into an HTML str | |
|
||
## Contributing | ||
All help is welcome. Please see [CONTRIBUTING](CONTRIBUTING.md). | ||
|
||
## Disclaimer | ||
As of now wypst is very experimental, so you may encounter lots of bugs. I expect to have most fixed by mid March. |