Adding support to specify import location via URLs #2658
Replies: 2 comments 3 replies
-
Hi there, I have open this discussion knowing very well that what I am proposing is drastic change in the language. Nonetheless, I believe this feature could help a lot of typst users in my situation. From the 5 up vote on this discussion, I assume 4 other person than me would like to see this feature too. I have a working prof of concept1. It seams fully functional but still lacks couple of things before I can officially open a PR (general clean-up, comments, integration tests, better http integration, ...). So my question: would you be willing to merge this kind of feature in typst? regards, didier Footnotes |
Beta Was this translation helpful? Give feedback.
-
I like your proposal! But what if your #import "@local/common.typ": basic-footer, basic-header
#import "@local/foo.typ": name After taking a look at your |
Beta Was this translation helpful? Give feedback.
-
Before introducing my formal proposal, allow me to contextualize it. I have been teaching a couple of classes lately and I have been using typst to write all my documents. I have many documents in different git repositories1. Usually, multiple typst documents by git repository. A typical course requires me to write a syllabus, some homeworks and addition documents; all in typst. To be professional, these documents need to look the same. Currently, the only way I have to share the style between documents located in different repositories is to copy typst code.
I know I could leverage git submodules. As I am using nix as build system, I could use that too. I am aware (but not up to date) with typst packages. Nonetheless, I feel my needs would not be fulfilled by any of these technologies. I would like to have a way to trivially share code between projects without polluting a global repository.
My proposal is to allow imports via URLs in typst in a very similar fashion than JavaScript modules. Go uses something similar to import URLs too. Deno uses JavaScript modules too2 and I love my experience with it.
Below is an example of what I am proposing.
Using URLs in imports would benefits typst users by allowing them to easily share code between repositories in a very stable manner without polluting a global repository. For instance, teachers of my department could all use the same template by simply publishing the template on github and referring the template via the url github provides. For simple documents, a centralize repository requires too much ceremony.
Some people do not like import URLs because they say it is insecure3 and for the lack of dependency versioning4. Practically, I believe it is possible to fix these issues using vendoring and import maps in a very similar fashion than what deno does 5.
My personal experience of writing a lot of small to medium documents in typst has shown me a need of a clean way to share personal code between projects and I believe adding the possibility import files by path would be great solution.
thanks,
didier
Footnotes
https://gitlab.com/didier-ahuntsic ↩
https://go.dev/doc/modules/managing-dependencies ↩
https://deon.land/ ↩
https://groups.google.com/g/golang-dev/c/nMWoEAG55v8/m/iJGgur7W_SEJ ↩
https://docs.deno.com/runtime/manual/basics/import_maps ↩
Beta Was this translation helpful? Give feedback.
All reactions