-
DescriptionWe are looking for an authoring tool to help us present tutorials for a c++ library. Each tutorial needs to walk through an entire source file, interspersing the source code with rich commentary that links to other documentation, research papers, other tutorials, etc. Quarto seems very promising for this! However, we definitely want a "single source" of truth for the code itself, to make sure that the actual c++ source file that a user compiles locally matches up with the code in the tutorial HTML page. So our question: is there a way to synthesize a new file from all the code blocks in a markdown file? E.g. a kind of lightweight "literate programming" that simply concatenates the code blocks together in order? We could certainly write a post-processor to do this extraction but would prefer to use existing standard tools if for this if they are available. I had a look at Thanks for any pointers or insights, and if there is some different better approach we would be glad to hear about that, too. Toy example with two
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
See: (or more directly: #9112 (reply in thread)) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reference @mcanouil when I run this code on the file above (saved as > quarto inspect foo.md | jq '
.fileInformation[].codeCells |
map(
.metadata = (.metadata | to_entries | map("#| \(.key): \(.value)") | join("\n"))
) |
group_by(.language) |
map({
language: .[0].language,
contents: map(.metadata + "\n" + .source) | join("\n")
})
'
[] |
Beta Was this translation helpful? Give feedback.
-
@mcanouil Is this just a bug related to highlighting cpp code blocks? (the quarto kind with curly braces, e.g.
you can see how syntax highlighting is applied to python but not cpp (at least, not more than "default" code block formatting): ![]() It's just weird since ```cpp (no curly braces) highlights just fine. This is so close to working for our needs. |
Beta Was this translation helpful? Give feedback.
Let me clarify some context about syntax here before trying to answer your initial question.
.md
doc can work with quarto, but this means they are not expecting to contains computation. No execution engine will be used (or more precisely, the markdown engine will be used which leads to no execution of computation of cell..qmd
needs to be used to work with computations.The former is the Source code block syntax, and the latter is the execution code block syntax. Those are totally different usage. You shouldn't need to use computation if you only want to demo code and not execute the cell.
I just…