fredrikekre/Literate.jl

Hide clode blocks?

Opened this issue · 2 comments

I am aware that if I add #hide to the end of a line of Julia code, that line is executed but not rendered. I'm also aware that if I have a block of code and I want to execute it but not render it, I can also prepend #hide to each line.

But it is inconvenient to apply these changes to each line. VS Code, for example, can comment and uncomment lines but not (that I am aware) with an additional bit of text. So if I uncomment all these lines with #hide at the start, I just get a bunch of Julia code with the token hide on each line. So toggling back and forth isn't so easy.

I looked through the documentation and I didn't see any way to fence an entire chunk of code in this way. Something along the lines of:

#begin hide
Some Julia code I want to run, but not show
potentially spanning
many,
many 
lines
#end hide 

But I just wanted to check here to see if I was missing anything (or perhaps some other way to achieve the same result).

Thanks.

I just use multi-cursor to insert #hide in VS Code:
Highlight lines in VS Code, then alt-shift-I (tested on Linux), press END on keyboard, and type #hide. There are a few guides on the internet on multi-cursor hotkeys and workflows in VS Code.
You'll need to manually delete the #hide inserted on blank lines though.

I hope this is an acceptable work-around for now.

This something you can sort of achieve with preprocess -- I have used it e.g. here

https://github.com/PoisotLab/SpeciesDistributionToolkit.jl/blob/main/docs/make.jl#L17-L36