msprev / panzer

pandoc + styles
BSD 3-Clause "New" or "Revised" License
160 stars 13 forks source link

Support 'includes' directory similar to 'template' directory #29

Open bpj opened 7 years ago

bpj commented 7 years ago

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:

msprev commented 7 years ago

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.

bpj commented 7 years ago

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...

msprev commented 7 years ago

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

bpj commented 7 years ago

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

msprev commented 7 years ago

Any pull requests are welcome!