Literate.jl icon indicating copy to clipboard operation
Literate.jl copied to clipboard

Custom code fence per code block

Open efaulhaber opened this issue 1 year ago • 3 comments

According to the docs,

  • The default code fence will change from

    ```julia
    # code
    ```
    

    to Documenters @example blocks:

    ```@examples $(name)
    # code
    ```
    

And in the config, I noticed that this can be changed with codefence. However, I would like to use a different fence only a single code block, which should read

```@cast
# code
```

to use Asciicast.jl. See the docs here. Of course, I don't want all blocks to generate Asciinema output.

Is this currently possible?

efaulhaber avatar Nov 20 '24 09:11 efaulhaber

You can do

# ```@cast
# # code
# ```

fredrikekre avatar Nov 20 '24 09:11 fredrikekre

Cool! But then I would have to do something like

# ```@cast
# my_code()
# ```
my_code() #!md

so that my_code() is

  1. run when I include the file,
  2. included in the notebook and
  3. not executed twice in Documenter.jl.

Right?

efaulhaber avatar Nov 20 '24 13:11 efaulhaber

Yes. If you have more code that depends on this I think you need to evaluate it twice anyway (otherwise the variables won't be in the same anonymous module).

fredrikekre avatar Nov 20 '24 13:11 fredrikekre