GithubHelp home page GithubHelp logo

0xpapercut / obsidian-wypst Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 2.0 17.11 MB

High quality rendering of Typst in Obsidian, powered by wypst.

License: MIT License

JavaScript 40.96% TypeScript 58.07% CSS 0.97%
math-typesetting obsidian typst wypst

obsidian-wypst's Introduction

obsidian-wypst's People

Contributors

0xpapercut avatar haruleekim avatar

Stargazers

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

Watchers

 avatar  avatar

obsidian-wypst's Issues

Inline RTL

Hey,
the plugin doesn't work correctly with rtl text. It does show it as rtl, but as far as math concerned it's ltr :)

Explictly typst blocks

It would be nice if wypst could have syntax for an explicitly typst inline or display equation, like the asciimath plugin. Then, rendering all equations as typst could be optional behavior.

Package imports

Is there any feature planned similar to the preamble one of obsidian-typst?

My use case is to add the physica package, required for most of the math in physics.

Thanks for this nice plugin ๐Ÿ˜€

Multiline math blocks don't work

Hi! I love this plugin and how easy it is to use without requiring any complicated settings!! โค๏ธ

I'm encountering an issue though: using multiline math like

$$
Q = rho A v + "time offset"
$$

causes

image

to be displayed. I usually format bigger math like described above, so it would be awesome if this plugin could support it :)

Render typst source code

Any chance for making this plugin render code blocks and not only equations?
I want my files to be rendered outside obsidian and the math syntax can lead to problems with mathjax and things like that.
Just to be clear, I want to write all the equations in typst code blocks. For example:

f(x) = 8x^2 + 3x

Primes break rendering.

If you have a symbol like $delta$ it renders fine, but if you add a prime, i.e. $delta'$ it suddenly breaks rendering.
image

Attach does not work as expected

When rendering the example from Typst documentation, Wypst seems to treat t as tr and b as br. Moreover, nothing else is rendered.

Typst:

attach(
  Pi, t: alpha, b: beta,
  tl: 1, tr: 2+3, bl: 4+5, br: 6,
)

LaTeX:

\underset{\beta}{\overset{\alpha}{\prescript{1}{4+5}{\Pi}^{2+3}_{6}}}

Outputs:
screenshot_20240228T120643-0500 png@2x

Calling `text()` with argument `fill` causes text not to be rendered

Obsidian version: v1.5.12
Obsidian-wypst version: 0.0.3

Calling text() in a wypst-math-block causes text not to be rendered if the fill argument is passed.

How to recreate:
$text("n", fill: #rgb("#00ff00"))$

Expected result:
A green letter 'n'

Result:
The letter is not rendered

Fallback to LaTeX when variable is not found

I have an existing vault full of LaTeX, and a great deal of LaTeX equations fail to render with this plugin enabled. The main issue I've noticed is that latex allows $dx$ to represent two variables next to each other, while in Typst $dx$ is an error when $dx$ is not defined. There are many LaTeX equations which Wypst detects as Typst as it does not contain a backslash but then fails to render because of this.

If possible, it would be best for Wypst to fallback to LaTeX when a variable is not found, or perhaps any time there is an error rendering the equation.

Grid doesn't seem to work?

None of the examples from Typst documentation work.

A simple example generates nothing and produces no error messages:

#grid(
  columns: 5,
  gutter: 5pt,
  ..range(25).map(str)
)

The tiger example and the chessboard example give an error message of 'expected semicolon or line break':

// We use `rect` to emphasize the
// area of cells.
#set rect(
  inset: 8pt,
  fill: rgb("e4e5ea"),
  width: 100%,
)

#grid(
  columns: (60pt, 1fr, 2fr),
  rows: (auto, 60pt),
  gutter: 3pt,
  rect[Fixed width, auto height],
  rect[1/3 of the remains],
  rect[2/3 of the remains],
  rect(height: 100%)[Fixed height],
  grid.cell(
    colspan: 2,
    image("tiger.jpg", width: 100%),
  ),
)
#set text(15pt, font: "Noto Sans Symbols 2")
#show regex("[โ™š-โ™Ÿ๏ธŽ]"): set text(fill: rgb("21212A"))
#show regex("[โ™”-โ™™]"): set text(fill: rgb("111015"))

#grid(
  fill: (x, y) => rgb(
    if calc.odd(x + y) { "EFF0F3" }
    else { "7F8396" }
  ),
  columns: (1em,) * 8,
  rows: 1em,
  align: center + horizon,

  [โ™œ], [โ™ž], [โ™], [โ™›], [โ™š], [โ™], [โ™ž], [โ™œ],
  [โ™Ÿ], [โ™Ÿ], [โ™Ÿ], [โ™Ÿ], [],  [โ™Ÿ], [โ™Ÿ], [โ™Ÿ],
  grid.cell(
    x: 4, y: 3,
    stroke: blue.transparentize(60%)
  )[โ™Ÿ],

  ..(grid.cell(y: 6)[โ™™],) * 8,
  ..([โ™–], [โ™˜], [โ™—], [โ™•], [โ™”], [โ™—], [โ™˜], [โ™–])
    .map(grid.cell.with(y: 7)),
)

removing the first three lines (#set... #show...) gives an error of 'type color has no method transparentize'.
Removing .transparentize(60%) then gives an error of 'function grid does not contain field cell`'.

Perhaps a separate ticket but none of the table examples in table documentation seem to work, either.

Thank you!

Newline, export

Finally! After looking for latex/typst plugins for obsidian, I found something that WORKS.
(now three) small issues:

  1. Rendered space between two lines is a bit to small.
  2. After exporting to pdf, it breaks with the error code "unexpected dollar sign".
  3. same as 1. but with spaces too.

Both 1,3 can be "fixed" by inserting an empty/space only string

More than one non-numeric character in a vector component causes RuntimeError: unreachable

Obsidian version: v1.5.12
Obsidian-wypst version: 0.0.3

Vectors that contain more than one non-numeric character in any component cause a "RuntimeError: unreachable"

Vectors that contain purely digits are fine, e.g. vec(111,222)
Vectors that contain single non-numeric characters per component also work fine, e.g. vec(n,k)

The problem arises when there are multiple such characters in a component (or a digit + non-numeric).
Examples:

  • vec(2, 2x)
  • vec(2, 2-1)
  • vec(2, n-k)
  • vec(2, [n])
  • vec(2, n!)

All result in "Runtime Error: Unreachable"

However, something like

  • vec(2, n_2)
  • dots.v

does not cause the error

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.