{"id":13523211,"url":"https://github.com/fenjalien/obsidian-typst","last_synced_at":"2025-05-16T04:04:03.432Z","repository":{"id":154223947,"uuid":"618440185","full_name":"fenjalien/obsidian-typst","owner":"fenjalien","description":"Renders typst code blocks in Obsidian into images using Typst through the power of WASM!","archived":false,"fork":false,"pushed_at":"2024-11-03T17:46:56.000Z","size":4135,"stargazers_count":390,"open_issues_count":28,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-08T14:08:51.059Z","etag":null,"topics":["obsidian","obsidian-md","obsidian-plugin","typst"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fenjalien.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fenjalien","ko_fi":"fenjalien"}},"created_at":"2023-03-24T13:25:23.000Z","updated_at":"2025-04-06T14:38:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9ec8f70-01b1-41c2-b2ec-513f40696ae2","html_url":"https://github.com/fenjalien/obsidian-typst","commit_stats":{"total_commits":64,"total_committers":6,"mean_commits":"10.666666666666666","dds":0.078125,"last_synced_commit":"3fe7b321e0b3b6ff7de33a9d57ddd53d2f9432a8"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":"obsidianmd/obsidian-sample-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenjalien%2Fobsidian-typst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenjalien%2Fobsidian-typst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenjalien%2Fobsidian-typst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenjalien%2Fobsidian-typst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fenjalien","download_url":"https://codeload.github.com/fenjalien/obsidian-typst/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["obsidian","obsidian-md","obsidian-plugin","typst"],"created_at":"2024-08-01T06:00:57.119Z","updated_at":"2025-05-16T04:04:03.405Z","avatar_url":"https://github.com/fenjalien.png","language":"TypeScript","funding_links":["https://github.com/sponsors/fenjalien","https://ko-fi.com/fenjalien"],"categories":["Integrations \u0026 Tools","编辑器集成插件","TypeScript"],"sub_categories":["Editor Integrations","Obsidian"],"readme":"# Typst Renderer\n\nRenders `typst` code blocks, and optionally math blocks, into images using [Typst](https://github.com/typst/typst) through the power of WASM! This is still very much in development, so suggestions and bugs are welcome!\n\n## Small Things to NOTE\n- 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.\n- File paths should be relative to the vault folder.\n- 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!\n\n## Versions\n\n| Plugin | Typst |\n|-|-|\n| 0.10 | 0.11.0 |\n| 0.9 | 0.10.0 |\n| 0.8 | 0.9.0 |\n| 0.7 | 0.8.0 |\n| 0.6 | [522708b](https://github.com/typst/typst/commit/522708b9df0b9b2f8265938aa1f0aeda8e6e6c1f) (Some commits after 0.7.0 to include SVG export) |\n| 0.5 | 0.6.0 |\n| 0.4 | 0.3.0 |\n| 0.3 | 0.2.0 |\n\n## Using Packages\nOn desktop the plugin supports reading packages from the [`@preview`](https://github.com/typst/packages#downloads) and [`@local`](https://github.com/typst/packages#local-packages) 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. \n\nOn mobile only the `@preview` namespace is supported and will always download missing packages to the vault.\n\nYou can view the downloaded packages in the settings and choose which ones to delete.\n\n## Math Block Usage\nThe 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, `$...$` -\u003e `$...$` and `$$...$$` -\u003e `$ ... $`.\n\nFrom what I've experimented with, normal math blocks are okay with Typst but Typst is not happy with any Latex code.\n\nFor styling and using imports with math blocks see the next section.\n\n## Preambles\n\nNeed 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!\n\nPreambles are prepended to your `typst` code before compiling. There are three different types on the \"Typst Renderer\" plugin settings page:\n- `shared`: Prepended to all `typst` code.\n- `math`: Prepended to `typst` code only in math blocks.\n- `code`: Prepended to `typst` code only in code blocks.\n\nThe following variables are defined for you in all preambles to help style the output correctly:\n- `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.\n- `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.\n- `SIZE`: The font size as defined by the CSS property `\"--font-text-size\"`\n- `THEME`: A string defining the current theme of Obsidian. Either \"light\" or \"dark\".\n\nThe 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.\n\u003cdetails\u003e\n\u003csummary\u003eShared\u003c/summary\u003e\n\n```\n#set text(fill: white, size: SIZE)\n#set page(width: WIDTH, height: HEIGHT)\n```\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eMath\u003c/summary\u003e\n\n```\n#set page(margin: 0pt)\n#set align(horizon)\n```\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eCode\u003c/summary\u003e\n\n```\n#set page(margin: (y: 1em, x: 0pt))\n```\n\u003c/details\u003e\n\n## Known Issues\n### Runtime Error Unreachable or Recursive Use Of Object\nThese 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!\n\n## Example\n\n```\n```typst\n= Fibonacci sequence\nThe Fibonacci sequence is defined through the\n_recurrence relation_ $F_n = F_(n-1) + F_(n-2)$.\nIt can also be expressed in closed form:\n\n$ F_n = floor(1 / sqrt(5) phi.alt^n), quad\n  phi.alt = (1 + sqrt(5)) / 2 $\n\n#let count = 10\n#let nums = range(1, count + 1)\n#let fib(n) = (\n  if n \u003c= 2 { 1 }\n  else { fib(n - 1) + fib(n - 2) }\n)\n\nThe first #count numbers of the sequence are:\n\n#align(center, table(\n  columns: count,\n  ..nums.map(n =\u003e $F_#n$),\n  ..nums.map(n =\u003e str(fib(n))),\n))\n\n```​\n```\n\n\u003cimg src=\"assets/example.png\"\u003e\n\n## Installation\nInstall \"Typst Renderer\" from the community plugins tab in settings\n\nor \n\nInstall 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.\n\n## TODO / Goals (In no particular order)\n- [x] Better font loading\n- [x] Fix importing\n- [x] Fix Github Actions\n- [x] Better error handling\n- [x] ? Fix output image scaling\n- [ ] Use HTML output\n- [x] Override default equation rendering\n- [ ] Custom editor for `.typ` files\n- [x] Mobile file reading\n- [x] Automate package downloading\n- [ ] Use `sys.stdin` for preambles instead of modifying the source cod\n- [ ] Overhall plugin structure (mostly communication with the webworker)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenjalien%2Fobsidian-typst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffenjalien%2Fobsidian-typst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenjalien%2Fobsidian-typst/lists"}