Replies: 5 comments 6 replies
-
Seems like a job for a Makefile: xyz.html: xyz.md
ifneq (,$(wildcard xyz.css))
COND_OPTS := --css=xyz.css
endif
ifneq (,$(wildcard xyz.yaml))
COND_OPTS := $(COND_OPTS) -dxyz.yaml
endif
pandoc $(COND_OPTS) $< -so $@ or with a bit of metaness: ifeq ($(BASE),)
$(error No BASE variable specified)
endif
$(BASE).html: $(BASE).md
ifneq (,$(wildcard $(BASE).css))
COND_OPTS := --css=$(BASE).css
endif
ifneq (,$(wildcard $(BASE).yaml))
COND_OPTS := $(COND_OPTS) -d$(BASE).yaml
endif
pandoc $(COND_OPTS) $< -so $@
$(BASE).ltx: $(BASE).md
ifneq (,$(wildcard $(BASE).sty))
COND_OPTS := -V header-includes='\usepackage{$(BASE)}'
endif
pandoc -w latex $(COND_OPTS) $< -so $@ Invoke with You get the idea. The LaTeX bit is untested but should work. The usual caveats about leading spaces in displayed code vs. tabs in a real Makefile apply! |
Beta Was this translation helpful? Give feedback.
-
thx, bpj. this may work, but seems quite elegant. it would be much nicer if pandoc itself were to populate a few variables that one could then use in a default templates.
I guess what I really have then is a suggestion for a new feature. if J does not read this forum, maybe I need to post it in the other one. |
Beta Was this translation helpful? Give feedback.
-
If you define "basename" in your metadata header/file, then you can use in your template:
\IfFileExists{$basename$.sty}{\usepackage{$basename$}}{}
(Variables are written between two dollars in template files.)
|
Beta Was this translation helpful? Give feedback.
-
Keep in mind that pandoc allows multiple input files, in which case I tend to agree with @bpj in that I believe that this is out of scope for pandoc and should be solved via alternative means. |
Beta Was this translation helpful? Give feedback.
-
thank you, everyone. I guess a preprocessor that inserts into yaml the file could do the job relatively elegantly. I will do this. still, I would think that adding |
Beta Was this translation helpful? Give feedback.
-
I am staring at the
default.latex
andpreamble.html
files.Ideally, I would like to have any generated file for
xyz.md
in a pandoc conversion to html include thexyz.css
andxyz.js
files IF THEY EXIST.Similarly, I would like to have the generated file
xyz.md
in a pandoc conversion to latex include thexyz.sty
file IF IT EXISTS.this could be accomplished by slurping or referencing. alas, to do even referencing, I need to have a variable that holds the basename of the file that is being processed, here
xyz
.easy?
Beta Was this translation helpful? Give feedback.
All reactions