aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App/OutputSettings.hs
AgeCommit message (Collapse)Author
2025-09-02Refactor highlighting options [API Change]Albert Krewinkel
A new command line option `--syntax-highlighting` is provided; it takes the values `none`, `default`, `idiomatic`, a style name, or a path to a theme file. It replaces the `--no-highlighting`, `--highlighting-style`, and `--listings` options. The `writerListings` and `writerHighlightStyle` fields of the `WriterOptions` type are replaced with `writerHighlightStyle`. Closes: #10525
2025-03-29Text.Pandoc.App: set `pdf-engine` variable.John MacFarlane
If `--pdf-engine` is specified or if a PDF is being produced, we set the `pdf-engine` variable. This allows writers and templates to behave differently depending on the PDF engine.
2025-03-05Disable citations extension in writers if `--citeproc` is used.John MacFarlane
Otherwise we get undesirable results, as the format's native citation mechanism is used instead of (or in addition to) the citeproc-generated citations. Closes #10662.
2024-12-19Change `--template` to allow use of extensionless templates.John MacFarlane
The intent is to allow bash process substitution: e.g., `--template <(echo "foo")`. Previously pandoc *always* added an extension based on the output format, which caused problems with the absolute filenames used by bash process substitution (e.g. `/dev/fd/11`). Now, if the template has no extension, pandoc will first try to find it without the extension, and then add the extension if it can't be found. So, in general, extensionless templates can now be used. But this has been implemented in a way that should not cause problems for existing uses, unless you are using a template `NAME.FORMAT` but happen to have an extensionless file `NAME` in the template search path. Closes #5270.
2024-12-14Use catMaybes instead of building with maybe and (:) one element at a timeJoseph C. Sible
2024-12-07Stylistic tweak.John MacFarlane
2024-12-07T.P.App.OutputSettings: add `sandbox'` function.John MacFarlane
This computes the sandboxed files from Opt and avoids some code repetition in T.P.App and T.P.App.OutputSettings.
2024-09-22Add support for list of figures (lof) and list of tables (lot) (#10029)Akash Patel
Two new command-line options are added: `--lof[=true|false]`, `--list-of-figures[=true|false]` `--lot[=true|false]`, `--list-of-tables[=true|false]` Only docx, latex, and context are supported at this point. Setting the `lof` and `lot` variables will also work for the formats that are currently supported. [API changes] + Lua: `list_of_figures` and `list_of_tables` can now be used in writer options. + Text.Pandoc.Options: add `writerListOfFigures` and `writerListOfTables` fields to `WriterOptions`. + Text.Pandoc.App.Opt: add `optListOfFigures` and `optListOfTables` to `Opt`. Closes #8245. Co-authored-by: John MacFarlane <[email protected]>
2024-09-08Initialize some missing fields in pandoc-server.John MacFarlane
writerEpubTitlePage, writerChunkTemplate, writerListTables.
2024-09-08Add options to change table/figure caption positions.John MacFarlane
+ Add command line options `--table-caption-position` and `--figure-caption-position`. These allow the user to specify whether to put captions above or below tables and figures, respectively. The following output formats are supported: HTML (and related such as EPUB), LaTeX (and Beamer), Docx, ODT/OpenDocument, Typst. + Text.Pandoc.Options: add `CaptionPosition` and new `WriterOptions` fields `writerFigureCaptionPosition` and `writerTableCaptionPosition` [API change]. + Text.Pandoc.Opt: add `Opt` fields `optFigureCaptionPosition` and `optTableCaptionPosition` [API change]. + Docx writer: make table/figure rendering sensitive to caption position settings. + OpenDocument writer: make table/figure rendering sensitive to caption position settings. + Typst writer/template: implement figure caption positions by triggering a show rule in the default template, which determines caption positions for figures and tables globally. + LaTeX writer: make table/figure rendering sensitive to caption position settings. Closes #5116. + HTML writer/template: make `<figcaption>` placement sensitive to caption position settings. For tables, `<caption>` must be the first element, and positioning is determined by CSS, for here we set a variable which the default template is sensitive to.
2024-07-01Add option to link rather than embedding images in ODT.John MacFarlane
New cli option: `--link-images`. This causes images to be linked rather than embedded in ODT. New field in WriterOptions: `writerLinkImages` [API change]. New field in Opt: `optLinkImages` [API change]. Closes #9815.
2024-04-25Update copyright dates to 2024.John MacFarlane
2023-07-19Fix errors for illegal output formats.John MacFarlane
Previously if you did `pandoc -s -t bbb`, it would give you an error about the missing bbb template instead of saying that it's not a supported output format.
2023-07-05Make modern AsciiDoc the target for `asciidoc`.John MacFarlane
The AsciiDoc community now regards the dialect parsed by `asciidoctor` as the official AsciiDoc syntax, so it should be the target of our `asciidoc` format. Closes #8936. The `asciidoc` output format now behaves like `asciidoctor` used to. `asciidoctor` is a deprecated synonynm. For the old `asciidoc` behavior (targeting the Python script), use `asciidoc_legacy`. The templates have been consolidated. Instead of separate `default.asciidoctor` and `default.asciidoc` templates, there is just `default.asciidoc`. Text.Pandoc.Writers.AsciiDoc API changes: - `writeAsciiDoc` now behaves like `writeAsciiDoctor` used to. - `writeAsciiDoctor` is now a deprecated synonym for `writeAsciiDoc`. - New exported function `writeAsciiDocLegacy` behaves like `writeAsciDoc` used to.
2023-06-27Use toTextM instead of toText when possible.John MacFarlane
(That is, whenever we have the filename and are in a PandocMonad instance.) This will lead to more informative error messages for UTF8 encoding, indicating the file path and byte offset where the error occurs. Closes #8884.
2023-03-20T.P.Format: add new function `formatFromFilePaths` [API Change] (#8710)Albert Krewinkel
* T.P.Format: export `formatFromFilePaths` [API change] * Lua: add function `pandoc.format.from_path` * Update lua-filters.md * The old T.P.App.FormatHeuristics module has been removed. This is an alternative to #8693.
2023-01-30Add new `--chunk-template` option (closes #8581).John MacFarlane
* Add `--chunk-template` CLI option, allowing more control over the chunk filenames in chunked HTML output. * Text.Pandoc.App: Add `optChunkTemplate` constructor to Opt [API change]. * Text.Pandoc.Options: add `writerChunkTemplate` contsructor to WriterOptions [API change]. * Text.Pandoc.Chunks: add Data, Typeable, Generic instances for PathTemplate.
2023-01-25Ensure that automatically set variables ...John MacFarlane
`pandoc-version`, `outputfile`, `title-prefix`, `epub-cover-image`, `curdir`, `dzslides-core` can be overridden by `--variable` on the command line. Previously they would create lists in the template Context, which is not desirable.
2023-01-12Replace `--epub-chapter-level` with `--split-level`.John MacFarlane
Rationale: we need this splitting level now not just in EPUB but in chunked HTML. `--epub-chapter-level` will still function as a deprecated synonynm. `epub-chapter-level` will also continue to work in defaults files, ande `epub_chapter_level` will still work for Lua marshalling. [API changes] Text.Pandoc.App.Opt: remove `optEpubChapterLevel`, add `optSplitLevel`. Text.Pandoc.Options: remove `writerEpubChapterLevel`, add `writerSplitLevel`.
2023-01-11Add ChunkedHTML writer.John MacFarlane
- Add module Text.Pandoc.Writers.ChunkedHTML, exporting writeChunkedHtml [API change]. - Revised API for Text.Pandoc.Chunks. `chunkNext`, `chunkPrev`, `chunkUp` are now just `Maybe Chunk`. - Fix assignment of navigation elements of Chunks. - Strip off anchor portion of next and prev links. - Remove Ord instances for SecInfo, Chunk. - Derive Show, Eq, Generic for ChunkDoc. - Add `chunkSectionNumber`, `chunkUnlisted`. - Automatically unwrap the zip to a directory if an extensionless output file specified. - Incorporate images with relative paths below working dir.
2023-01-10Update copyright years, it's 2023!Albert Krewinkel
2022-12-20T.P.Scripting: Refactor the scripting engine.John MacFarlane
The new type CustomComponents is exported from T.P.Scripting, and the ScriptEngine fields are changed. Instead of separate fields for custom readers and writers, we now have a single function that loads any number of "components" from a script: these may be custom readers, custom writers, templates for writers, or extension configs. (Note: it's possible to have a custom reader and a custom writer for a format together in the same file.) Pandoc now checks the folder `custom` in the user's data directory for a matching script if it can't find one in the local directory. Previously, the `readers` and `writers` data directories were search for custom readers and writers, respectively. Scripts in those directories must be moved to the `custom` folder. Custom readers used to implement a fallback behavior that allowed to consume just a string value as input to the `Reader` function. This has been removed, the first argument is now always a list of sources. Use `tostring` on that argument to get a string. Closes #8417. Signed-off-by: Albert Krewinkel <[email protected]>
2022-12-14T.P.App.OutputSettings: remove unused record field `outputWriterName`Albert Krewinkel
2022-12-05Lua: support `-D` CLI option for custom writers [API change]Albert Krewinkel
A new error `PandocNoTemplateError` (code 87) is thrown if a template is required but cannot be found.
2022-12-04EPUB writer: make title page optional.John MacFarlane
New command line option: `--epub-title-page=true|false`. New `writerEpubTitlePage` field on `WriterOptions` [API change]. New `optEpubTitlePage` field on `Opts` [API change]. Closes #6097.
2022-10-19Split Text.Pandoc.Version from Text.Pandoc.Shared.John MacFarlane
This new module exports `pandocVersion` and `pandocVersionText`, which are no longer exported from Text.Pandoc.Shared. [API change] Also, we now set the `pandoc-version` variable centrally rather than in the writers. One effect is the man writer now emits a comment with the pandoc version (this was intended before, judging from the template, but it didn't happen because the vairable wasn't set).
2022-10-15Minor code cleanups.John MacFarlane
2022-10-14Lua: Support built-in default templates for custom writersAlbert Krewinkel
Custom writers can define a default template via a global `Template` function; the data directory is no longer searched for a default template. Writer authors can restore the old lookup behavior with ``` lua Template = function () local template return template.compile(template.default(PANDOC_SCRIPT_FILE)) end ```
2022-10-11Templates: use filename to search for default template of custom writersAlbert Krewinkel
The default template of a custom writer `/path/to/my-writer.lua` is expected in the `templates/default.my-writer.lua` data file. Note that templates are *not* applied automatically to the output of custom writers; custom writer authors must ensure that the template is applied if one is present in the writer options. Closes: #8137
2022-10-10Lua: support extensions in custom writersAlbert Krewinkel
Custom writers can define the extensions that they support via the global `writer_extensions`. The variable's value must be a table with all supported extensions as keys, and their default status as values. E.g., the below specifies that the writer support the extensions `smart` and `sourcepos`, but only the `smart` extension is enabled by default: writer_extensions = { smart = true, sourcepos = false, }
2022-10-08[API Change] Change argument type of `getReader`, `getWriter`.Albert Krewinkel
The functions now take a `FlavoredFormat` instead of a text argument.
2022-10-08[API Change] Add new module "Text.Pandoc.Format"Albert Krewinkel
The module provides functions and types for format spec parsing and processing. The function `parseFormatSpec` was moved from Text.Pandoc.Extensions to the new module and renamed to `parseFlavoredFormat`. It now operates in a PandocMonad and is based on the updated types.
2022-10-03[API Change] Base custom writers on Writer type.Albert Krewinkel
The `T.P.Lua.writeCustom` function changed to allow either a TextWriter or ByteStringWriter to be returned. The global variables `PANDOC_DOCUMENT` and `PANDOC_WRITER_OPTIONS` are no longer set when the writer script is loaded. Both variables are still set in classic writers before the conversion is started, so they can be used when they are wrapped in functions.
2022-09-30[API Change] Parameterize `convertWithOpts` over scripting engine.Albert Krewinkel
2022-09-30[API Change] Remove modules T.P.Writers.Custom and T.P.Readers.Custom.Albert Krewinkel
The functions `writeCustom` and `readCustom` are available from module Text.Pandoc.Lua.
2022-09-29Add `--list-tables` option.John MacFarlane
[API change] Add writerListTables to WriterOptions. RST writer: Remove sensitivity to "list-table" class in table attributes. Instead, just check `writerListTables` in writer options. See #4564.
2022-08-14T.P.Highlighting: Export `lookupHighlightingStyle`.John MacFarlane
[API change] Previously this lived in an unexported module T.P.App.CommandLineOptions, under the name `lookupHighlightStyle`.
2022-02-09PDF: allow custom writer as format if engine is explicitly specified (#7901)Albert Krewinkel
Closes #7898. Note that it may be necessary to explicitly specify a template on the command line.
2022-01-04Stop exporting `writeCustom` from module T.P.Writers [API change]Albert Krewinkel
This ensures that all writer exported in T.P.Writers are parameterized and work with any `PandocMonad` type. This is consistent with T.P.Readers, as `readCustom` is not exported from that module either.
2022-01-02Copyright notices: update for 2022Albert Krewinkel
2021-08-28Add `--sandbox` option.John MacFarlane
+ 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 MacFarlane
so we can run this with any instance of PandocMonad and MonadIO, not just PandocIO.
2021-02-22Text.Pandoc.UTF8: change IO functions to return Text, not String.John MacFarlane
[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-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel
* 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 Krewinkel
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-06Use traverse instead of reimplementing it (#6124)Joseph C. Sible
2020-01-08Change setVariable to use Text instead of String.John MacFarlane
This avoids some unnecessary unpacking. (This is only an internal module so it's not an API change.)
2019-12-11Improved template API and fixed a bug. Closes #5979.John MacFarlane
* 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-14Change optInputFiles to a `Maybe [FilePath]`.John MacFarlane
`Nothing` means: nothing specified. `Just []` means: an empty list specified (e.g. in defaults). Potentially these could lead to different behavior: see #5888.