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.
This commit is contained in:
Albert Krewinkel 2021-12-21 18:53:37 +01:00
parent 1c389bf6b6
commit 17a32a99a5
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
4 changed files with 26 additions and 20 deletions

View file

@ -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

View file

@ -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:

View file

@ -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"

View file

@ -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