Universe

Perlit is a library for rendering Obsidian graphs in Typst with CeTZ

Usage

#import "@preview/perlit:0.0.1": draw

#draw(json("/example.canvas"))
simple obsidian graph simple graph rendered in typst

To use this package, simply import and call the draw function with the loaded json of the graph you want to render. For security reasons, typst cannot read files outside of the documents’ root directory. For more information, read the typst docs.

different graph features in obsidian different graph features rendered in typst

Loading files (experimental)

Obsidian graphs can contain files like images and pdfs. As typst doesn’t allow loading files from outside the project root, the loading of the files needs to be handled by the user.

IMPORTANT: Currently files need to be directly in the root directory of the document to be available to the graph in typst

Images

#import "@preview/perlit:0.0.1": draw

#draw(
  json("/testgraph.canvas"),
  velocity: 0.1,
  curve: false,
  file-handlers: (
    "jpg": (path: str, length: length, ..args) => {
    	image(path, width: length)
  	},
  ),
)
imported image in obsidian imported image rendered in typst

Other Graphs

This also means that other graphs can be imported into the graph:

#import "@preview/perlit:0.0.1": draw

#draw(
  json("/testgraph.canvas"),
  velocity: 0.1,
  curve: false,
  file-handlers: (
    "canvas": (path: str, ..args) => {
    	draw(json(path), scale: 0.8, ..args)
  	},
  ),
)
nested graph in obsidian nested graph rendered in typst