aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App/Opt.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-05-09Change reader types, allowing better tracking of source positions.John MacFarlane1-1/+1
Previously, when multiple file arguments were provided, pandoc simply concatenated them and passed the contents to the readers, which took a Text argument. As a result, the readers had no way of knowing which file was the source of any particular bit of text. This meant that we couldn't report accurate source positions on errors or include accurate source positions as attributes in the AST. More seriously, it meant that we couldn't resolve resource paths relative to the files containing them (see e.g. #5501, #6632, #6384, #3752). Add Text.Pandoc.Sources (exported module), with a `Sources` type and a `ToSources` class. A `Sources` wraps a list of `(SourcePos, Text)` pairs. [API change] A parsec `Stream` instance is provided for `Sources`. The module also exports versions of parsec's `satisfy` and other Char parsers that track source positions accurately from a `Sources` stream (or any instance of the new `UpdateSourcePos` class). Text.Pandoc.Parsing now exports these modified Char parsers instead of the ones parsec provides. Modified parsers to use a `Sources` as stream [API change]. The readers that previously took a `Text` argument have been modified to take any instance of `ToSources`. So, they may still be used with a `Text`, but they can also be used with a `Sources` object. In Text.Pandoc.Error, modified the constructor PandocParsecError to take a `Sources` rather than a `Text` as first argument, so parse error locations can be accurately reported. T.P.Error: showPos, do not print "-" as source name.
2021-03-20Text.Pandoc.Parsing: remove F type synonym.John MacFarlane1-1/+2
Muse and Org were defining their own F anyway, with their own state. We therefore move this definition to the Markdown reader.
2021-03-06Allow `--resource-path` to accumulate.John MacFarlane1-1/+2
Previously, if `--resource-path` were used multiple times, the last resource path would replace the others. With this change, each time `--resource-path` is used, it prepends the specified path components to the existing resource path. Similarly, when `resource-path` is specified in a defaults file, the paths provided will be prepended to the existing resource path. This change also allows one to avoid using the OS-specific path separator; instead, one can simply use `--resource-path` a number of times with single paths. This form of command will not have an OS-dependent behavior. This change facilitates the use of multiple, small defaults files: each can specify a directory containing its own resources without clobbering the resource paths set by the others. Closes #6152.
2021-03-05Allow `${.}` in defaults files paths...John MacFarlane1-2/+11
to refer to the directory where the default file is. This will make it possible to create moveable "packages" of resources in a directory. Closes #5871.
2021-03-05Implement environment variable interpolation in defaults files.John MacFarlane1-6/+111
This allows the syntax `${HOME}` to be used, in fields that expect file paths only. Any environment variable may be interpolated in this way. A warning will be raised for undefined variables. The special variable `USERDATA` is automatically set to the user data directory in force when the defaults file is parsed. (Note: it may be different from the eventual user data directory, if the defaults file or further command line options change that.) Closes #5982. Closes #5977. Closes #6108 (path not taken).
2021-03-05Add fields for CSL optinos to Opt.John MacFarlane1-48/+20
* Add `optCSL`, `optBibliography`, `optCitationAbbreviations` to `Opt` [API change]. * Move `addMeta` from T.P.App.Opt to T.P.App.CommandLineOptions.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2021-01-05Implement defaults file inheritance (#6924)David Martschenko1-7/+129
Allow defaults files to inherit options from other defaults files by specifying them with the following syntax: `defaults: [list of defaults files or single defaults file]`.
2020-11-15Remove redundant bracket in App.OptAlbert Krewinkel1-1/+1
2020-11-14Markdown writer: default to using ATX headings.Aner Lucero1-1/+7
Previously we used Setext (underlined) headings by default. The default is now ATX (`##` style). * Add the `--markdown-headings=atx|setext` option. * Deprecate `--atx-headers`. * Add constructor 'ATXHeadingInLHS` constructor to `LogMessage` [API change]. * Support `markdown-headings` in defaults files. * Document new options in MANUAL. Closes #6662.
2020-10-29Allow citation-abbreviations in defaults file.John MacFarlane1-0/+5
2020-09-21Add built-in citation support using new citeproc library.John MacFarlane1-0/+5
This deprecates the use of the external pandoc-citeproc filter; citation processing is now built in to pandoc. * Add dependency on citeproc library. * Add Text.Pandoc.Citeproc module (and some associated unexported modules under Text.Pandoc.Citeproc). Exports `processCitations`. [API change] * Add data files needed for Text.Pandoc.Citeproc: default.csl in the data directory, and a citeproc directory that is just used at compile-time. Note that we've added file-embed as a mandatory rather than a conditional depedency, because of the biblatex localization files. We might eventually want to use readDataFile for this, but it would take some code reorganization. * Text.Pandoc.Loging: Add `CiteprocWarning` to `LogMessage` and use it in `processCitations`. [API change] * Add tests from the pandoc-citeproc package as command tests (including some tests pandoc-citeproc did not pass). * Remove instructions for building pandoc-citeproc from CI and release binary build instructions. We will no longer distribute pandoc-citeproc. * Markdown reader: tweak abbreviation support. Don't insert a nonbreaking space after a potential abbreviation if it comes right before a note or citation. This messes up several things, including citeproc's moving of note citations. * Add `csljson` as and input and output format. This allows pandoc to convert between `csljson` and other bibliography formats, and to generate formatted versions of CSL JSON bibliographies. * Add module Text.Pandoc.Writers.CslJson, exporting `writeCslJson`. [API change] * Add module Text.Pandoc.Readers.CslJson, exporting `readCslJson`. [API change] * Added `bibtex`, `biblatex` as input formats. This allows pandoc to convert between BibLaTeX and BibTeX and other bibliography formats, and to generated formatted versions of BibTeX/BibLaTeX bibliographies. * Add module Text.Pandoc.Readers.BibTeX, exporting `readBibTeX` and `readBibLaTeX`. [API change] * Make "standalone" implicit if output format is a bibliography format. This is needed because pandoc readers for bibliography formats put the bibliographic information in the `references` field of metadata; and unless standalone is specified, metadata gets ignored. (TODO: This needs improvement. We should trigger standalone for the reader when the input format is bibliographic, and for the writer when the output format is markdown.) * Carry over `citationNoteNum` to `citationNoteNumber`. This was just ignored in pandoc-citeproc. * Text.Pandoc.Filter: Add `CiteprocFilter` constructor to Filter. [API change] This runs the processCitations transformation. We need to treat it like a filter so it can be placed in the sequence of filter runs (after some, before others). In FromYAML, this is parsed from `citeproc` or `{type: citeproc}`, so this special filter may be specified either way in a defaults file (or by `citeproc: true`, though this gives no control of positioning relative to other filters). TODO: we need to add something to the manual section on defaults files for this. * Add deprecation warning if `upandoc-citeproc` filter is used. * Add `--citeproc/-C` option to trigger citation processing. This behaves like a filter and will be positioned relative to filters as they appear on the command line. * Rewrote the manual on citatations, adding a dedicated Citations section which also includes some information formerly found in the pandoc-citeproc man page. * Look for CSL styles in the `csl` subdirectory of the pandoc user data directory. This changes the old pandoc-citeproc behavior, which looked in `~/.csl`. Users can simply symlink `~/.csl` to the `csl` subdirectory of their pandoc user data directory if they want the old behavior. * Add support for CSL bibliography entry formatting to LaTeX, HTML, Ms writers. Added CSL-related CSS to styles.html.
2020-06-29Handle errors in yamlToMetaNikolay Yakimov1-8/+8
2020-06-29Unify defaults and markdown metadata parsersNikolay Yakimov1-14/+15
2020-04-13Add an option to disable certificate validation (#6156)Cédric Couralet1-0/+5
This commit adds the option `--no-check-certificate`, which disables certificate checking when resources are fetched by HTTP. Co-authored-by: Cécile Chemin <cecile.chemin@insee.fr> Co-authored-by: Juliette Fourcot <juliette.fourcot@insee.fr>
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel1-2/+0
* Use implicit Prelude The previous behavior was introduced as a fix for #4464. It seems that this change alone did not fix the issue, and `stack ghci` and `cabal repl` only work with GHC 8.4.1 or newer, as no custom Prelude is loaded for these versions. Given this, it seems cleaner to revert to the implicit Prelude. * PandocMonad: remove outdated check for base version Only base versions 4.9 and later are supported, the check for `MIN_VERSION_base(4,8,0)` is therefore unnecessary. * Always use custom prelude Previously, the custom prelude was used only with older GHC versions, as a workaround for problems with ghci. The ghci problems are resolved by replacing package `base` with `base-noprelude`, allowing for consistent use of the custom prelude across all GHC versions.
2020-03-13Update copyright year (#6186)Albert Krewinkel1-1/+1
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-07Apply linter suggestions. Add fix_spacing to lint target in Makefile.John MacFarlane1-2/+2
2020-01-31Support 'bibliography' and 'csl' fields in defaults file.John MacFarlane1-1/+41
Move addMeta from T.P.App.CommandLineOptions to T.P.App.Opt. (not an api change because modules not exported)
2019-12-22Ensure that later default file values for `variable` replace earlier ones.John MacFarlane1-1/+3
The semigroup instance for doctemplates Context does a left-biased union on the underlying Map. That means that if you union `{a: 1}` and `{a: 2}`, you get `{a: 1}`. This commit causes pandoc to do the operation in the opposite order, so that later default files take precedence in the values they assign to keys. See #5988.
2019-11-17Reverted the behavior change with `--title-prefix`.John MacFarlane1-1/+2
It now implies `--standalone` again, as before.
2019-11-14Default files: Allow leaving input-files blank again.John MacFarlane1-3/+4
Leaving it blank yields a Nothing value (interpreted as stdin). Providing an empty list is intepreted as no input. This resolves one part of #5888.
2019-11-14Change optInputFiles to a `Maybe [FilePath]`.John MacFarlane1-6/+7
`Nothing` means: nothing specified. `Just []` means: an empty list specified (e.g. in defaults). Potentially these could lead to different behavior: see #5888.
2019-11-13Default files: combine with prior values when appropriate.John MacFarlane1-21/+45
Certain command-line arguments can be repeated: `--metadata-file`, `--css`, `--include-in-header`, `--include-before-body`, `--include-after-body`, `--variable`, `--metadata`, `--syntax-definition`. In these cases, values specified in default files should be added to the list rather than replacing values specified earlier on the command line (perhaps in other default files). So, for example, if one does pandoc --variable foo=3 --defaults d1 --defaults d2 and `d1` sets the variable `bar` and `d2` sets `baz`, all three variables will be set. Closes #5894.
2019-11-13Use `atx-headers` rather than `setext-headers` in defaults file...John MacFarlane1-2/+2
for consistency with CLI options. See #5894.
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-25/+23
PR #5884. + Use pandoc-types 1.20 and texmath 0.12. + Text is now used instead of String, with a few exceptions. + In the MediaBag module, some of the types using Strings were switched to use FilePath instead (not Text). + In the Parsing module, new parsers `manyChar`, `many1Char`, `manyTillChar`, `many1TillChar`, `many1Till`, `manyUntil`, `mantyUntilChar` have been added: these are like their unsuffixed counterparts but pack some or all of their output. + `glob` in Text.Pandoc.Class still takes String since it seems to be intended as an interface to Glob, which uses strings. It seems to be used only once in the package, in the EPUB writer, so that is not hard to change.
2019-11-06Allow singular input-file in defaults file.John MacFarlane1-0/+4
Closes #5877.
2019-11-01`--defaults` improvements.John MacFarlane1-88/+113
- ToYAML instance is now for `Opt -> Opt`, rather than `Opt`. - This allows us to handle `--defaults` without clobbering all the options that occur prior to `--defaults` on the command line. (Note, however, that options in `--defaults` can replace these options if the `--defaults` option is used after them, which may be a bit confusing given the name.) - `--defaults` may now be used multiple times on the command line, allowing users to break defaults into different chunks.
2019-10-29Changes to build with new doctemplates/doclayout.John MacFarlane1-1/+2
The new version of doctemplates adds many features to pandoc's templating system, while remaining backwards-compatible. New features include partials and filters. Using template filters, one can lay out data in enumerated lists and tables. Templates are now layout-sensitive: so, for example, if a text with soft line breaks is interpolated near the end of a line, the text will break and wrap naturally. This makes the templating system much more suitable for programatically generating markdown or other plain-text files from metadata.
2019-10-11Allow output-file to be null in --defaults.John MacFarlane1-1/+1
2019-10-10Improve parsing of --defaults.John MacFarlane1-11/+234
- Add FromYAML instances to Opt and to all subsidiary types. - Remove the use of HsYAML-aeson, which doesn't give good position information on errors. - Rename some fields in Opt to better match cli options or reflect what the ycontain [API change]: + optMetadataFile -> optMetadataFiles + optPDFEngineArgs -> optPDFEngineOpts + optWrapText -> optWrap - Add IpynbOutput enumerated type to Text.Pandoc.App.Opts. Use this instead fo a string for optIpynbOutput. - Add FromYAML instance for Filter in Text.Pandoc.Filters. With these changes parsing of defaults files should be complete and should give decent error messages. Now (unlike before) we get an error if an unknown field is used.
2019-10-09T.P.App.Opt: rename optReader, optWriter as optFrom, optTo.John MacFarlane1-4/+4
This will allow to: and from: in defaults.
2019-10-09Initial implementation of --defaults option.John MacFarlane1-1/+1
Need documentation.
2019-10-09T.P.App.Opt: Changed optMetadata to Meta, to allow structured values.John MacFarlane1-3/+4
[API change] The current behavior of the `--metadata` option stays the same.
2019-10-09Change optVariables from [(String, String)] to Context Text.John MacFarlane1-2/+4
In Text.Pandoc.App.Opt [API change].
2019-10-08Use th to derive json instance for LineEnding.John MacFarlane1-16/+4
2019-10-07Text.Pandoc.Options: change To/FromJSON instances for...John MacFarlane1-1/+3
HTMLMathMethod, CiteMethod, ObfuscationMethod, TrackChanges, WrapOption, TopLevelDivision, ReferenceLocation, HTMLSlideVariant. In each case we use lowercase (or hyphenated lowercase) for constructors to line up more closely with command-line option values. This is a breaking change for those who manually decode or encode JSON for these data types (e.g. for ReaderOptions or WriterOptions). See #5790.
2019-10-07Remove derive_json_via_th flag; always use TH.John MacFarlane1-14/+0
This cuts down on code duplication and reduces the chance for errors. See #4083.
2019-10-07Use typeMismatch.John MacFarlane1-1/+2
2019-10-06T.P.App.Opt: custom FromJSON instance for LineEnding.John MacFarlane1-8/+17
So either CRLF or crlf will work.
2019-10-06Opt: Change optHighlightStyle to a Maybe String instead of Maybe Style.John MacFarlane1-3/+2
Do the parsing/loading of themes later, after option parsing.
2019-10-06Text.Pandoc.App.Opt: Remove optBaseHeaderLevel from Opt.John MacFarlane1-2/+0
We now just use optShiftHeadingLevelBy, to avoid redundancy.
2019-10-06Text.Pandoc.App.Opt: Change optShiftHeadingLevel to optShiftHeadingLevelBy...John MacFarlane1-2/+2
to match the option.
2019-10-06Text.Pandoc.App.Opt: more convenient To/FromJSON instances.John MacFarlane1-5/+9
Make the field names like `strip-empty-paragraphs` rather than `optStripEmptyParagraphs`.
2019-09-10Add --shift-heading-level-by option.John MacFarlane1-0/+2
Deprecate --base-heading-level. The new option does everything the old one does, but also allows negative shifts. It also promotes the document metadata (if not null) to a level-1 heading with a +1 shift, and demotes an initial level-1 heading to document metadata with a -1 shift. This supports converting documents that use an initial level-1 heading for the document title. Closes #5615.
2019-08-24Change optMetadataFile type from Maybe to List (#5702)Owen McGrath1-2/+2
Changed optMetadataFile from `Maybe FilePath` to `[FilePath]`. This allows for multiple YAML metadata files to be added. The new default value has been changed from `Nothing` to `[]`. To account for this change in `Text.Pandoc.App`, `metaDataFromFile` now operates on two `mapM` calls (for `readFileLazy` and `yamlToMeta`) and a fold. Added a test (command/5700.md) which tests this functionality and updated MANUAL.txt, as per the contributing guidelines. With the current behavior, using `foldr1 (<>)`, values within files specified first will be used over those in later files. (If the reverse of this behavior would be preferred, it should be fixed by changing foldr1 to foldl1.)
2019-03-01Remove license boilerplate.John MacFarlane1-18/+0
The haddock module header contains essentially the same information, so the boilerplate is redundant and just one more thing to get out of sync.
2019-02-28Shared: add filterIpynbOutput. [API change]John MacFarlane1-0/+2
Add command line option `--ipynb-output=all|none|best`. Closes #5339.
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel1-2/+2
Quite a few modules were missing copyright notices. This commit adds copyright notices everywhere via haddock module headers. The old license boilerplate comment is redundant with this and has been removed. Update copyright years to 2019. Closes #4592.
2018-11-06T.P.App: extract Opt into separate moduleAlbert Krewinkel1-0/+221
The new Opt module has only a few dependencies. This is important for compile-times during development, as Template Haskell containing modules are be recompiled whenever a (transitive) dependency changes.