aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Custom.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-04-28Support new Underline element in readers and writers (#6277)Vaibhav Sagar1-0/+2
Deprecate `underlineSpan` in Shared in favor of `Text.Pandoc.Builder.underline`.
2020-04-17API change: use PandocError for exceptions in Lua subsystemAlbert Krewinkel1-18/+9
The PandocError type is used throughout the Lua subsystem, all Lua functions throw an exception of this type if an error occurs. The `LuaException` type is removed and no longer exported from `Text.Pandoc.Lua`. In its place, a new constructor `PandocLuaError` is added to PandocError.
2020-04-15Adapt to the newest Table type, fix some previous adaptation issuesdespresc1-2/+1
- Writers.Native is now adapted to the new Table type. - Inline captions should now be conditionally wrapped in a Plain, not a Para block. - The toLegacyTable function now lives in Writers.Shared.
2020-04-15Implement the new Table typedespresc1-2/+4
2020-03-22Finer grained imports of Text.Pandoc.Class submodules (#6203)Albert Krewinkel1-1/+1
This should speed-up recompilation after changes in `Text.Pandoc.Class`, as the number of modules affected by a change will be smaller in general. It also offers faster insights into the parts of `T.P.Class` used within a module.
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
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-6/+7
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-29Changes to build with new doctemplates/doclayout.John MacFarlane1-5/+7
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-08-25Use new doctemplates, doclayout.John MacFarlane1-4/+4
+ 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-7/+4
* 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-07-23Templates: Change type of renderTemplate'.John MacFarlane1-1/+1
Return value is now Text rather than being polymorphic. This makes room for upcoming removal of the TemplateTarget class from doctemplates. Other code modified accordingly, and should compile with both current and upcoming version of doctemplates.
2019-03-01Remove license boilerplate.John MacFarlane1-17/+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-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-10-28T.P.Lua: expose more useful internals (API change)Albert Krewinkel1-3/+2
Newly exported from Text.Pandoc.Lua: - `runFilterFile` to run a Lua filter from file; - data type `Global` and its constructors; and - `setGlobals` to add globals to a Lua environment. This module also contains `Pushable` and `Peekable` instances required to get pandoc's data types to and from Lua. Low-level Lua operation remain hidden in Text.Pandoc.Lua.
2018-10-28T.P.Lua: rename `runPandocLua` to `runLua` (API change)Albert Krewinkel1-2/+2
2018-10-26Text.Pandoc.Lua: move globals handling to separate moduleAlbert Krewinkel1-30/+8
2018-10-14Custom writer: provide PANDOC_DOCUMENT instead of Setup functionAlbert Krewinkel1-18/+26
Custom writers have access to the global variable `PANDOC_DOCUMENT`. The variable contains a userdata wrapper around the full pandoc AST and exposes two fields, `meta` and `blocks`. The field content is only marshaled on-demand, performance of scripts not accessing the fields remains unaffected.
2018-10-13Custom writer: give full access to doc in optional Setup function (#4967)Albert Krewinkel1-1/+16
Custom writers can specify an optional `Setup` function. The function takes the full Pandoc document as input and should not return any value. Users can use this function to configure the writer depending on the given document's content or its metadata. data/sample.lua: add sample use of Setup function. The change allows to control the image format used to encode the image produced from dot code. Closes #4957
2018-10-01Lua filters: report traceback when an error occursAlbert Krewinkel1-2/+2
A proper Lua traceback is added if either loading of a file or execution of a filter function fails. This should be of help to authors of Lua filters who need to debug their code.
2018-09-24Use hslua v1.0.0Albert Krewinkel1-69/+74
2018-08-12Lua: cleanup Lua utils, remove unused functions.Albert Krewinkel1-7/+7
2018-05-16Custom writer: fix error message on script failureAlbert Krewinkel1-1/+1
Error messages produced by Lua were not displayed by Pandoc. The writer was using the bottom-most stack element, while the error message is the top-most element. This lead to the writer to always show "Lua 5.3" as error message, disregarding the actual message.
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-02-24Lua: register script name in global variableAlbert Krewinkel1-1/+2
The name of the Lua script which is executed is made available in the global Lua variable `PANDOC_SCRIPT_FILE`, both for Lua filters and custom writers. Closes: #4393
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2017-12-27Fix regression of DefinitionLists in custom writerAlbert Krewinkel1-1/+11
Pairs where serialized as two-element lists instead, and are now pushed again as a table with a single key/value pair. Fixes: #4202
2017-12-27Fix custom writer regressionAlbert Krewinkel1-2/+1
An additional `Lua.call` was left in during refactoring, which caused an exception "attempt to call a nil value". Fixes: #4202
2017-12-13Custom writer: use init file to setup Lua interpreterAlbert Krewinkel1-11/+12
The same init file (`data/init`) that is used to setup the Lua interpreter for Lua filters is also used to setup the interpreter of custom writers.lua.
2017-12-13Custom writer: define instances for newtype wrapperAlbert Krewinkel1-69/+57
The custom writer used its own `ToLuaStack` instance definitions, which made it difficult to share code with Lua filters, as this could result in conflicting instances. A `Stringify` wrapper is introduced to avoid this problem.
2017-10-29hlint suggestions.John MacFarlane1-1/+1
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane1-3/+3
2017-08-16Update to hslua-0.8.0Albert Krewinkel1-0/+6
hslua no longer provides lua stack instances for Int and Double, the necessary instances are added to the Custom writer and the lua filtering system.
2017-08-13Delete Text.Pandoc.Lua.SharedInstancesAlbert Krewinkel1-1/+0
Stack instances for common data types are now provides by hslua. The instance for Either was useful only for a very specific case; the function that was using the `ToLuaStack Either` instance was rewritten to work without it. Closes: #3805
2017-08-13Use hslua >= 0.7, update Lua codeAlbert Krewinkel1-128/+109
2017-06-20Writers: adjusted for renderTemplate' changes.John MacFarlane1-2/+5
Now we raise a proper error on template failure.
2017-06-11Switched Writer types to use Text.John MacFarlane1-3/+5
* XML.toEntities: changed type to Text -> Text. * Shared.tabFilter -- fixed so it strips out CRs as before. * Modified writers to take Text. * Updated tests, benchmarks, trypandoc. [API change] Closes #3731.
2017-05-13Update dates in copyright noticesAlbert Krewinkel1-2/+2
This follows the suggestions given by the FSF for GPL licensed software. <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>
2017-04-14Avoid repeating StackValue instances definitionsAlbert Krewinkel1-30/+1
The lua filters and custom lua writer system defined very similar StackValue instances for strings and tuples. These instance definitions are extracted to a separate module to enable sharing.
2017-04-14Extract lua helper functions into Lua.Util moduleAlbert Krewinkel1-10/+7
2017-03-28Custom writer: remove old preprocesesor conditionalsAlbert Krewinkel1-36/+0
The minimum required hslua version is 0.4.0, the conditionals inserted to support hslua-0.3.* can hence be removed.
2017-03-24Ensure compatibility with hslua 0.5.*Albert Krewinkel1-1/+2
The 0.5.0 release of hslua fixes problems with lua C modules on linux. The signature of the `loadstring` function changed, so a compatibility wrapper is introduced to allow both 0.4.* and 0.5.* versions to be used.
2017-03-04Stylish-haskell automatic formatting changes.John MacFarlane1-22/+25
2016-11-30Options: Removed writerStandalone, made writerTemplate a Maybe.John MacFarlane1-5/+3
Previously setting writerStandalone = True did nothing unless a template was provided in writerTemplate. Now a fragment will be generated if writerTemplate is Nothing; otherwise, the specified template will be used and standalone output generated. [API change]
2016-10-13Add support for the LineBlock element to writersAlbert Krewinkel1-0/+2
The following markup features are used to output the lines of the `LineBlock` element: - AsciiDoc: a `[verse]` block, - ConTeXt: text surrounded by `\startlines` and `\endlines`, - HTML: `div` with an per-element style setting to interpret the content as pre-wrapped, - Markdown: line blocks if the `line_blocks` extension is enabled, a simple paragraph with hard linebreaks otherwise, - Org: VERSE block, - RST: a line block, and - all other formats: a paragraph, containing hard linebreaks between lines. Custom lua writers should be updated to use the `LineBlock` element.
2016-02-05Custom writer: Pass attributes parameter to CaptionedImage.John MacFarlane1-2/+2
Closes #2697.
2015-12-11Implemented SoftBreak and new `--wrap` option.John MacFarlane1-4/+6
Added threefold wrapping option. * Command line option: deprecated `--no-wrap`, added `--wrap=[auto|none|preserve]` * Added WrapOption, exported from Text.Pandoc.Options * Changed type of writerWrapText in WriterOptions from Bool to WrapOption. * Modified Text.Pandoc.Shared functions for SoftBreak. * Supported SoftBreak in writers. * Updated tests. * Updated README. Closes #1701.
2015-11-19Merge branch 'new-image-attributes' of https://github.com/mb21/pandoc into ↵John MacFarlane1-3/+3
mb21-new-image-attributes * Bumped version to 1.16. * Added Attr field to Link and Image. * Added `common_link_attributes` extension. * Updated readers for link attributes. * Updated writers for link attributes. * Updated tests * Updated stack.yaml to build against unreleased versions of pandoc-types and texmath. * Fixed various compiler warnings. Closes #261. TODO: * Relative (percentage) image widths in docx writer. * ODT/OpenDocument writer (untested, same issue about percentage widths). * Update pandoc-citeproc.
2015-11-09Revert "Use -XNoImplicitPrelude and 'import Prelude' explicitly."John MacFarlane1-1/+0
This reverts commit c423dbb5a34c2d1195020e0f0ca3aae883d0749b.