aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App
AgeCommit message (Collapse)AuthorFilesLines
2021-10-19FormatHeuristics: remove `.tei.xml` extension for TEI.John MacFarlane1-1/+0
As noted in #7630, this never worked, because `takeExtension` only returns `.xml`. So it won't be missed if we remove it. Closes #7630.
2021-10-06Don't prepend `file://` to `--syntax-definition` on Windows.John MacFarlane1-8/+2
This was a fix for a problem in skylighting, but this problem doesn't exist now that we've moved from HXT to xml-conduit. Cf. #6374.
2021-08-28Add `--sandbox` option.John MacFarlane3-1/+30
+ Add sandbox feature for readers. When this option is used, readers and writers only have access to input files (and other files specified directly on command line). This restriction is enforced in the type system. + Filters, PDF production, custom writers are unaffected. This feature only insulates the actual readers and writers, not the pipeline around them in Text.Pandoc.App. + Note that when `--sandboxed` is specified, readers won't have access to the resource path, nor will anything have access to the user data directory. + Add module Text.Pandoc.Class.Sandbox, defining `sandbox`. Exported via Text.Pandoc.Class. [API change] Closes #5045.
2021-08-24T.P.App.OutputSettings: Generalize some types...John MacFarlane1-6/+5
so we can run this with any instance of PandocMonad and MonadIO, not just PandocIO.
2021-08-08Allow `--slide-level=0`.John MacFarlane1-2/+2
When the slide level is set to 0, headings won't be used at all in splitting the document into slides. Horizontal rules must be used to separate slides. Closes #7476.
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-15Use foldl' instead of foldl everywhere.John MacFarlane1-2/+2
2021-03-13T.P.App.FormatHeuristics: shorten code, improve docs.Albert Krewinkel1-7/+13
2021-03-06Allow `--resource-path` to accumulate.John MacFarlane2-2/+4
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 MacFarlane2-53/+46
* Add `optCSL`, `optBibliography`, `optCitationAbbreviations` to `Opt` [API change]. * Move `addMeta` from T.P.App.Opt to T.P.App.CommandLineOptions.
2021-02-22Text.Pandoc.UTF8: change IO functions to return Text, not String.John MacFarlane2-20/+22
[API change] This affects `readFile`, `getContents`, `writeFileWith`, `writeFile`, `putStrWith`, `putStr`, `putStrLnWith`, `putStrLn`. `hPutStrWith`, `hPutStr`, `hPutStrLnWith`, `hPutStrLn`, `hGetContents`. This avoids the need to uselessly create a linked list of characters when emiting output.
2021-02-02Add parseOptionsFromArgs [API change, addition].John MacFarlane1-1/+6
Exported by Text.Pandoc.App.
2021-01-16Recognize more extensions as markdown by default.John MacFarlane1-0/+5
`mkdn`, `mkd`, `mdwn`, `mdown`, `Rmd`. Closes #7034.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel4-5/+5
2021-01-05Implement defaults file inheritance (#6924)David Martschenko2-33/+139
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-14Revise deprecation warning for --atx-headers.John MacFarlane1-1/+1
2020-11-14Markdown writer: default to using ATX headings.Aner Lucero2-2/+25
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-10-19More refinements to --version output.John MacFarlane1-3/+4
Add ipynb version. Put user data directory on same line as heading "User data directory" (dropping "default").
2020-10-19Modify --version output.John MacFarlane1-8/+8
Use space more efficiently and report the citeproc version along with skylighting, texmath, and pandoc-types.
2020-10-04Sort languages in `--list-highlight-languages` output (#6718)Albert Krewinkel1-1/+1
Languages appear to be sorted by their long name, which leads to unexpected results: e.g., the long name of *m4* is *GNU m4*, so it is listed between *gnuassembler* and *go*.
2020-09-21Add built-in citation support using new citeproc library.John MacFarlane3-0/+12
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-09-19Command line options: use normalizePath in more places.John MacFarlane1-14/+25
See #5127. It is now used everywhere a file argument can be used. Closes #5127.
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres1-4/+3
* Fix hlint suggestions, update hlint.yaml Most suggestions were redundant brackets. Some required LambdaCase. The .hlint.yaml file had a small typo, and didn't ignore camelCase suggestions in certain modules.
2020-08-06Options: Add `/tex-mml-chtml.js` to defaultMathJaxURL.John MacFarlane1-2/+1
Previously we added this in processing command line options, but not in processing defaults files, which was inconsistent. Cloess #6593.
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`.