owickstrom / pandoc-include-code

A Pandoc filter for including code from source files
Mozilla Public License 2.0
139 stars 18 forks source link

Nested Snippets #16

Open makersend opened 5 years ago

makersend commented 5 years ago

I often need to include an overview and snippets from the same source code.

It'd be cool if it was configurable to omit all "snippet-oriented" comments, e.g., start and stop snippet.

I don't know Haskell so I can't help :/ But I could document it.

owickstrom commented 5 years ago

Do you mean you want to include the entire source file, but excluding the snippet comment lines? Not the content of the snippets?

makersend commented 5 years ago

@owickstrom Sorry for the delayed response--was missing notifications.

Yes--currently I have to have two copies of source files, one for an entire listing, and one for small snippets. And while I worked around it, I also had a nested snippet usecase, e.g.,

// snippet Something we want to look at in-the-large
someCode();
moreCode();
// snippet And something small within that we need to talk about
somethingImportant();
// end-snippet
yetMoreCode();
// end-snippet

So yes: strip out snippet start/end markers. Which of course opens up new different worm-cans; should the whole line be removed (my vote), should it be replaced with a blank line (not as cool), etc.

barskern commented 5 years ago

I actually wanted this aswell in a recent project. Going to try to make a PR :)