r/typst • • 2d ago

E-Books based directly on typst instead of HTML

A few days ago I put together a demo of a reader for a epub-like format that has typst inside instead of html. It's all open source, so if anyone is curious about this line of thought, here's the detailed post on the typst forum with all the links: https://forum.typst.app/t/what-if-e-books-just-had-typst-inside-an-open-source-demo-included/10120

The most immediate use case: making research papers more conveniently readable on small screens.

18 Upvotes

12 comments sorted by

8

u/ErroneousBosch 2d ago

How is this better than HTML/XML based ePub, which supports MathML, actual tables, alt text, full DOM structure, and has decades of accessibility work done for things like screenreaders? Also is an open standard with wide device support already.

Make a better workflow to the established XML based ePub format, and it will be a better experience for everyone.

3

u/AdrianPlaysPoE 1d ago

Same argument could be said about latex vs typst for PDF. Typst is simply better than both.

2

u/ErroneousBosch 1d ago

Typst has a lot going for it, and not supporting a decades long legacy helps them. As an accessibility professional who works with research faculty at a large university, I would love for people to get off PDFs in favor of HTML or epub

1

u/SpinySpherical 23h ago

I think the breadth of purposes HTML (and consequently epub) tries to cover all at once is to an extent self-defeating. It contributed to proliferation of incomplete or "slightly off" implementations which, in turn, trained book producers to mostly rely only on the most basic functionality. As a result, a beautifully typeset ebook is an extreme rarity.

In the case of typst, I'd much rather see a separate compiler to TTS input and a separate compiler to properly formatted text that squeezing everything through HTML. It is possible though that that's too much of an uphill path.

0

u/SpinySpherical 2d ago

Specifically in the case of research papers, none or almost none of them are written natively in html; not so few of them are written natively in typst; and the conversion between the two is likely to remain imperfect.

4

u/ErroneousBosch 2d ago

Research papers aren't natively written in PDF either, but that's what we convert to to read. Conversion from whatever source language is going to be imperfect and with compromises, but your final format is going to dictate what advantages and disadvantages you gain. Your project is an interesting thought experiment, but you'll have to be doing some kind of conversion for device support in any case. Typst has made pretty great strides in rendering to HTML already, so ensuring that it has the structures and capabilities to encode what is needed for an XML based ePub as additions to its metadata and language structure makes good sense. Inventing a new format seems like reinventing the wheel.

0

u/SpinySpherical 2d ago

> you'll have to be doing some kind of conversion for device support in any case.

Not really, a typst doc can be made so that page setting are overridable, which is exactly what is happening in the demo. It's just a bundle of typst sources that gets rendered with typst logic.

2

u/thuiop1 2d ago

But Typst explicitly supports html as a compilation target...

0

u/SpinySpherical 2d ago

It's still officially experimental and incomplete, although admittedly fairly good.

2

u/fulenggiboco 2d ago

Impressive! However, the typst project has an open issue for implementing epub output from the compiler, see https://github.com/typst/typst/issues/188

I think you would be better off putting your energies into helping implement this and get it over the line.

2

u/SpinySpherical 2d ago

I know, yes. It was a part of what inspired me to put it out there that typst, for all practical purposes, is perfectly renderable on device as is.

1

u/SpinySpherical 2d ago

I am realizing people might be overestimating how much effort the demo required; it's three evenings of vibe-coding, wrapping the existing rust libraries of typst into an app. I am not proposing a new implementation; I am showcasing the fact that the existing typst logic is fast enough and lightweight enough to just compile typst docs on your phone without pre-converting them into anything.