Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Typst Support #1439

Open
stellarpower opened this issue Sep 28, 2023 · 3 comments
Open

[FR] Typst Support #1439

stellarpower opened this issue Sep 28, 2023 · 3 comments
Labels
feature a feature request or enhancement

Comments

@stellarpower
Copy link

For some background information, I've only started with the basics of Bookdown today, I'm not an R user, and I don't write that many documents. So can't speak from much experience.

But, I have spent a few years looking for a tool that sits betwen LaTex (too old and complicated, I don't want to waste time learning it) and LibreOffice (too manual, not reproducible, etc.). I have the exact same frustration with the lack of software for tabular data, that isn't just LO Calc or writing your own script in e.g. Ruby. LyX was reasonably nice to use for some time, but, it was too tied to LaTex, bringing me back to the original problem. I ended up writing a complicated pipeline converting to ODT and then styling it when I ran out of options, and abandoned this, so I was pleased when I learned of bookdown.

Bookdown seems to be much closer, because from what I have gleaned, it talks directly to Pandoc - whereas LyX basically wraps around LaTex and talks directly to a a rendered to spit that out as PDF. However, the fact that Pandoc then converts to LaTex and uses this to generate PDF concerns me a bit after my previous experiences with Lyx. When I learned that to add colour in bookdown, essentially I need to include a lua extension for Pandoc, that will then switch on the output format and insert the relevant LaTex, I started searching again.

I have felt for some time that PanDoc ought to have its own file format, so that we have an alternative between an old WYSIWYM format that is overkill in the modern world, and the WYSIWYG MS Word-like editors that are friendly as GUIS but bad for structured text, and plain markdown, which is designed for the web and just doesn;t have enough features for typesetting a full document.

Enter Typst. I have just learned of its existence today, and if anyone out there shares my own frustrations, I reckon it could take off and be very popular. Pandoc is already working on support for reading and has support for writing Typst, which itself can then render to a PDF - I would bet with fewer hiccoughs for general documents than when using LaTex. Admittedly this pipeline is as many steps as using LaTex, but I feel like Typst would be a more closely-aligned backend for bookdown, being more modern, simpler, closer to Markdown, and benefitting from 40 years of evolution since.

In theory, Pandoc support would provide all that is needed, to use Typst in lieu of LaTex before rendering as a PDF - but in practice, I expect more work would be needed for a close integration. As I see no mention so far in the issue list, thought I would raise it as something to have on the horizon - but as I'm not an active or experienced user, I'll leave it open for someone else to make a more detailed/over-arching/fine analysis of if and how/if this integration into bookdown ought to be accomplished.

Cheers!

@cderv
Copy link
Collaborator

cderv commented Sep 29, 2023

Hi @stellarpower !

thanks for reaching out!

I've only started with the basics of Bookdown today, I'm not an R user, and I don't write that many documents. So can't speak from much experience.

I will first react on this as we have been working on another tool which main difference is that it is not tied to R at all.
It is called Quarto (https://quarto.org) "An open-source scientific and technical publishing system" based on Pandoc.

Compared to R Markdown ecosystem, it is an evolution and a way to bring all the great feature to outside R ecosystem.
Quarto can do all that R Markdown can do, including documents, website, blogs, books, presentation, and all in one CLI tool with no external dependency (unless you need computation using R & knitr or Jupyter for Julia Python, ..)

As it is based on Pandoc too , there is already Typst support for document: https://quarto.org/docs/prerelease/1.4/typst.html

If you are starting on this reproducible publishing through Pandoc path, I would suggest to give Quarto a look and a try. To be clear (especially to other reading this), I say that because you said you are not a R user. Using bookdown would required to install R, Pandoc and packages even if you book only contains Markdown content and no R code whatsoever. With Quarto, you just need quarto CLI tool and that is all - Pandoc, Typst, etc... are all bundled, and if you do only Markdown content, with no computation code, you can use without any R or Python installation.

but I feel like Typst would be a more closely-aligned backend for bookdown,

Now about the main topic of this issue - I think this is indeed a good feature request. We would need to first bring Typst support into rmarkdown R package. Also maybe into knitr so that output of computation may be tweaked for Typst if necessary.
That is a pre-requisite. Then a bookdown format like pdf_book()

but in practice, I expect more work would be needed for a close integration.

Indeed I believe there will be more work because bookdown offers some special feature not in Pandoc, and so it would need to work also for Typst. Could be simple or not, it depends also on what Typst supports. Most of the extensions bookdown provides are descbribed at https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html

As a last note, this is almost the same team working on Quarto and on bookdown, so resources are also shared and we tend to invest really new stuff in Quarto. Though, I really thing that bringing typst to R Markdown ecosystem will be useful for all the R Markdown users out there that don't need to switch to Quarto.

We'll see when and how we could make this happen. Though PR are always welcomed !

@cderv cderv added the feature a feature request or enhancement label Sep 29, 2023
@stellarpower
Copy link
Author

Thanks, I saw Quarto mentioned on the typst discord server, so I will have to check it out in more detail. For now, I think typst probably has first-class support (or will do in time) for most of what I need to do, but if not I'll give it a try. I guess Quarto may be useful a bit like a template in that regard, and it seems as I can easily insert Raw Typst code, I can use that for a fine level of control in how those segments get rendered. Looks good overall, if I don't need to have R Studio installed just for generating documents.

Beyond that, the rest of what you are saying all sounds good to me! Thanks for getting back so quickly.

@cderv
Copy link
Collaborator

cderv commented Oct 2, 2023

For now, I think typst probably has first-class support (or will do in time) for most of what I need to do, but if not I'll give it a try. I guess Quarto may be useful a bit like a template in that regard,

Quarto will be related to Typst like Pandoc is. Input document can be a Markdown based file, which will be converted to Typst and then to PDF using typst. Quarto adds support for computation code block (evaluation and insertion of results), and Markdown syntax improvement for scientific & technical publication related features like cross references of figures, or special layouts. Aim is to have one type of document (.qmd text based file, or .ipynb notebook based file) to create several types of output (like a HTML page for a website, and a PDF document using Typst).

For all the features to work, it needs to be supported by the output document. So Typst need indeed a way to express cross reference, or any other feature we provide.

and it seems as I can easily insert Raw Typst code, I can use that for a fine level of control in how those segments get rendered.

So main advantage is to use Markdow Markup syntax, but Quarto is indeed quite configurable, by using Raw Typst directly in doc, or extended features by using Lua filters (possibly packaged in extension): Example with this poster template adapted to Quarto from this typst version

Quarto also offers Project levels features for all output format, which could be really interesting for more complex project, and more configurable content.

Looks good overall, if I don't need to have R Studio installed just for generating documents.

With Quarto you don't need RStudio at all. Not any IDE if you want as this is a CLI tool. Though, there is integrated support with VSCODE (https://quarto.org/docs/tools/vscode.html)

but if not I'll give it a try

When you give it a try, please to share with us feedback in https://github.com/quarto-dev/quarto-cli/discussions/. Having feedbacks from new users, and especially Typst user, is really valuable to us. This is early stage integration for Typst with Quarto (and Pandoc), so any feedback will help us prioritize and know what is missing and important to provide.

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants