aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Class.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-08-28Add `--sandbox` option.John MacFarlane1-0/+2
+ 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.
2020-03-22Text.Pandoc.Class: extract submodules PandocIO, PandocPureAlbert Krewinkel1-393/+10
2020-03-21Class: fix missing import when data files are not embeddedAlbert Krewinkel1-0/+3
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel1-1/+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-14Subdivide Text.Pandoc.Class into small modules (#6106)Albert Krewinkel1-695/+37
* Extract CommonState into submodule * Extract PandocMonad into submodule * PandocMonad: ensure all functions have Haddock documentation
2020-02-07Resolve HLint warningsAlbert Krewinkel1-1/+0
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-10/+9
* 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-12-11Improved template API and fixed a bug. Closes #5979.John MacFarlane1-11/+0
* 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-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-66/+68
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-10-03Minor ghc 8.8 fixups.John MacFarlane1-2/+2
2019-08-25Use new doctemplates, doclayout.John MacFarlane1-10/+6
+ Remove Text.Pandoc.Pretty; use doclayout instead. [API change] + Text.Pandoc.Writers.Shared: remove metaToJSON, metaToJSON' [API change]. + Text.Pandoc.Writers.Shared: modify `addVariablesToContext`, `defField`, `setField`, `getField`, `resetField` to work with Context rather than JSON values. [API change] + Text.Pandoc.Writers.Shared: export new function `endsWithPlain` [API change]. + Use new templates and doclayout in writers. + Use Doc-based templates in all writers. + Adjust three tests for minor template rendering differences. + Added indentation to body in docbook4, docbook5 templates. The main impact of this change is better reflowing of content interpolated into templates. Previously, interpolated variables were rendered independently and intepolated as strings, which could lead to overly long lines. Now the templates interpolated as Doc values which may include breaking spaces, and reflowing occurs after template interpolation rather than before.
2019-07-28Use doctemplates 0.3, change type of writerTemplate.John MacFarlane1-0/+13
* Require recent doctemplates. It is more flexible and supports partials. * Changed type of writerTemplate to Maybe Template instead of Maybe String. * Remove code from the LaTeX, Docbook, and JATS writers that looked in the template for strings to determine whether it is a book or an article, or whether csquotes is used. This was always kludgy and unreliable. To use csquotes for LaTeX, set `csquotes` in your variables or metadata. It is no longer sufficient to put `\usepackage{csquotes}` in your template or header includes. To specify a book style, use the `documentclass` variable or `--top-level-division`. * Change template code to use new API for doctemplates.
2019-05-28Fix handling of `file:` URL scheme in `downloadOrRead` (#5522)Mauro Bieg1-2/+2
Move up the pattern match to be reachable, closes #5517. Previously `file:/` URLs were handled wrongly and pandoc attempted to make HTTP requests, which failed.
2019-04-05PowerPoint writer: expand builtin reference doc to model all layoutsJesse Rosenthal1-0/+4
The previous built-in reference doc had only title and content layouts. Add in a section-header slide and a two-content slide, so users can more easily modify it to build their own templates. Golden files needed to be regenerated. Checked on MS PowerPoint 2013.
2019-03-27Drop support for ghc < 8.John MacFarlane1-8/+0
2019-03-22fetchItem: don't treat UNC paths as protocol-relative URLs.John MacFarlane1-1/+2
These are paths beginning `//?/UNC/...`. Closes #5127.
2019-03-01Remove license boilerplate.John MacFarlane1-20/+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.
2018-11-01Remove unnecessary hiding in Class.hsAlexander Krotov1-1/+0
2018-10-09Docx writer: added framework for custom properties.John MacFarlane1-0/+1
So far, we don't actually write any custom properties, but we have the infrastructure to add this. See #3034.
2018-07-02Spellcheck commentsAlexander Krotov1-2/+2
2018-06-28Remove network-uri flag and use 'Network.Socket'.John MacFarlane1-1/+1
This removes a compiler warning. There is no need for the old network-uri flag, since network 2.6 was released in 2014.
2018-05-08Use uriPathToPath with file: URIs.John MacFarlane1-1/+2
Closes #4613. Needs testing on Windows.
2018-05-04catch IO errors when writing media files, closes #4559 (#4619)Francesco Occhipinti1-1/+9
If we do not catch these errors, any malformed entry in a media bag could cause the loss of a whole document output. An example of malformed entry is an entry with an empty file path.
2018-04-19Text.Pandoc.Class.writeMedia: unescape URI-escaping in file path.John MacFarlane1-1/+1
This avoids writing things like `file%20one.png` to the file system.
2018-03-18Removed old-locale flag and Text.Pandoc.Compat.Time.John MacFarlane1-2/+2
This is no longer necessary since we no longer support ghc 7.8.
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane1-0/+2
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-03-16Monoid/Semiground cleanup relying on custom Prelude.John MacFarlane1-4/+0
2018-03-16Class: Semigroup instance for FileTree with base >= 4.9.John MacFarlane1-0/+4
2018-02-18Powerpoint writer: Move notes slides into data tree.Jesse Rosenthal1-0/+8
2018-01-19hlint code improvements.John MacFarlane1-3/+3
2017-12-28Class: make FileTree opaque.John MacFarlane1-1/+1
This forces uses to interact with it using `insertInFileTree` and `getFileInfo`, which normalize file names.
2017-12-28Powerpoint writer tests: use IO.John MacFarlane1-2/+2
Otherwise we can't find the data files when compiled with -embed_data_files.
2017-12-28Moved makeCanoncial definition out of ifdef!John MacFarlane1-9/+11
Also added slide2 to the default pptx, and reordered the data files in pandoc.cabal.
2017-12-28Class: use makeCanonical for normalization in FileTree and data files.John MacFarlane1-8/+11
2017-12-28Text.Pandoc.Class: add insertInFileTree (API change).John MacFarlane1-7/+13
This gives a pure way to insert an ersatz file into a FileTree. In addition, we normalize paths both on insertion and on lookup, so that "foo" and "./foo" will be judged equivalent.
2017-12-13Removed whitespace at ends of line.John MacFarlane1-3/+3
2017-12-11Add necessary powerpoint functions to Class.Jesse Rosenthal1-0/+64
2017-10-29Export all of Text.Pandoc.Class from Text.Pandoc.John MacFarlane1-1/+0
2017-10-29Source code reformatting.John MacFarlane1-0/+1
2017-10-27hlint suggestions.John MacFarlane1-1/+0
2017-10-27hlint suggestions.John MacFarlane1-5/+4
2017-10-26Comment reformat.John MacFarlane1-6/+4
2017-10-24Added some haddock docs for Text.Pandoc.Class functions.John MacFarlane1-3/+22
2017-10-23Back to using [WARNING] and [INFO] to mark messages.John MacFarlane1-4/+2
2017-10-23More pleasing presentation of warnings and info messages.John MacFarlane1-4/+5
!! warning -- info
2017-10-15Remove openURL from Shared (API change).John MacFarlane1-7/+44
Now all the guts of openURL have been put into openURL from Class. openURL is now sensitive to stRequestHeaders in CommonState and will add these custom headers when making a request. It no longer looks at the USER_AGENT environment variable, since you can now set the `User-Agent` header directly.
2017-10-15Class: add stRequestHeaders to CommonState, and setRequestHeader.John MacFarlane1-0/+13
2017-09-30Text.Pandoc.Class - add getVerbosity.John MacFarlane1-0/+5
2017-09-30Removed writerSourceURL, add source URL to common state.John MacFarlane1-17/+37
Removed `writerSourceURL` from `WriterOptions` (API change). Added `stSourceURL` to `CommonState`. It is set automatically by `setInputFiles`. Text.Pandoc.Class now exports `setInputFiles`, `setOutputFile`. The type of `getInputFiles` has changed; it now returns `[FilePath]` instead of `Maybe [FilePath]`. Functions in Class that formerly took the source URL as a parameter now have one fewer parameter (`fetchItem`, `downloadOrRead`, `setMediaResource`, `fillMediaBag`). Removed `WriterOptions` parameter from `makeSelfContained` in `SelfContained`.
2017-09-30Text.Pandoc.Lua: add mediabag submoduleAlbert Krewinkel1-9/+19