aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-01-10JATS writer: fix citations (#7018)Albert Krewinkel1-14/+2
* JATS writer: keep code lines at 80 chars or below * JATS writer: fix citations
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-11-26Added some explicit imports.John MacFarlane1-3/+3
2020-11-16Only use filterIpynbOutput if input format is ipynb.John MacFarlane1-0/+1
Closes #6841.
2020-11-16When checking reader/writer name, check base name...John MacFarlane1-9/+11
now that we permit extensions on formats other than markdown.
2020-10-07Raise informative errors when YAML metadata parsing fails.John MacFarlane1-2/+3
Closes #6730. Previously the command would succeed, returning empty metadata, with no errors or warnings. API changes: - Remove now unused CouldNotParseYamlMetadata constructor for LogMessage (T.P.Logging). - Add 'Maybe FilePath' parameter to yamlToMeta in T.P.Readers.Markdown.
2020-09-21Add built-in citation support using new citeproc library.John MacFarlane1-11/+16
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-04-13Add an option to disable certificate validation (#6156)Cédric Couralet1-0/+2
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-19Text.Pandoc.App: set resource path at the beginning...John MacFarlane1-1/+2
...so it can affect things like include-in-header. See #5982.
2020-02-08Factor out a findM function (#6125)Joseph C. Sible1-8/+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-1/+1
2020-02-07Resolve HLint warningsAlbert Krewinkel1-1/+1
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-11/+10
* 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
2019-11-24Add unexported Text.Pandoc.Readers.Metadata.John MacFarlane1-1/+1
For YAML metadata parsing. A step in the direction of #5914. No API change.
2019-11-14Change optInputFiles to a `Maybe [FilePath]`.John MacFarlane1-6/+6
`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-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-23/+21
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-07Change merge behavior for metadata.John MacFarlane1-8/+4
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-2/+1
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-03Allow pdf output to stdout.John MacFarlane1-1/+2
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-10-10Improve parsing of --defaults.John MacFarlane1-8/+8
- 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-10`--metadata-file`: when multiple files specified, second takes precedence...John MacFarlane1-0/+4
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-09T.P.App.Opt: rename optReader, optWriter as optFrom, optTo.John MacFarlane1-1/+1
This will allow to: and from: in defaults.
2019-10-09T.P.App.Opt: Changed optMetadata to Meta, to allow structured values.John MacFarlane1-38/+16
[API change] The current behavior of the `--metadata` option stays the same.
2019-10-06Text.Pandoc.App.Opt: Remove optBaseHeaderLevel from Opt.John MacFarlane1-4/+1
We now just use optShiftHeadingLevelBy, to avoid redundancy.
2019-10-06Text.Pandoc.App.Opt: Change optShiftHeadingLevel to optShiftHeadingLevelBy...John MacFarlane1-1/+1
to match the option.
2019-09-29Raise error on unsupported extensions. Closes #4338.John MacFarlane1-10/+1
+ An error is now raised if you try to specify (enable or disable) an extension that does not affect the given format, e.g. `docx+pipe_tables`. + The `--list-extensions[=FORMAT]` option now lists only extensions that affect the given FORMAT. + Text.Pandoc.Error: Add constructors `PandocUnknownReaderError`, `PandocUnknownWriterError`, `PandocUnsupportedExtensionError`. [API change] + Text.Pandoc.Extensions now exports `getAllExtensions`, which returns the extensions that affect a given format (whether enabled by default or not). [API change] + Text.Pandoc.Extensions: change type of `parseFormatSpec` from `Either ParseError (String, Extensions -> Extensions)` to `Either ParseError (String, [Extension], [Extension])` [API change]. + Text.Pandoc.Readers: change type of `getReader` so it returns a value in the PandocMonad instance rather than an Either [API change]. Exceptions for unknown formats and unsupported extensions are now raised by this function and need not be handled by the calling function. + Text.Pandoc.Writers: change type of `getWriter` so it returns a value in the PandocMonad instance rather than an Either [API change]. Exceptions for unknown formats and unsupported extensions are now raised by this function and need not be handled by the calling function.
2019-09-27LogMessage: change UnknownExtension -> CouldNotDeduceFormatJohn MacFarlane1-1/+1
2019-09-10Add --shift-heading-level-by option.John MacFarlane1-0/+3
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-09-08Emit warning on `-f latex -o out.pdf` (#5736)Mauro Bieg1-0/+8
add UnusualConversion to LogMessage [API change]
2019-08-25Don't add a newline if there's already one.John MacFarlane1-4/+5
2019-08-24Change optMetadataFile type from Maybe to List (#5702)Owen McGrath1-2/+3
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-08-08Revert "Avoid a pointless Text -> String conversion on output."John MacFarlane1-14/+8
This reverts commit 87ce1ffbd97f6cb2785f9fbf05f68d3185f50675. This change caused a problem on Windows that we didn't have before; this needs looking into. https://ci.appveyor.com/project/jgm/pandoc/build/job/fxq96log042df8dk .\pandoc.exe -s --toc ..\MANUAL.txt -o MANUAL.html pandoc.exe: MANUAL.html: commitAndReleaseBuffer: invalid argument (invalid character) Command exited with code 1
2019-08-07Avoid a pointless Text -> String conversion on output.John MacFarlane1-8/+14
2019-07-20Removed an unnecessary liftIO.John MacFarlane1-2/+1
2019-07-20Moved istty check.John MacFarlane1-5/+5
2019-07-20Minor code clarity change.John MacFarlane1-8/+8
2019-07-14Logging: Added UnknownExtensions constructor to LogMessage.John MacFarlane1-35/+39
[API change] Issue this warning when we're falling back to markdown or html because we don't recognize the extension of the input or output files.
2019-07-14Change formatForFilePaths to return a Maybe.John MacFarlane1-1/+2
Internal change. This will make it easier to emit messages when we're guessing at a format.
2019-04-25Fix --self-contained so it works when output format has extensions.John MacFarlane1-4/+4
Previously if you used `--self-contained` with `html-smart` or `html+smart`, it wouldn't work.
2019-04-02Fix harmless error in file-scope code.John MacFarlane1-2/+2
Closes #5422.
2019-03-02Use XDG data directory for user data directory.John MacFarlane1-6/+12
Instead of `$HOME/.pandoc`, the default user data directory is now `$XDG_DATA_HOME/pandoc`, where `XDG_DATA_HOME` defaults to `$HOME/.local/share` but can be overridden by setting the environment variable. If this directory is missing, then `$HOME/.pandoc` is searched instead, for backwards compatibility. However, we recommend moving local pandoc data files from `$HOME/.pandoc` to `$HOME/.local/share/pandoc`. On Windows the default user data directory remains the same. Closes #3582.
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-28Markdown Reader: yamlToMeta respects extensions (#5276)Mauro Bieg1-4/+5
Add ReaderOptions parameter to yamlToMeta [API change]. fixes #5272
2019-02-28Shared: add filterIpynbOutput. [API change]John MacFarlane1-8/+21
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-12-31Simplify/fix reading of `--metadata` values on command line.John MacFarlane1-7/+8
Previously we used HsYAML's decodeStrict to recognize boolean values (treating everything else as a string). This caused problems relating to hvr/HsYAML#7. We now just check for the recognized boolean values `true|True|TRUE|false|False|FALSE`, and avoid using HsYAML. Closes #5177.
2018-11-29Improve error message for UTF-8 decoding errors.John MacFarlane1-6/+17
Give the filename and the byte offset. Closes #4765.
2018-11-07T.P.App: extract submodule T.P.App.FormatHeuristicsAlbert Krewinkel1-57/+1
Format guessing is used for input and output options and should be shared.