Typst Renderer

by fenjalien
5
4
3
2
1
Score: 44/100

Description

Category: Coding & Technical Tools

The Typst Renderer plugin enables users to render typst code blocks and math blocks into images directly within Obsidian. Using WebAssembly for rendering, the plugin supports Typst's syntax and integrates preamble features to style and format the output consistently. Users can customize how typst code and math blocks are displayed by defining shared, math-specific, or code-specific preambles. The plugin also allows for importing packages from Typst's namespaces, with options to download and manage missing packages. While Typst currently exports only PNGs, SVGs, and PDFs, this plugin provides tools to work around scaling and rendering issues. It is designed for advanced users who require visually enhanced mathematical or typographic outputs in their notes.

Reviews

No reviews yet.

Stats

522
stars
11,803
downloads
32
forks
1,022
days
551
days
781
days
18
total PRs
6
open PRs
2
closed PRs
10
merged PRs
62
total issues
31
open issues
31
closed issues
11
commits

Latest Version

2 years ago

Changelog

  • Upgrade to Typst 0.11.0
  • Update fonts to be equal with Typst 0.11

README file from

Github

Typst Renderer

Renders typst code blocks, and optionally math blocks, into images using Typst through the power of WASM! This is still very much in development, so suggestions and bugs are welcome!

Small Things to NOTE

  • Typst does not currently support exporting to HTML only PDFs, PNGs and SVGs. So due to image scaling, the rendered views may look a bit terrible. If you know how to fix this PLEASE HELP.
  • File paths should be relative to the vault folder.
  • To help with loading times the web assembly file must be downloaded separately. This will automatically happen the first time the plugin is enabled and after an update!

Versions

Plugin Typst
0.10 0.11.0
0.9 0.10.0
0.8 0.9.0
0.7 0.8.0
0.6 522708b (Some commits after 0.7.0 to include SVG export)
0.5 0.6.0
0.4 0.3.0
0.3 0.2.0

Using Packages

On desktop the plugin supports reading packages from the @preview and @local namespaces. If a package cannot be found in either folder and the "Download Missing Packages" setting is on, the package will be downloaded and saved within the current vault in the pulgin's folder.

On mobile only the @preview namespace is supported and will always download missing packages to the vault.

You can view the downloaded packages in the settings and choose which ones to delete.

Math Block Usage

The plugin can render typst inside math blocks! By default this is off, to enable it set the "Override Math Blocks" setting or use the "Toggle math block override" command. Math block types are conserved between Obsidian and Typst, $...$ -> $...$ and $$...$$ -> $ ... $.

From what I've experimented with, normal math blocks are okay with Typst but Typst is not happy with any Latex code.

For styling and using imports with math blocks see the next section.

Preambles

Need to style your typst code the same way everytime and don't to write it out each time? Or using math blocks and need a way to import things? Use PREAMBLES!

Preambles are prepended to your typst code before compiling. There are three different types on the "Typst Renderer" plugin settings page:

  • shared: Prepended to all typst code.
  • math: Prepended to typst code only in math blocks.
  • code: Prepended to typst code only in code blocks.

The following variables are defined for you in all preambles to help style the output correctly:

  • WIDTH: The horizontal size of the space the output will be placed in. Can be a length or auto if the space is not limited in that direction.
  • HEIGHT: The vertical size of the space the output will be placed in. Can be a length or auto if the space is not limited in that direction.
  • SIZE: The font size as defined by the CSS property "--font-text-size"
  • THEME: A string defining the current theme of Obsidian. Either "light" or "dark".

The following are the default preambles, I highly recommend you check this on each update to make sure you don't miss any changes that could break things. That being said you don't need them they are merely recommended.

#set text(fill: white, size: SIZE)
#set page(width: WIDTH, height: HEIGHT)
#set page(margin: 0pt)
#set align(horizon)
#set page(margin: (y: 1em, x: 0pt))

Known Issues

Runtime Error Unreachable or Recursive Use Of Object

These occur when the Typst compiler panics for any reason and means the compiler cannot be used again until it is restarted. There should be more information in the console log so please create an issue with this error!

Example

