litedown icon indicating copy to clipboard operation
litedown copied to clipboard

feature request: make litedown more shell friendly

Open AlbertLei opened this issue 1 year ago • 4 comments

I consider myself a minimalist and like the idea of litedown. However, one thing that prevents me from trying litedown more is its focus on users who primarily work within an R session. Indeed, the docs seem to even assume users are using RStudio and frequently talk about the knit button.

I would try litedown more if it could (i) offer a CLI tool or (ii) provide guidance in the docs on how to create a bash wrapper around RScript to use it. Method (ii) may be easy and straightforward (am i right?). But knowing that the developer has users like me in mind would certainly encourage me to try litedown more.

I think there are other potential users like me. While litedown is an R package, its main functions are more similar to pandoc/quarto. I think most people use pandoc and quarto from CLI.

AlbertLei avatar Dec 06 '24 05:12 AlbertLei

For now, the shell version would be:

  1. Type R in the shell to start R.
  2. Type litedown::roam().

Or

R -e 'litedown::roam(open=TRUE);while(TRUE)Sys.sleep(.01)'
# Ctrl + C to stop

If you only intend to render one file, call litedown::fuse() or litedown::mark(), which can also be done via R -e, or a shell script wrapper, which should be quite straightforward to write, e.g., fuse.sh

#!/usr/bin/env Rscript

litedown::fuse(commandArgs(TRUE))

Then

./fuse.sh your-file.Rmd

If you are looking for a product similar to litedown but doesn't depend on R, you may come back a year later. I have had some wild ideas for quite a while and need to find time to try.

yihui avatar Dec 06 '24 06:12 yihui

YAML header should contain all the information and I usually have a project-wide makefile, but an executable script added to a path so I could just do:

litedown infile.rmd --out latex --keep_md --options +toc

or a variation of thereof sounds rad.

J-Moravec avatar Dec 09 '24 03:12 J-Moravec

Yes, that would be nice and shouldn't be hard to write (especially on *nix).

A true executable?

When I said "a year" above, I meant "give me some time next year to learn Rust and reimagine Jupyter" (then a by-product would be a true CLI tool, not just a wrapper shell script).

yihui avatar Dec 10 '24 17:12 yihui

Coming here late but as it is related: I also prefer shell (and/or farmed out shell calls from the editor) and FWIW I have been driving rmarkdown and friends for many years now from a simple shell wrapper render.r. It, just like dozens of similar scripts, are in package littler and use /usr/bin/r (or /usr/bin/env r). It would be pretty trivial to rewrite them for Rscript (and its mostly just the commandArgs() business).

It would be trivial to extend this to litedown.

eddelbuettel avatar Mar 15 '25 15:03 eddelbuettel