panzer icon indicating copy to clipboard operation
panzer copied to clipboard

Support 'includes' directory similar to 'template' directory

Open bpj opened this issue 7 years ago • 5 comments

I have a directory ~/.pandoc/includes/ and often a directory ./includes/ containing reusable header includes files like fancy-headings.ltx. The irritating thing about this is that when using panzer I still have to supply these as command line options with a full path and without smartness in the lookup:

commandline:
  include-in-header:
    - '`/home/bpj/.pandoc/includes/fancy-headings.ltx`'

In short I wish I could say

headerincludes:
  # These load titlesec and does stuff with it
  - kill: plain-headings.ltx 
  - use:  fancy-headings.ltx
beforebodyincludes:
  - use:  foo.ltx
afterbodyincludes:
  - kill: bar.ltx

and have panzer look for the files similarly to how it looks for filters and templates,

# look for
1 ./fancy-headings.ltx
2 ./includes/fancy-headings.ltx
3 ./includes/fancy-headings/fancy-headings.ltx
4 ~/.panzer/includes/fancy-headings.ltx
5 ~/.panzer/includes/fancy-headings/fancy-headings.ltx

building an includes list for each of the three locations.

Notes:

  • I only ever use header includes this way, but it seems to make sense to support before/after body includes as well. If they are not included somebody will certainly find a need for them! :-)

  • I'm not enough of a Python programmer, my language of choice being Perl, to suggest any code for doing this, but hopefully the code for looking up filters, templates etc. can largely be reused.

bpj avatar Aug 07 '17 12:08 bpj

This is a good suggestion. I can see the reasoning behind it. The main issue is that it isn't trivial to implement (although it is certainly possible). The code can't be reused in the way you suggest (I'd do it differently if I were starting again...). I'll keep this issue open and put it on the todo list.

msprev avatar Aug 10 '17 09:08 msprev

Yeah, a lot of version 0.001 software would look different if we knew which features will actually be used or wanted in the future. Been there, done that. I guess one should always have one function or method for everything which can conceivably be reused, and make it as general as possible, but that slows down...

bpj avatar Aug 10 '17 18:08 bpj

Thanks, if I can (magically) free up some time I'll work on this.

msprev avatar Aug 11 '17 07:08 msprev

I do periodically have free time. Perhaps I'll be able to take this as a chance to hone my Python skills.

bpj avatar Aug 11 '17 10:08 bpj

Any pull requests are welcome!

msprev avatar Aug 11 '17 11:08 msprev