```typst
= Fibonacci sequence
The Fibonacci sequence is defined through the
_recurrence relation_ $F_n = F_(n-1) + F_(n-2)$.
It can also be expressed in closed form:

$ F_n = floor(1 / sqrt(5) phi.alt^n), quad
  phi.alt = (1 + sqrt(5)) / 2 $

#let count = 10
#let nums = range(1, count + 1)
#let fib(n) = (
  if n <= 2 { 1 }
  else { fib(n - 1) + fib(n - 2) }
)

The first #count numbers of the sequence are:

#align(center, table(
  columns: count,
  ..nums.map(n => $F_#n$),
  ..nums.map(n => str(fib(n))),
))

```​

Installation

Install "Typst Renderer" from the community plugins tab in settings

or

Install it by copying main.js, styles.css, obsidian_typst_bg.wasm and manifest.json from the releases tab to the folder .obsidian/plugins/typst in your vault.

TODO / Goals (In no particular order)

  • Better font loading
  • Fix importing
  • Fix Github Actions
  • Better error handling
  • ? Fix output image scaling
  • Use HTML output
  • Override default equation rendering
  • Custom editor for .typ files
  • Mobile file reading
  • Automate package downloading
  • Use sys.stdin for preambles instead of modifying the source cod
  • Overhall plugin structure (mostly communication with the webworker)

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Auto-\displaystyle Inline Math
2 years ago by Ryota Ushio
An Obsidian.md plugin to automatically make all inline maths \displaystyle.
Calctex
3 years ago by Mike
An Obsidian plugin for automatic calculation of LaTeX formulas.
Desmos
4 years ago by Nigecat
Embed graphs directly into your obsidian notes
Function Plot
4 years ago by leonhma
A obsidian.md plugin for rendering maths graphs.
IMSwitch in Math Block
a year ago by XXM
Kroki
5 years ago by Greg Zuro
Latex Environments
6 years ago by Zach Raines
Quickly insert and change latex environments within math blocks in Obsidian.
Latex Matrices
3 years ago by Daniele Susino
An obsidian plugin to create latex matrices.
LaTeX Panel Helper
5 months ago by Luster
A powerful and convenient LaTeX symbol panel for Obsidian to enhance your mathematical and scientific note-taking efficiency.
Latex Suite
4 years ago by artisticat1
Make typesetting LaTeX as fast as handwriting through snippets, text expansion, and editor enhancements
Linter
5 years ago by Victor Tao
An Obsidian plugin that formats and styles your notes with a focus on configurability and extensibility.
Math Booster
3 years ago by Ryota Ushio
A powerful indexing & referencing system for theorems & equations in your Obsidian vault.
Math Indicator Changer
2 years ago by Ori Replication
Mathematica Plot
2 years ago by Marcos Nicolau
Insert functions on Obsidian using Wolfram Mathematica!
MathLive
3 years ago by Dan Zilberman
The must-have plugin for math in Obsidian
MathLive in Editor Mode
2 years ago by MizarZh
MathLive input in editor mode.
MathType
a year ago by slateblua
Type math faster
Meld Calc
5 years ago by meld-cp
No more flickering inline math
3 years ago by Ryota Ushio
No longer disturbed by flickering inline math in Obsidian.
Numerals
3 years ago by RyanC
An obsidian plugin which turns a math code block into a full featured calculator
Obsidian asciimath
3 years ago by widcardw
Asciimath support for Obsidian (based on asciimath-parser)
Obsidian Math+
4 years ago by Oscar Capraro
This is an Obsidian plugin for taking math notes using Excalidraw.
Obsidian matrix
4 years ago by Jonas Mohr
Project Euler Stats
a year ago by Artem Korsakov
Get statistics from Project Euler.
Quick LaTeX
5 years ago by joeyuping
Quick Matrix
5 months ago by Charlie Flowe
Plugin for Obsidian.md that allows for faster interactions with matrices in LaTeX
SwiftLaTeX Render
2 years ago by gboyd068
Typst Mate
3 months ago by azyarashi
Render math expressions with Typst instead of MathJax in Obsidian.
Universal renderer
2 years ago by Kloud
Obsidian plugin to render latex, dot, blockdiag, ditaa and other graphs
Wypst
2 years ago by 0xpapercut
High quality rendering of Typst in Obsidian, powered by wypst.