public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Create multiple outputs from single defaults file
@ 2021-10-06 11:13 Pranesh Prakash
       [not found] ` <ba39e16b-6b2d-4bba-8e15-9cbdc7f23b95n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Pranesh Prakash @ 2021-10-06 11:13 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1952 bytes --]

Dear all,
Since pandoc can now reference multiple defaults files within a single 
defaults file, I thought it would be possible to run a single command to 
generate multiple outputs.

```
$ cat defaults.yaml
---
# General options
defaults: 
-  defaults/cis_ihrl_69a.defaults.yaml
-  defaults/cis_ihrl_69a.html.defaults.yaml
-  defaults/cis_ihrl_69a.pdf.defaults.yaml
...
```

The files `cis_ihrl_69a.html.defaults.yaml` and 
`cis_ihrl_69a.pdf.defaults.yaml` have different `to:` lines.  I'd expect 
both an HTML output as well as a PDF output when I do:

```
$ pandoc -d defaults
```

However, that doesn't work as I expected.  Only the last writer (PDF, in 
this case), gets executed.

I'm not sure if my expectations are wrong, or if I'm doing something wrong.

I read through the manual, but this doesn't really seem to help answer my 
question:

> Specify a set of default option settings. *FILE* is a YAML file whose 
fields correspond to command-line option settings. All options for document 
conversion, including input and output files, can be set using a defaults 
file. The file will be searched for first in the working directory, and 
then in the defaults subdirectory of the user data directory (see --data-dir 
<https://pandoc.org/MANUAL.html#option--data-dir>). The .yaml extension may 
be omitted. See the section Default files 
<https://pandoc.org/MANUAL.html#default-files> for more information on the 
file format. Settings from the defaults file may be overridden or extended 
by subsequent options on the command line.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ba39e16b-6b2d-4bba-8e15-9cbdc7f23b95n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2669 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Create multiple outputs from single defaults file
       [not found] ` <ba39e16b-6b2d-4bba-8e15-9cbdc7f23b95n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-10-07  8:07   ` BPJ
       [not found]     ` <CADAJKhBMDq22wSp0Z==AgxRf7e-b4M+xZpddv7UjA8_Z2kW2zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: BPJ @ 2021-10-07  8:07 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 1970 bytes --]

Den ons 6 okt. 2021 13:14Pranesh Prakash <the.solipsist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>
> Dear all,
>
> Since pandoc can now reference multiple defaults files within a single
defaults file, I thought it would be possible to run a single command to
generate multiple outputs.

It isn't. Pandoc only ever produces a single output per run, unless
something has changed very recently.

>
>
> ```
>
> $ cat defaults.yaml
>
> ---
>
> # General options
>
> defaults:
>
> -  defaults/cis_ihrl_69a.defaults.yaml
>
> -  defaults/cis_ihrl_69a.html.defaults.yaml
>
> -  defaults/cis_ihrl_69a.pdf.defaults.yaml
>
> ...
>
> ```
>
>
> The files `cis_ihrl_69a.html.defaults.yaml` and
`cis_ihrl_69a.pdf.defaults.yaml` have different `to:` lines.  I'd expect
both an HTML output as well as a PDF output when I do:

You can invert the pattern by having a file, say `common.yaml`, which
contains the settings common to HTML and PDF output and include it from
`html.yaml` and `pdf.yaml`:

``````yaml
to: html
defaults:
  - common.yaml
``````

``````yaml
to: latex
pdf-engine: xelatex
defaults:
  - common.yaml
``````

Then you can use a Makefile to run pandoc once for each output with each
defaults file:
(watch out for spaces where there should be tabs!)

``````make
all: document.html document.pdf

.PHONY: all

document.html: document.md html.yaml common.yaml
pandoc -d html.yaml $< -o $@

document.pdf: document.md pdf.yaml common.yaml
pandoc -d pdf.yaml $< -o $@
``````

Still nicer than including a loooong command line in the Makefile!

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBMDq22wSp0Z%3D%3DAgxRf7e-b4M%2BxZpddv7UjA8_Z2kW2zw%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 3977 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Create multiple outputs from single defaults file
       [not found]     ` <CADAJKhBMDq22wSp0Z==AgxRf7e-b4M+xZpddv7UjA8_Z2kW2zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-10-07 11:37       ` Pranesh Prakash
       [not found]         ` <7a342f8f-63d7-45d0-9a5d-8e820cae1826n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Pranesh Prakash @ 2021-10-07 11:37 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1823 bytes --]

On Thursday, 7 October, 2021 at 1:37:34 pm UTC+5:30 BP wrote:

> It isn't. Pandoc only ever produces a single output per run, unless 
> something has changed very recently.
>

Thanks. That clarifies this.

Then you can use a Makefile to run pandoc once for each output with each 
> defaults file:
> (watch out for spaces where there should be tabs!)
>
> ``````make
> all: document.html document.pdf
>
> .PHONY: all
>
> document.html: document.md html.yaml common.yaml
> pandoc -d html.yaml $< -o $@
>
> document.pdf: document.md pdf.yaml common.yaml
> pandoc -d pdf.yaml $< -o $@
> ``````
>
> Still nicer than including a loooong command line in the Makefile!
>

Thanks for this. I've never used a Makefile before, and thought I'd try. I 
renamed `defaults/cis_ihrl_69a.defaults.yaml` to 
`defaults/cis_ihrl_69a.common.defaults.yaml` to make it clearer what it 
was. I included a reference to it in both the html and the pdf defaults 
files. I then created this as my Makefile:

```make
.PHONY: all html pdf

