aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
AgeCommit message (Collapse)AuthorFilesLines
2021-11-02Lua: allow to compare, show Citation valuesAlbert Krewinkel1-1/+12
Comparisons of Citation values are performed in Haskell; values are equal if they represent the same Haskell value. Converting a Citation value to a string now yields its native Haskell string representation.
2021-11-01Lua: restore `content` property on Header elementsAlbert Krewinkel1-0/+2
2021-10-31Lua: re-add `content` property to Link elementsAlbert Krewinkel1-0/+2
This was a regression introduced in version 2.15. Fixes: #7647
2021-10-30Fix build on GHC 9.2Joseph C. Sible1-0/+1
2021-10-29Lua: use hslua module abstraction where possibleAlbert Krewinkel11-297/+374
This will make it easier to generate module documentation in the future.
2021-10-28Lua: increase strictness when getting attribute keysAlbert Krewinkel1-2/+2
2021-10-27Lua: re-add `t` and `tag` property to Attr valuesAlbert Krewinkel1-0/+4
Removal of these properties from Attr values was a regression.
2021-10-27Lua: fix `pandoc.utils.stringify` regressionAlbert Krewinkel1-1/+1
The `pandoc.utils.stringify` function returned empty strings when called with a string argument.
2021-10-26Fix a copy/paste bug in Lua marshalling code.John MacFarlane1-1/+1
This led changes in link properties in Lua filters to change the links into images! Closes #7639.
2021-10-26Lua: marshal SimpleTable values as userdata objectsAlbert Krewinkel3-46/+58
2021-10-26Lua: generate constants in module pandoc programmaticallyAlbert Krewinkel1-0/+17
2021-10-26Lua: marshal ListAttributes values as userdata objectsAlbert Krewinkel6-15/+80
2021-10-26Lua: marshal Block values as userdata objectsAlbert Krewinkel4-146/+461
Properties of Block values are marshalled lazily, which generally improves performance considerably. Script users may also notice the following differences: - Block element properties can no longer be accessed by numerical indexing of the `.c` field. The `.c` property now serves as an alias for `.content`, so some filter that used this undocumented method for property access may continue to work, while others will need to be updated and use proper property names. - The marshalled Block elements now have a `show` method, and a `__tostring` metamethod. Both return the Haskell string representation of the element. - Block values now have the Lua type `userdata` instead of `table`.
2021-10-25Lua: marshal Citation values as userdata objectsAlbert Krewinkel3-16/+53
2021-10-23Lua: convert IOErrors to PandocErrors in pandoc.pipe functionAlbert Krewinkel1-0/+2
Fixes: #7523
2021-10-22Lua: marshal Version values as userdataAlbert Krewinkel6-125/+12
2021-10-22Lua: marshal Inline elements as userdataAlbert Krewinkel2-63/+345
This includes the following user-facing changes: - Deprecated inline constructors are removed. These are `DoubleQuoted`, `SingleQuoted`, `DisplayMath`, and `InlineMath`. - Attr values are no longer normalized when assigned to an Inline element property. - It's no longer possible to access parts of Inline elements via numerical indexes. E.g., `pandoc.Span('test')[2]` used to give `pandoc.Str 'test'`, but yields `nil` now. This was undocumented behavior not intended to be used in user scripts. Use named properties instead. - Accessing `.c` to get a JSON-like tuple of all components no longer works. This was undocumented behavior. - Only known properties can be set on an element value. Trying to set a different property will now raise an error.
2021-10-22Lua: marshal Attr values as userdataAlbert Krewinkel4-14/+233
- Adds a new `pandoc.AttributeList()` constructor, which creates the associative attribute list that is used as the third component of `Attr` values. Values of this type can often be passed to constructors instead of `Attr` values. - `AttributeList` values can no longer be indexed numerically.
2021-10-22Lua: marshal Pandoc values as userdataAlbert Krewinkel2-11/+36
2021-10-22Switch to hslua-2.0Albert Krewinkel23-1115/+1013
The new HsLua version takes a somewhat different approach to marshalling and unmarshalling, relying less on typeclasses and more on specialized types. This allows for better performance and improved error messages. Furthermore, new abstractions allow to document the code and exposed functions.
2021-10-12Revert "Depend on pandoc-types 1.23, remove Null constructor on Block."John MacFarlane1-0/+2
This reverts commit fb0d6c7cb63a791fa72becf21ed493282e65ea91.
2021-10-01Depend on pandoc-types 1.23, remove Null constructor on Block.John MacFarlane1-2/+0
2021-08-24Text.Pandoc.Class: add readStdinStrict method to PandocMonad.John MacFarlane1-0/+1
[API change]
2021-08-24Lua subsystem and custom writers: generalize types from PandocIO...John MacFarlane2-6/+4
to any instance of PandocMonad and MonadIO. This involves an API change, since the type of runLua is now (PandocMonad m, MonadIO m) => Lua a -> m (Either PandocError a)
2021-06-10Lua utils: fix handling of table headers in `from_simple_table`Albert Krewinkel1-1/+1
Passing an empty list of header cells now results in an empty table header. Fixes: #7369
2021-05-24MediaBag improvements.John MacFarlane1-3/+3
In the current dev version, we will sometimes add a version of an image with a hashed name, keeping the original version with the original name, which would leave to undesirable duplication. This change separates the media's filename from the media's canonical name (which is the path of the link in the document itself). Filenames are based on SHA1 hashes and assigned automatically. In Text.Pandoc.MediaBag: - Export MediaItem type [API change]. - Change MediaBag type to a map from Text to MediaItem [API change]. - `lookupMedia` now returns a `MediaItem` [API change]. - Change `insertMedia` so it sets the `mediaPath` to a filename based on the SHA1 hash of the contents. This will be used when contents are extracted. In Text.Pandoc.Class.PandocMonad: - Remove `fetchMediaResource` [API change]. Lua MediaBag module has been changed minimally. In the future it would be better, probably, to give Lua access to the full MediaItem type.
2021-04-08Lua filter: respect Inlines/Blocks filter functions in pandoc.walk_*Albert Krewinkel2-3/+10
2021-03-15Use foldl' instead of foldl everywhere.John MacFarlane1-1/+2
2021-02-27Lua: use strict evaluation when retrieving AST value from the stackAlbert Krewinkel1-79/+77
Fixes: #6674
2021-02-04Lua filters: use same function names in Haskell and LuaAlbert Krewinkel2-28/+30
2021-02-02Lua: add module "pandoc.path"Albert Krewinkel1-0/+2
The module allows to work with file paths in a convenient and platform-independent manner. Closes: #6001 Closes: #6565
2021-01-26Lua: always load built-in Lua scripts from default data-dirAlbert Krewinkel4-46/+44
The Lua modules `pandoc` and `pandoc.List` are now always loaded from the system's default data directory. Loading from a different directory by overriding the default path, e.g. via `--data-dir`, is no longer supported to avoid unexpected behavior and to address security concerns.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel24-34/+34
2020-12-16Support Lua marshalling of doctemplates BoolVal.John MacFarlane1-0/+1
This updates T.P.Lua.Marshaling.Context for doctemplates >= 0.9.
2020-11-07Lint code in PRs and when committing to master (#6790)Albert Krewinkel1-1/+1
* Remove unused LANGUAGE pragmata * Apply HLint suggestions * Configure HLint to ignore some warnings * Lint code when committing to master
2020-10-14Fix typos in comments, doc strings, error messages, and testsAlbert Krewinkel1-1/+1
Typos reported by https://fossies.org/linux/test/pandoc-master.tar.gz/codespell.html See: #6738
2020-09-20Lua filters: add SimpleTable for backwards compatibility (#6575)Albert Krewinkel5-7/+106
A new type `SimpleTable` is made available to Lua filters. It is similar to the `Table` type in pandoc versions before 2.10; conversion functions from and to the new Table type are provided. Old filters using tables now require minimal changes and can use, e.g., if PANDOC_VERSION > {2,10,1} then pandoc.Table = pandoc.SimpleTable end and function Table (tbl) tbl = pandoc.utils.to_simple_table(tbl) … return pandoc.utils.from_simple_table(tbl) end to work with the current pandoc version.
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres2-6/+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-07-25Lua filters: make attr argument optional in Table constructorAlbert Krewinkel1-1/+1
This changes the Lua API. It is highly unlikely for this change to affect existing filters, since the documentation for the new Table constructor (and type) was incomplete and partly wrong before. The Lua API is now more consistent, as all constructors for elements with attributes now take attributes as the last parameter.
2020-05-12Lua: fix regression in package searcherAlbert Krewinkel1-2/+8
This caused `require 'module'` to fail for third party packages. Fixes: #6361
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 new type PandocLua for all pandoc Lua operationsAlbert Krewinkel7-204/+241
The new type `PandocLua` is an instance of the `PandocMonad` typeclass and can thus be used in a way similar to `PandocIO`.
2020-04-17API change: use PandocError for exceptions in Lua subsystemAlbert Krewinkel9-35/+175
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-15Lua: support new tablesAlbert Krewinkel1-17/+99
2020-04-15Use the new builders, modify readers to preserve empty headersdespresc1-1/+2
The Builder.simpleTable now only adds a row to the TableHead when the given header row is not null. This uncovered an inconsistency in the readers: some would unconditionally emit a header filled with empty cells, even if the header was not present. Now every reader has the conditional behaviour. Only the XWiki writer depended on the header row being always present; it now pads its head as necessary.
2020-04-15Adapt to the newest Table type, fix some previous adaptation issuesdespresc2-11/+34
- 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 typedespresc2-3/+40
2020-03-29Clean up some fmaps (#6226)Joseph C. Sible1-1/+1
* Avoid fmapping when we're just binding right after anyway * Clean up unnecessary fmaps in the LaTeX reader
2020-03-22Finer grained imports of Text.Pandoc.Class submodules (#6203)Albert Krewinkel7-9/+14
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 Krewinkel19-36/+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.