quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.93k stars 325 forks source link

pseudocode.js algorithms #4369

Open topepo opened 1 year ago

topepo commented 1 year ago

Bug description

I'm getting to the point in my book where I need to show algorithms. I couldn't get Christophe Dervieux's Rmd instructions to work, so I made a reprex repo (reporex?).

https://github.com/topepo/quarto-pseudocode-test https://topepo.github.io/quarto-pseudocode-test/

There was some weirdness. When I first compiled it, the js block wanted me to install jupyter (no thanks). I moved the same example code to the (private) book repo and rendered it so that I could take a screen shot.

After that, my reporex rendered without the jupyter request but the algorithm doesn't show up.

Also, when it does show up, the equations are not rendered (see the screen shot in the reporex).

Checklist

cderv commented 1 year ago

When I first compiled it, the js block wanted me to install jupyter (no thanks).

I believe this is only because of auto binding to engine. Quarto will only bind to knitr engine when it detects a R chunk in the doc. Otherwise, if when no R chunks, it will default to Jupyter for computation. You would need to be explicit by setting engine: knitr in the YAML of the doc where you want to use js knitr engine and only that. More on that here: https://quarto.org/docs/computations/execution-options.html#engine-binding

Do you have a R chunk in your qmd where you are using this ? Have you set the execution engine already ?

Regarding example, the one I share on Rpub still works for Quarto: https://cderv.quarto.pub/test-pseudocodejs/ I only changed the YAML header

---
title: "test pseudocode.js"
format: html 
embed-resources: true
include-in-header: head.html
code-tools: true
engine: knitr
---

Hope it helps.

I really should make an extension of this example

camilogarciabotero commented 1 year ago

I opened a discussion about other implementations of those kinds of blocks. This could be a nice feature/extesion!

cderv commented 1 year ago

This could be a nice feature/extesion!

Yes definitely. I'll try to do it soon for a first proposal. Long term I think we may try to support that built-in to Quarto

topepo commented 1 year ago

@cderv Thanks I'll update my repo(s) with the new options.

Your test repo doesn't process the math either :-/

cderv commented 1 year ago

I may have missed what the issue is. My example seems to work fine on my side.

I'll try with yours. We can quickly connect live otherwise so that you can show.

Sorry for this

cderv commented 1 year ago

Oh I see now. indeed... sorry for that. I misunderstood which math 🤔 I need to find the trick

topepo commented 1 year ago

We need a "no worries" emoji to choose at the comment-level in GH.

cderv commented 1 year ago

FWIW It seems someone already made an extension for this

https://github.com/leovan/quarto-pseudocode

topepo commented 1 year ago

That works for me (although the font is a little wonky). Thanks!

camilogarciabotero commented 1 year ago

Yes definitely. I'll try to do it soon for a first proposal. Long term I think we may try to support that built-in to Quarto

Could still this be a built-in feature to implement in the future? Leovan´s extension could be another starting point for a built-in?

cderv commented 1 year ago

I agree that we could try to add this support built in. I'll reopen for future consideration.

dragonstyle commented 1 year ago

Just as a note for future implementers, I looked pretty closely at supporting this as a native feature and the biggest issue that I ran into was supporting a common pseudocode syntax (within the pseudocode block) across formats (HTML and LaTeX). It seemed like it should be possible to get the supported syntax to be close (or the same), but I couldn't find a way to make that happen. I think supporting multiple format output is essential if we're planning on productizing this.