-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify template in YAML #1958
Comments
It is not possible in pandoc 'directly' as far as I know (I'm quite new to pandoc). But R markdown (which uses pandoc) seems to have what you want: http://rmarkdown.rstudio.com/html_document_format.html
|
Interesting, but that would add a completely unnecessary piece of software to a workflow that already has its quirks, and so probably isn't desirable. I have no need for the statistical features of R, and so would prefer to stick with using pandoc directly. |
Template variables aren't well suited for things like path names, because (recall) everything is interpreted as Markdown. However, YAML fields ending with So, you could do this: in your documents, use the YAML metadata field
Then, extract this using sed in your pandoc command line:
where |
@jgm, I had the same question as @davepwsmith. Thanks for providing a solution! I wanted to make the command more flexible by having it automatically detect whether there is a "template_" YAML field. The following command only adds a
I then integrated this into my Sublime Text build system (after fighting with escape characters for a while). For anyone interested, my ST3 build system is:
This will convert a Markdown file to PDF, using a custom template file if and only if one is specified using a "template_" YAML field. |
I agree with this idea, and it would be a huge quality of life improvement for me. As it stands, I end up having to create a Makefile for individual documents or copy/paste the template path (when I only ever use a handful of templates). If I could specify the template in YAML (like I can bibs and CSLs, both of which have the same path issue), it would make many things I do (e.g., academic papers, recommendation letters, envelopes, instructions, course materials) much easier. I appreciate the workaround, and I'll try to figure out an equivalent to that ST3 build in Atom, but it would still be nice to see this built in normally. |
OK, I'll reopen this for further consideration. But since the source document might be used to generate content in different formats, at the very least this would need to be parameterized on the output format as it is in RMarkdown. See also #2139. |
Would it be an option to make this decision depend on whether the given template has an extension? So ---
template: my-letter.latex
--- would look for ---
template: my-letter
--- would look for a template with a file extension matching the output format? (I'm commenting on this because I found this issue looking for exactly this functionlatily (so this comment is a |
Closing in favour of #4627. |
Stole this solution from jgm/pandoc#1958 (comment). This commit introduces a __get_template function. It returns `--template=<template>` where <template> is extracted from the SRCFILE when present. Else it return `--standalone` ie. pandoc uses the default template.
I can't seem to specify the template in the YAML metadata, as I can for example with the bibliography and CSL style. This would be very useful, as I could then basically customize my pandoc command for each file, without having to remember which arguments to use for specific projects. Am I doing something wrong (template: paper) or is this simply not possible?
The text was updated successfully, but these errors were encountered: