On a Hugo site with code blocks, I would like to be able to somehow test that code in an automated way. Specifically, I am talking about Go code, but the language does not really matter.
One way I can think of is to somehow make Hugo extract the code into separate files, potentially placed into functions the languageβs test tool recognizes as tests. On these files, I could run the tests.
Maybe alternative output formats and code block rendering hooks could help here somehow?
Alternatively, the code could be in separate files and be drawn into the blocks on the site. This seems possible with readFile. However, each block needs its own file then I guess.
The first option would be way more author friendly. Can anybody hint me in a direction how this could be achieved?
Thinking about it a bit further, it may indeed be more flexible to do it with option 2. E.g., with some string functions application, it also allows to include only the relevant code in the code block, not potential boilerplate around it.