data-intuitive / quarto-d2

GNU Affero General Public License v3.0
28 stars 3 forks source link

ENH Suggestion: Return the code as well as the diagram #6

Open zachcp opened 4 months ago

zachcp commented 4 months ago

This is a great addition to the ecosystem, thank you!

Is there a relatively easy way to retain the code so the code and the image are both viewable? Ideally I'd like to have the code in a folded code block as per other types of code. Do you think it would it be relatively straightforward to add this?

Thanks, zach cp

rcannood commented 4 months ago

Is the echo parameter what you are looking for? (See https://github.com/data-intuitive/quarto-d2?tab=readme-ov-file#attributes)

zachcp commented 4 months ago

@rcannood Beautiful - I didn't see that.

So I just gave it a whirl and the code returns which is great, but it doesn't seem to respect Quarto's code-fold option. Do you know if there a way to get it to fold? (these can be long diagrams)

rcannood commented 3 months ago

I see -- quarto-d2 would probably need to make use of https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/filters/quarto-post/foldcode.lua. I'll leave this GitHub issue open for now.