Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpapercut committed May 3, 2024
1 parent 1ff0d0b commit ad064b2
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions README.md
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
Expand All @@ -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.

0 comments on commit ad064b2

Please sign in to comment.