aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-12-21 18:53:37 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2021-12-21 19:01:11 +0100
commit17a32a99a5eefadc5ebe66d441b6c4f7a0d2f438 (patch)
treea65d95bdc02f25530f1eeec44193bd97154fdb66
parent1c389bf6b6236cefcadac3c2eefe62eb6c884863 (diff)
downloadpandoc-17a32a99a5eefadc5ebe66d441b6c4f7a0d2f438.tar.gz
Lua: simplify and deprecate function `pandoc.utils.equals`
The function is no longer required for element comparisons; it is now an alias for the `==` operator.
-rw-r--r--cabal.project2
-rw-r--r--doc/lua-filters.md36
-rw-r--r--src/Text/Pandoc/Lua/Module/Utils.hs6
-rw-r--r--stack.yaml2
4 files changed, 26 insertions, 20 deletions
diff --git a/cabal.project b/cabal.project
index 8e56ca0a4..f0365d5da 100644
--- a/cabal.project
+++ b/cabal.project
@@ -6,7 +6,7 @@ constraints: aeson >= 2.0.1.0
source-repository-package
type: git
location: https://github.com/pandoc/pandoc-lua-marshal
- tag: 45e53d9dce37d20f8e30e0d297a43c5b4c4a6831
+ tag: f81ec19006cc4d0476f199d1fb913bac4af0a0d8
source-repository-package
type: git
diff --git a/doc/lua-filters.md b/doc/lua-filters.md
index e5ea90104..af3342826 100644
--- a/doc/lua-filters.md
+++ b/doc/lua-filters.md
@@ -831,8 +831,8 @@ Usage:
Pandoc document
Values of this type can be created with the
-[`pandoc.Pandoc`](#pandoc.pandoc) constructor. Object equality is
-determined via [`pandoc.utils.equals`].
+[`pandoc.Pandoc`](#pandoc.pandoc) constructor. Pandoc values are
+equal in Lua if and only if they are equal in Haskell.
`blocks`
: document content ([List] of [Blocks])
@@ -876,8 +876,8 @@ Meta information on a document; string-indexed collection of
[MetaValues].
Values of this type can be created with the
-[`pandoc.Meta`](#pandoc.meta) constructor. Object equality is
-determined via [`pandoc.utils.equals`].
+[`pandoc.Meta`](#pandoc.meta) constructor. Meta values are equal
+in Lua if and only if they are equal in Haskell.
## MetaValue {#type-metavalue}
@@ -909,7 +909,8 @@ or `pandoc.Blocks`.
## Block {#type-block}
-Object equality is determined via [`pandoc.utils.equals`].
+Block values are equal in Lua if and only if they are equal in
+Haskell.
### Common methods
@@ -1292,8 +1293,8 @@ Usage:
## Inline {#type-inline}
-Object equality is determined by checking the Haskell
-representation for equality.
+Inline values are equal in Lua if and only if they are equal in
+Haskell.
### Common methods
@@ -1741,7 +1742,7 @@ Result:
Usage:
- -- returns `pandoc.Inlines{pandoc.SmallCaps('SPQR)}`
+ -- returns `pandoc.Inlines{pandoc.SmallCaps('SPQR')}`
return pandoc.Inlines{pandoc.Emph('spqr')}:walk {
Str = function (s) return string.upper(s.text) end,
Emph = function (e) return pandoc.SmallCaps(e.content) end,
@@ -1766,7 +1767,8 @@ This also works when using the `attr` setter:
local span = pandoc.Span 'text'
span.attr = {id = 'text', class = 'a b', other_attribute = '1'}
-Object equality is determined via [`pandoc.utils.equals`].
+Attr values are equal in Lua if and only if they are equal in
+Haskell.
Fields:
@@ -1784,6 +1786,9 @@ Fields:
List of key/value pairs. Values can be accessed by using keys as
indices to the list table.
+Attributes values are equal in Lua if and only if they are equal
+in Haskell.
+
### Caption {#type-caption}
The caption of a table, with an optional short caption.
@@ -1835,7 +1840,8 @@ Single citation entry
Values of this type can be created with the
[`pandoc.Citation`](#pandoc.citation) constructor.
-Object equality is determined via [`pandoc.utils.equals`].
+Citation values are equal in Lua if and only if they are equal in
+Haskell.
Fields:
@@ -2115,7 +2121,7 @@ Values of this type can be created with the
`must_be_at_least(actual, expected [, error_message])`
Raise an error message if the actual version is older than the
-expected version; does nothing if actual is equal to or newer
+expected version; does nothing if `actual` is equal to or newer
than the expected version.
Parameters:
@@ -2173,7 +2179,6 @@ Usage:
[TableFoot]: #type-tablefoot
[TableHead]: #type-tablehead
[Version]: #type-version
-[`pandoc.utils.equals`]: #pandoc.utils.equals
# Module text
@@ -3308,12 +3313,13 @@ Test equality of AST elements. Elements in Lua are considered
equal if and only if the objects obtained by unmarshaling are
equal.
+**This function is deprecated.** Use the normal Lua `==` equality
+operator instead.
+
Parameters:
`element1`, `element2`:
-: Objects to be compared. Acceptable input types are [Pandoc],
- [Meta], [MetaValue], [Block], [Inline], [Attr],
- [ListAttributes], and [Citation].
+: Objects to be compared (any type)
Returns:
diff --git a/src/Text/Pandoc/Lua/Module/Utils.hs b/src/Text/Pandoc/Lua/Module/Utils.hs
index c1bb42410..24fd3402e 100644
--- a/src/Text/Pandoc/Lua/Module/Utils.hs
+++ b/src/Text/Pandoc/Lua/Module/Utils.hs
@@ -61,9 +61,9 @@ documentedModule = Module
=#> functionResult pushInlines "list of inlines" ""
, defun "equals"
- ### liftPure2 (==)
- <#> parameter peekAstElement "AST element" "elem1" ""
- <#> parameter peekAstElement "AST element" "elem2" ""
+ ### equal
+ <#> parameter pure "AST element" "elem1" ""
+ <#> parameter pure "AST element" "elem2" ""
=#> functionResult pushBool "boolean" "true iff elem1 == elem2"
, defun "make_sections"
diff --git a/stack.yaml b/stack.yaml
index 702e3a780..492f39cf0 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -38,7 +38,7 @@ extra-deps:
- git: https://github.com/jgm/ipynb.git
commit: 00246af10885c2ad4413ace4f69a7e6c88297a08
- git: https://github.com/pandoc/pandoc-lua-marshal
- commit: 45e53d9dce37d20f8e30e0d297a43c5b4c4a6831
+ commit: f81ec19006cc4d0476f199d1fb913bac4af0a0d8
- git: https://github.com/jgm/commonmark-hs
commit: 4d460b206e0b1872376db86cadf7a4567eeddaed
subdir: commonmark-pandoc