all : html pdf

html : defaults/cis_ihrl_69a.html.defaults.yaml source/cis_ihrl_69a.md
pandoc -d $<

pdf : defaults/cis_ihrl_69a.pdf.defaults.yaml source/cis_ihrl_69a.md
pandoc -d $<
```
That works great. However, I was hoping for something that would work 
easily on Windows as well, for collaborators.  I think I'll just have to 
provide them instructions to run two `pandoc -d` commands in sequence.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7a342f8f-63d7-45d0-9a5d-8e820cae1826n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3221 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Create multiple outputs from single defaults file
       [not found]         ` <7a342f8f-63d7-45d0-9a5d-8e820cae1826n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-10-07 12:28           ` Joost Kremers
  2021-10-07 15:12           ` BPJ
  1 sibling, 0 replies; 5+ messages in thread
From: Joost Kremers @ 2021-10-07 12:28 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw; +Cc: Pranesh Prakash


On Thu, Oct 07 2021, Pranesh Prakash wrote:
> That works great. However, I was hoping for something that would work 
> easily on Windows as well, for collaborators.  I think I'll just have to 
> provide them instructions to run two `pandoc -d` commands in sequence.

Well, you could always write a small batch file.

-- 
Joost Kremers
Life has its moments


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Create multiple outputs from single defaults file
       [not found]         ` <7a342f8f-63d7-45d0-9a5d-8e820cae1826n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2021-10-07 12:28           ` Joost Kremers
@ 2021-10-07 15:12           ` BPJ
  1 sibling, 0 replies; 5+ messages in thread
From: BPJ @ 2021-10-07 15:12 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 3101 bytes --]

Have you googled "make for windows"?

The greatest advantage of make is that if you list all source files,
default files, metadata files, filters etc. as prerequisites for the output
files make will run pandoc for each individual output file if and only if
any of the prerequisite files for that output file has been changed.
Moreover you don't really need to list every common prerequisite for every
output file. You can just write a line with all the output files on the lhs
and all the common prerequisites on the rhs.

Den tors 7 okt. 2021 13:38Pranesh Prakash <the.solipsist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> On Thursday, 7 October, 2021 at 1:37:34 pm UTC+5:30 BP wrote:
>
>> It isn't. Pandoc only ever produces a single output per run, unless
>> something has changed very recently.
>>
>
> Thanks. That clarifies this.
>
> Then you can use a Makefile to run pandoc once for each output with each
>> defaults file:
>> (watch out for spaces where there should be tabs!)
>>
>> ``````make
>> all: document.html document.pdf
>>
>> .PHONY: all
>>
>> document.html: document.md html.yaml common.yaml
>> pandoc -d html.yaml $< -o $@
>>
>> document.pdf: document.md pdf.yaml common.yaml
>> pandoc -d pdf.yaml $< -o $@
>> ``````
>>
>> Still nicer than including a loooong command line in the Makefile!
>>
>
> Thanks for this. I've never used a Makefile before, and thought I'd try. I
> renamed `defaults/cis_ihrl_69a.defaults.yaml` to
> `defaults/cis_ihrl_69a.common.defaults.yaml` to make it clearer what it
> was. I included a reference to it in both the html and the pdf defaults
> files. I then created this as my Makefile:
>
> ```make
> .PHONY: all html pdf
>
> all : html pdf
>
> html : defaults/cis_ihrl_69a.html.defaults.yaml source/cis_ihrl_69a.md
> pandoc -d $<
>
> pdf : defaults/cis_ihrl_69a.pdf.defaults.yaml source/cis_ihrl_69a.md
> pandoc -d $<
> ```
> That works great. However, I was hoping for something that would work
> easily on Windows as well, for collaborators.  I think I'll just have to
> provide them instructions to run two `pandoc -d` commands in sequence.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/7a342f8f-63d7-45d0-9a5d-8e820cae1826n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/7a342f8f-63d7-45d0-9a5d-8e820cae1826n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhAQJ718Oj0Z%3D23UvxBGgoQr%3DFwa_U3eh8PQWFpodagtRQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 5032 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-07 15:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 11:13 Create multiple outputs from single defaults file Pranesh Prakash
     [not found] ` <ba39e16b-6b2d-4bba-8e15-9cbdc7f23b95n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-10-07  8:07   ` BPJ
     [not found]     ` <CADAJKhBMDq22wSp0Z==AgxRf7e-b4M+xZpddv7UjA8_Z2kW2zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-10-07 11:37       ` Pranesh Prakash
     [not found]         ` <7a342f8f-63d7-45d0-9a5d-8e820cae1826n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-10-07 12:28           ` Joost Kremers
2021-10-07 15:12           ` BPJ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).