aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App
AgeCommit message (Collapse)AuthorFilesLines
2020-06-29Handle errors in yamlToMetaNikolay Yakimov1-8/+8
2020-06-29Unify defaults and markdown metadata parsersNikolay Yakimov1-14/+15
2020-04-17Revert 0e48a02 and dependency on base-noprelude...John MacFarlane1-2/+2
which hasn't been updated for ghc 8.10. See discussion at #6187.
2020-04-13Add an option to disable certificate validation (#6156)Cédric Couralet2-0/+10
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 Krewinkel4-10/+2
* 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 Krewinkel4-5/+5
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-08Factor out a findM function (#6125)Joseph C. Sible1-10/+2
This adds a new function to the API: Text.Pandoc.Shared.findM.
2020-02-07Apply linter suggestions. Add fix_spacing to lint target in Makefile.John MacFarlane1-2/+2
2020-02-07Resolve HLint warningsAlbert Krewinkel1-5/+4
All warnings are either fixed or, if more appropriate, HLint is configured to ignore them. HLint suggestions remain. * Ignore "Use camelCase" warnings in Lua and legacy code * Fix or ignore remaining HLint warnings * Remove redundant brackets * Remove redundant `return`s * Remove redundant as-pattern * Fuse mapM_/map * Use `.` to shorten code * Remove redundant `fmap` * Remove unused LANGUAGE pragmas * Hoist `not` in Text.Pandoc.App * Use fewer imports for `Text.DocTemplates` * Remove redundant `do`s * Remove redundant `$`s * Jira reader: remove unnecessary parentheses
2020-02-07More in-depth refactoring and cleanup (#6123)Joseph C. Sible1-8/+7
* Avoid duplicating the dash case * Pull common functions out of case branches * Make sure list lengths are only calculated once * Use unless * Simplify parseURIReference' and avoid an unnecessary call to length * Use <$> instead of reimplementing it * Use swap instead of reimplementing it * Remove eta-expansion that's been unnecessary since 90f5dd8 * Use tailDef instead of reimplementing it * Use second instead of fmap, per @tarleb
2020-02-06Use traverse instead of reimplementing it (#6124)Joseph C. Sible1-5/+2
2020-01-31Support 'bibliography' and 'csl' fields in defaults file.John MacFarlane2-24/+42
Move addMeta from T.P.App.CommandLineOptions to T.P.App.Opt. (not an api change because modules not exported)
2020-01-31Add Text.Pandoc.Readers.CSV (readCSV).John MacFarlane1-0/+1
This adds csv as an input format. The CSV table is converted into a pandoc simple table. Closes #6100.
2020-01-08Change setVariable to use Text instead of String.John MacFarlane2-21/+20
This avoids some unnecessary unpacking. (This is only an internal module so it's not an API change.)
2019-12-26Use HTTPS in copyright message (#6010)Felix Yan1-1/+1
Since the website now redirect to https automatically, it would be nice to just use https in the help text.
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-12-11Improved template API and fixed a bug. Closes #5979.John MacFarlane1-29/+7
* Text.Pandoc.Templates [API change] + Add Monad wrappers `WithDefaultPartials` and `WithPartials`. Wrapping these around an instance of `PandocMonad` gives us different instances of `TemplateMonad`, with different search behavior in retrieving partials. To compile a template and limit partial search to pandoc's data files, use `runWithDefaultPartials (compileTemplate ...)`. To compile a template and allow partials to be found locally (either on the file system or via HTTP, in the event that the main template has an absolute URL), ue `runWithPartials (compileTemplate ...)`. + Export `getTemplate`, which seeks a template locally, or via HTTP if the template has an absolute URL, falling back to the data files if not found. + Export `compileDefaultTemplate` -- does `getDefaultTemplate` and compiles the result, raising an error on failure. * Text.Pandoc.Class [API change] + Remove `TemplateMonad` instances for `PandocIO` and `PandocPure`. These were too limiting and caused a bug whereby a local partial could be used even when the default template was requested. We now rely on instances provided in the Templates module. Text.Pandoc.App.OutputSettings + Simplify template retrieval code.
2019-12-04Fix regression with behavior of --variable.John MacFarlane1-2/+8
Previously -Vfoo=1 -Vfoo=2 would produce a list value for foo; with 2.8 it produced just '2'. This commit restores the earlier beahvior. Closes #5962.
2019-11-26Add pdf to list of output formats (`--list-output-formats`).John MacFarlane1-1/+2
Closes #5938.
2019-11-17Reverted the behavior change with `--title-prefix`.John MacFarlane2-2/+4
It now implies `--standalone` again, as before.
2019-11-17Ensure that options imply `--standalone` even in defaults file.John MacFarlane1-14/+15
Certain options (`--self-contained`, `--include-in-header`, etc.) imply `--standalone`. We now handle this after option parsing so that it affects options specified in defaults files too. Behavior change: `--title-prefix` no longer implies `--standalone`.
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 MacFarlane3-9/+15
`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-14Allow combining `-Vheader-includes` and `--include-in-header`.John MacFarlane1-15/+21
Closes #5904.
2019-11-14Fix regression preventing header-includes from being set using -V.John MacFarlane1-1/+2
See #5904.
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].despresc4-107/+111
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-07Fix list fields in Opt so they aren't reversed.John MacFarlane2-28/+24
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.
2019-11-07Change merge behavior for metadata.John MacFarlane1-1/+1
Previously, if a document contained two YAML metadata blocks that set the same field, the conflict would be resolved in favor of the first. Now it is resolved in favor of the second (due to a change in pandoc-types). This makes the behavior more uniform with other things in pandoc (such as reference links and `--metadata-file`).
2019-11-06Add and apply filters in order (not reversed).John MacFarlane1-4/+2
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.
2019-11-06Allow singular input-file in defaults file.John MacFarlane1-0/+4
Closes #5877.
2019-11-03Allow pdf output to stdout.John MacFarlane1-12/+15
PDF output will not be output to the terminal, but can be sent to stdout using either `-o -` or a pipe. The intermediate format will be determined based on the setting of `--pdf-engine`. Closes #5751.
2019-11-02Move extension-adding to applyDefaultsJohn MacFarlane1-6/+5
2019-11-01Revert "ALlow multiple comma-separated files for `--defaults`."John MacFarlane1-7/+6
This reverts commit e96f3fd813b3f8b73c3457ff6e9177e2a4a74164.
2019-11-01ALlow multiple comma-separated files for `--defaults`.John MacFarlane1-6/+7
2019-11-01Factor out applyDefaults in T.P.A.CommandLineOptions.John MacFarlane1-20/+24
2019-11-01`--defaults` improvements.John MacFarlane2-89/+114
- 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-11Remove redundant import.John MacFarlane1-1/+0
2019-10-10Improve parsing of --defaults.John MacFarlane3-31/+254
- 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-10Add -d as synonym for --defaults.John MacFarlane1-1/+1
2019-10-10Reorder options in `--help`.John MacFarlane1-58/+58
2019-10-10`--metadata-file`: when multiple files specified, second takes precedence...John MacFarlane1-1/+1
on conflicting fields. This changes earlier behavior (but not in a release), where first took precedence. Note that this may seem inconsistent with the behavior of multiple YAML blocks within a document, where the first takes precedence. Still, it is convenient to be able to override defaults with options later on the command line.
2019-10-10Remove unnecessary import.John MacFarlane1-1/+0
2019-10-09--defaults: add .yaml extension if absent, look in user data dir...John MacFarlane1-13/+30
under "defaults" subdirectory.
2019-10-09T.P.App.Opt: rename optReader, optWriter as optFrom, optTo.John MacFarlane3-8/+8
This will allow to: and from: in defaults.
2019-10-09Make sure that input-files works in --default files.John MacFarlane1-1/+1
2019-10-09Basic changes for MathJax 3.zorkow1-1/+1