quartools icon indicating copy to clipboard operation
quartools copied to clipboard

Code chunk generation

Open ElianHugh opened this issue 7 months ago • 0 comments

Ran into an issue with generating programmatic typst blocks, because they need their own code chunks so as to be evaluated properly. Ended up having to handroll a solution, so I think it makes sense that quartools supports this. Might have to examine quartools again because it's been a while since I've looked at the code :)

E.g., qto_codechunk with the following interface

qto_codechunk(
  ..., 
  lang = NULL,
  id = NULL,
  class = NULL,
  css = NULL,
  .attributes = NULL,
  .content = NULL,
  collapse = "",
  drop_empty = TRUE,
  drop_na = TRUE,
  call = caller_env()
)

So qto_codechunk("#colbreak()", lang = "=typst") would generate:

```{=typst}
#colbreak()
```

Perhaps has implications for creating plain fenced blocks too, but the interface might need some more thought

ElianHugh avatar Apr 04 '25 02:04 ElianHugh