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: Output to Quarto markdown flavour #199

Closed
svilupp opened this issue Aug 4, 2022 · 3 comments · Fixed by #200
Closed

FR: Output to Quarto markdown flavour #199

svilupp opened this issue Aug 4, 2022 · 3 comments · Fixed by #200

Comments

@svilupp
Copy link
Contributor

svilupp commented Aug 4, 2022

It would be amazing to add support Quarto markdown flavour

User story: As an analyst, I would like to write my script in Literate.jl format and easily convert to Quarto markdown to be able to further output to standard business outputs (PDF, presentations, etc)

What would it take? Would it be simply changing the codefence and adding a custom YAML header?

EDIT:

Background on Quarto:

  • Quarto is a cross-platform cross-language open-source scientific and technical publishing system built on Pandoc
  • It grew from Rmarkdown/knitr eco-system but has first-class support for Julia and Python
  • There is already a good ecosystem: CLI, VS Code extension, JupyterLab support, caching support (for previews)
  • It was introduced in JuliaCon 2022: Reproducible Publications with Julia and Quarto | J.J. Allaire | JuliaCon 2022

Markdown specs:

  • Julia reference
  • It seems to support CommonMark (similar to Literate.jl): reference
  • Code cells seem to have {julia} instead of julia codefence and there are some additional options, which I'm not sure how they would be passed: Jupyter reference
  • There is an additional YAML header where the user can provide some formatting configurations but also select which jupyter kernel to use for evaluation of the notebook (it's not clear to me how the julia Pkg environment is provided)
@fredrikekre
Copy link
Owner

Can you link to some description of what Quarto markdown flavor is?

@svilupp
Copy link
Contributor Author

svilupp commented Aug 4, 2022

Apologies! I've beefed up the original post with some references and an introduction.

@svilupp
Copy link
Contributor Author

svilupp commented Aug 5, 2022

Findings from a quick investigation: we get most of the functionality with the existing blocks, the only challenge I found is parsing the modifying attributes like #| echo:false that need to be inside of code blocks.

Goal: producing a .qmd file that corresponds to Quarto specs

I've created a gist here with:

  • target file quarto_jl.qmd that we would like to produce
  • source file quarto.jl that we feed to Literate.jl

Code pipeline (from REPL):

using Literate
Literate.markdown("quarto.jl",flavor = Literate.CommonMarkFlavor(),codefence="```{julia}" => "```")
mv("quarto.md","quarto.qmd")
run(`quarto render quarto.qmd --to html`)

The only challenge I found was how to create a cell like this with #| echo:false-like statements

```{julia}
#| echo: false
#| output: false
using Pkg; Pkg.activate(".")

Proposal

  • I think we could easily add a new flavour of markdown with its codefence here
  • Writing the result to the right filename, probably use the keyword literate_outputfile in the config - EDIT: that doesn't work, but perhaps we could just suffix quarto markdown with .qmd
  • ? How to pass the code-block arguments? I think the rule that's not working is that a comment expects a space (eg, ## Comment), so this regex doesn't get triggered

I'm happy to open the PR but I'm not sure how to best tackle the 3rd bullet - any ideas?
Maybe adding an optional | symbol after the # to the regex to be still treated like a comment?

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

Successfully merging a pull request may close this issue.

2 participants