TIL that Helix and Typst are a match made in heaven
48 points by cgrinds
48 points by cgrinds
I'm curious which parts of this are particular to Helix and would not work in another editor with language server support. I tried Helix for a couple months about a year back and I largely enjoyed it, but I had too many issues with outdated buffers overwriting code when switching branches.
Author here. Most of the magic happens in the Language Server, I just happen to be a Helix nerd and it was my practical use case.
The outdated buffers is indeed a real problem. There's this PR in the works to solve it at least for macOS and Linux, but it's moving at glacial speed. Helix is a fantastic editor, but the maintainers don't have a lot of time to review the nearly 500 PRs open. I wish they onboarded more co-maintainers to spread the load.
Absolutely not Helix specific (no disrespect!), but tinymist is pulling the weight here. I use Neovim + tinymist to do the same stuff, and the preview renders in Safari on my second monitor.
Helix and LSP aside, I'm surprised to see Typst as a viable Markdown replacement. I thought it'd be more like LaTeX, and a total overkill for simple documents, but it seems like it's possibly just a better Markdown with an actual standard behind it?
Does anyone else use it this way, care to share your experiences?
I've occasionally used Typst as a Markdown replacement for university lecture notes, to easily drop in math snippets. It worked, but two things kept me from pursuing it further:
Typst is simple for simple things and complicated for complicated things. That's a huge improvement over both markdown and LaTeX. Markdown cannot do complicated things and LaTeX is complicated even for simple things. So yeah, I think Typst would be a great markdown alternative.
I already use Typst for all my PDF-generating needs, like papers and presentations. I'm just waiting for more mature HTML support. This is what I use markdown a lot for, writing simple website content. Blog posts, docs for little side projects etc. The downside of using markdown for this is that usually you need one or two random features that markdown simply doesn't have. Then you reach for extensions and build systems on top of markdown... it's a mess. Typst can be powerful enough that you don't need anything else. I'm dreaming of a package you can import from Typst universe that's basically a template / toolbox for building documentation websites.
Another angle is that if you're accepting input from users, markdown is simpler to handle. Take a comment text box on a forum, for example. Using markdown for that is just simpler for the forum software to handle. Since Typst has a builtin scripting language, using that could lead to a DoS attack, where a user posts a comment that was crafted to take ages to compile.
So, I suspect markdown will have its place for a long time, but Typst has a bright future and a very broad range of applications where it can shine.
The downside of using markdown for this is that usually you need one or two random features that markdown simply doesn't have.
But HTML usually does (especially if your target is web publishing). And Markdown allows embedded HTML.
Edit I'm not trying to denigrate Typst, it does sound cool and it's great that LaTeX is getting some competition. But there's a reason that Markdown is a sort of local minimum when it comes to online authoring , and it's gonna take a whole lot of energy to move to the next higher local minimum.
(edited to correct spelling of minimum, thanks @reivilibre)
Why don't people write everything in HTML then? Because it's tedious and more complicated than it needs to be for the task at hand. I'm saying this is still the case for a lot of things people want to do when creating simple to medium complexity websites. Want to draw a diagram? Markdown doesn't have that feature. Sure, you can write the SVG inline, specifying every path coordinate by hand. That's not what people do. They reach for a diagramming tool and then some build tool to stitch it together with the markdown text. With typst, you can create beautiful diagrams easily with packages like fletcher.
I am stating, without too much evidence because I don't have much experience with them, that most features that Markdown detractors covet but are missing in stock MD ("callouts", "asides") can be trivially implemented in embedded HTML in Markdown.
I've used this feature many times myself. I don't have automatic anchor tags in my content, but when I need them, I can easily add them. Same for footnotes. If I need a table, I usually generate it with an outside tool and paste the HTML code.
Edit to add knowing Markdown and just a smidgen of HTML brings me to 99.9% of what I want to do when authoring web content on platforms I control. As I stated earlier, it would have to take a lot of effort from Typst's side to entice me to switch (especially considering Typst's rudimentary current state of styling c..f. https://lobste.rs/s/culejy/blogging_typst_is_not_hard)
It seems Typst also allows embedded HTML, see https://typst.app/docs/reference/html/elem/ (Of course this is only for the HTML export, but then the same applies to Markdown really. The best way to convert Markdown to PDF that I've found has been to use a webkit-to-PDF renderer, which is a bit funny if you think about it)
(side note: 'minimum' is the word. 'minima' is the plural of 'minimum'. Not that you'd be the only one to mix this up)
The best way to convert Markdown to PDF that I've found has been to use a webkit-to-PDF renderer
What are the advantages of doing it that way compared to using Pandoc?
This might be a few years out of date so take it with a grain of salt, but iirc Pandoc converts it to LaTeX first to then convert it to PDF, right?
I believe I had various layout troubles when doing it that way, I can't remember exactly what though; might have been that some elements (tables?) were overflowing the width of the page, whereas browsers are a bit more dynamic about the way they can layout tables.
(If someone with more recent experience knows, or alternatively can tell me I'm wrong, I'd be happy to hear)
I use it this way. I used to use Markdown for everything-everything. pandoc's Markdown flavour in particular is quite nice, and quite configurable, and it's very easy to render to PDFs for assignments and such. Eventually, though, I started needing a little bit more: specifically, diagrams and syntax trees, and resorted to hacks with introspecting on LaTeX-tagged code blocks with pandoc's filters.
I tried out Typst at the start of the year and I'm never going back. Since it's extensible with packages, it has actual support for diagrams and typesetting and what not, which is much nicer to use than the hacky Markdown + LaTeX stuff I was using before (which unfortunately still meant I had to deal with LaTeX's reprehensible error reporting).
But yes, I think it's better at simple documents than Markdown is, too. Take a look at the syntax. That's it! It's about as simple, maybe simpler than Markdown. Commonly used functionality gets special syntax, but because Typst has functions, less commonly used functionality can get regulated to there (i.e. #strike, #highlight). And Typst's syntax fixes some minor annoyances of Markdown, too. __ is for italics, while ** is for bold... - is similarly for bullet lists but there's also + for automatically-numbered lists, which means 1. etc for numbered lists renders the correct numbers. Pretty handy!
I've still got loads of Markdown documents lying around, but I'll be converting my personal wiki over to Typst once the HTML export functionality improves, and it's become my de facto notes syntax.
Markdown still has ubiquity but other than that I also find myself wanting to use Typst everywhere too. Heck, now you're making me think I want a mdBook-but-Typst.
Seems like there is some work in this space.. https://github.com/Myriad-Dreamin/shiroa
I use it for all of the thousands of documents in my document-system/pkm (including the subset that make up my personal blog) in exactly this way. It took very little time to mentally switch over from markdown/Djot. It's spec, consistency, HTML+PDF exports, and being able to trivially write custom functions is just a pure joy. Can highly recommend :)
Wrote my entire internship report using typst and it was a pleasure to use this Tinymist extension on VSCode for a quick preview (just like Markdowns) directly in my editor. Highly recommend!
I've also found Tinymist working really well. To anyone trying it: for the live updates to work, make sure to open the extension's own "preview" pane and not a generic PDF viewer extension. Sounds obvious in hindsight but the documentation wasn't very clear on this.
markdown has too much momentum and is too useful in too many places for me to consider even looking at Typst. I am sure that Typst is a great solution, but it is to a problem which I do not have.
Lilypond has had approximately this for a very long time, though triggered on save rather than edit:
Unless you disable “point and click” (which you should do for production builds), every graphical object in a PDF or SVG it generates will be a link to textedit://‹/path/to/file.ly›:‹line›:‹char›:‹column›.
Register textedit URLs to be handled by lilypond-invoke-editor (which supports a bunch of editors—atom, emacs, geany, gedit, gvim, jedit, kate, nedit, syn, uedit32).
Use a PDF viewer that reloads when the file changes, and which allows opening textedit links. I think that was Evince for me back when I last did this maybe a decade ago. I recall having to fiddle with AppArmor after upgrading Ubuntu once.
Run something that watches your source files and invokes the Lilypond compiler. Don’t remember what I used last time I was doing this sort of thing, but nowadays I’d use something like `watchexec --ignore=*.pdf 'lilypond *.ly'.
Oh amazing! I’ve been making slides in typst and helix this week and this is a huge improvement in my workflow
You don’t need a language server, just typst watch and a PDF viewer which supports automatic document reloading, like zathura.
Yeah, that's what I do right now. It's great. I guess the one big advantage of using the LSP for preview is the bi-directional cursor jumping. I'll have to try it out to see how useful it is.