Code Monkey home page Code Monkey logo

wypst's Introduction

wypst

Typst math typesetting for the web.

Usage

You can load this library either by using a script tag, or installing it with npm.

Script tag (simple usage)

<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>

<script>
    wypst.initialize().then(() => {
        wypst.renderToString("x + y"); // Test it out!
    })
</script>

Keep in mind that the javascript file is 17M, so if your internet is slow it might take some seconds to load.

npm package (advanced usage)

If having the wasm inlined directly is an incovenience, install the npm package

npm install wypst

You may then load the wasm binary

import wypst from 'wypst';
import wasm from 'wypst/dist/wypst.wasm';

await wypst.initialize(wasm);
wypst.renderToString("x + y"); // Test it out!

Keep in mind that you will probably need to tell your bundler how to load a .wasm file. If you have difficulties you can open an issue.

Rendering Typst Math

To render a Typst math expression, you can use either render or renderToString, as the example below shows:

wypst.render('sum_(n >= 1) 1/n^2 = pi^2/6', element); // Renders into the HTML element
wypst.renderToString('sum_(n >= 1) 1/n^2 = pi^2/6'); // Renders into an HTML string

Contributing

All help is welcome. Please see CONTRIBUTING.

wypst's People

Contributors

0xpapercut avatar eniraa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

eniraa pcheng17

wypst's Issues

Accents support

The accent function and accent calls like macron(A) or tilde(A) are not supported.
This is true both in Obsidian and on https://0xpapercut.github.io/wypst/.

Error:

RuntimeError: Unreachable code should not be executed (evaluating 'wasm.parseTree(retptr, ptr0, len0)')

Cannot use import statement outside a module

Hey there! I'm working on a side project that involves rendering math when a friend of mine shared this repository with me, and thought that I'd give it a go in my project. I installed using pnpm, switched out my katex.render calls with wypst.render, hoping things to just magically work, but I'm running into this error. It could just be a skill issue on my part since I'm new to web dev in general, but if you have any idea what might be going on, that would be awesome.

Screenshot 2024-03-23 at 5 58 39 PM

wypst behind the scenes?

Hey @0xpapercut! I stumbled upon wypst a few days ago and it seems like the perfect fit for a project I have in mind. I am just having problems with properly trusting it because I just don't know how it works internally. HTML export for typst isn't a thing yet and you're not using something like pandoc. Could you please explain the inner workings of the module? It seems like you're using KaTeX so my current guess is that you translate typst to LaTeX and the render it using KaTeX. Idk please enlighten me :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.