Skip to content
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

Allow list arguments in default files to accumulate #5881

Closed
jgm opened this issue Nov 6, 2019 · 4 comments
Closed

Allow list arguments in default files to accumulate #5881

jgm opened this issue Nov 6, 2019 · 4 comments

Comments

@jgm
Copy link
Owner

jgm commented Nov 6, 2019

For example, if defaults1.yaml is

include-in-header: A.txt

and defaults2.yaml is

include-in-header:
- B.txt
- C.txt

and the command line is

pandoc --include-in-header D.txt --defaults defaults1.yaml --defaults defaults2.yaml

then we should get four files included, in the order: D.txt, A.txt, B.txt, C.txt.

This affects many of the arguments in defaults files. Note that some of these are currently accumulated in reverse in option processing (when multiple options are allowed), and we may want to regularize this a bit.

We also need some tests for this sort of thing.

@jgm jgm added this to the 2.8 milestone Nov 6, 2019
jgm added a commit that referenced this issue Nov 6, 2019
This changes `applyFilters` from Text.Pandoc.Filter so
that it does a left fold rather than a right fold, applying
the filters in the order listed. [behavior change]

The command-line arguments are accumulated in order instead
of reverse order.

A first step twoards #5881.
@jgm
Copy link
Owner Author

jgm commented Nov 7, 2019

This may also help with #3139

@dhimmel
Copy link

dhimmel commented Nov 7, 2019

What is the difference between --defaults and --metadata-file?

Update, I see the documentation at:

pandoc/MANUAL.txt

Lines 1421 to 1591 in 9c7f75a

# Default files
The `--defaults` option may be used to specify a package
of options. Here is a sample defaults file demonstrating all of
the fields that may be used:
``` yaml
from: markdown+emoji
# reader: may be used instead of from:
to: html5
# writer: may be used instead of to:
# leave blank for output to stdout:
output-file:
# leave blank for input from stdin:
input-files:
- preface.md
- content.md
# or you may use input-file: with a single value
template: letter
standalone: true
self-contained: false
# note that structured variables may be specified:
variables:
documentclass: book
classoption:
- twosides
- draft
# metadata values specified here are parsed as literal
# string text, not markdown:
metadata:
author:
- Sam Smith
- Julie Liu
metadata-files:
- boilerplate.yaml
# or you may use metadata-file: with a single value
# Note that these take files, not their contents:
include-before-body: []
include-after-body: []
include-in-header: []
resource-path: ["."]
# filters will be assumed to be lua filters if they have
# the .lua extension, and json filters otherwise. But
# the filter type can also be specified explicitly, as shown:
filters:
- pandoc-citeproc
- wordcount.lua
- type: json
path: foo.lua
file-scope: false
data-dir:
# ERROR, WARNING, or INFO
verbosity: INFO
log-file: log.json
# citeproc, natbib, or biblatex
cite-method: citeproc
# part, chapter, section, or default:
top-level-division: chapter
abbreviations:
pdf-engine: pdflatex
pdf-engine-opts:
- "-shell-escape"
# you may also use pdf-engine-opt: with a single option
# pdf-engine-opt: "-shell-escape"
# auto, preserve, or none
wrap: auto
columns: 78
dpi: 72
extract-media: mediadir
table-of-contents: true
toc-depth: 2
number-sections: false
# a list of offsets at each heading level
number-offset: [0,0,0,0,0,0]
# toc: may also be used instead of table-of-contents:
shift-heading-level-by: 1
section-divs: true
identifier-prefix: foo
title-prefix: ""
strip-empty-paragraphs: true
# lf, crlf, or native
eol: lf
strip-comments: false
indented-code-classes: []
ascii: true
default-image-extension: ".jpg"
# either a style name of a style definition file:
highlight-style: pygments
syntax-definitions:
- c.xml
# or you may use syntax-definition: with a single value
listings: false
reference-doc: myref.docx
# method is plain, webtex, gladtex, mathml, mathjax, katex
# you may specify a url with webtex, mathjax, katex
html-math-method:
method: mathjax
url: "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
# none, references, or javascript
email-obfuscation: javascript
tab-stop: 8
preserve-tabs: true
incremental: false
slide-level: 2
epub-subdirectory: EPUB
epub-metadata: meta.xml
epub-fonts:
- foobar.otf
epub-chapter-level: 1
epub-cover-image: cover.jpg
reference-links: true
# block, section, or document
reference-location: block
setext-headers: true
# accept, reject, or all
track-changes: accept
html-q-tags: false
css:
- site.css
# none, all, or best
ipynb-output: best
# A list of two-element lists
request-headers:
- ["User-Agent", "Mozilla/5.0"]
fail-if-warnings: false
dump-args: false
ignore-args: false
trace: false
```
Fields that are omitted will just have their regular
default values. So a defaults file can be as simple as
one line:
``` yaml
verbosity: INFO
```
Default files can be placed in the `defaults` subdirectory of
the user data directory and used from any directory. For
example, one could create a file specifying defaults for writing
letters, save it as `letter.yaml` in the `defaults` subdirectory
of the user data directory, and then invoke these defaults
from any directory using `pandoc --defaults letter`
or `pandoc -dletter`.

jgm added a commit that referenced this issue Nov 7, 2019
Previously optIncludeInHeader, etc. were in reverse order.
This has been changed to promote #5881.

Note also that the `sourcefile` variable used to be sometimes
a string, sometimes a list (when there was more than one).
Now it is always a list.
@brainchild0
Copy link

In the past when I have dealt with problems analogous to this one I have found that trying to apply a single a rule to all fields of a common basic type (e.g. lists) is generally prone to lead to confusing boundary conditions. Some list fields might be suitable handling through a list append, as you have shown, some by pre-pending, some by full replacement, and some by a case-by-case basis depending on values of other fields. It is a complex subject that is tempting to try to treat generically, though doing so is not always viable.

@jgm
Copy link
Owner Author

jgm commented Nov 14, 2019

Closed by ec043e0

@jgm jgm closed this as completed Nov 14, 2019
jgm added a commit that referenced this issue Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants