JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
821 stars 94 forks source link

Folding code blocks but not the output (e.g. figures) [FR] #477

Open nathanaelbosch opened 8 months ago

nathanaelbosch commented 8 months ago

A similar issue (#425) requests foldable code blocks, and a comment also provides a simple solution to get the desired result. However, surrounding a code block with <details> and </details> would also hide the output generated by Weave.jl, such as a figure. Is there any way to hide the code, but not the output?

nathanaelbosch commented 8 months ago

A quick and hacky implementation of this:

Weave.register_format!("custom", Weave.GitHubMarkdown(
    codestart="""
    ```@raw html
    <details><summary>Code:</summary>
```julia""",
codeend="""
```
```@raw html
</details>
```
""",

))


This makes _all_ code folded in a `<details>` block with summary `Code:`. This works well enough for my use-case, but I think a chunk option could still be valuable.