Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ghc-pandoc-lua-marshal for openSUSE:Factory checked in at 2023-04-04 21:22:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-pandoc-lua-marshal (Old) and /work/SRC/openSUSE:Factory/.ghc-pandoc-lua-marshal.new.19717 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-pandoc-lua-marshal" Tue Apr 4 21:22:01 2023 rev:4 rq:1075984 version:0.2.2 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-pandoc-lua-marshal/ghc-pandoc-lua-marshal.changes 2022-08-01 21:32:23.766000246 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-pandoc-lua-marshal.new.19717/ghc-pandoc-lua-marshal.changes 2023-04-04 21:22:20.861851822 +0200 @@ -1,0 +2,52 @@ +Thu Mar 30 17:07:48 UTC 2023 - Peter Simons <psim...@suse.com> + +- Updated spec file to conform with ghc-rpm-macros-2.5.2. + +------------------------------------------------------------------- +Wed Mar 15 20:49:41 UTC 2023 - Peter Simons <psim...@suse.com> + +- Update pandoc-lua-marshal to version 0.2.2. + ## 0.2.2 + + Released 2023-03-15. + + - Add `__tostring` metamethods to *Blocks* and *Inlines*. + +------------------------------------------------------------------- +Mon Mar 13 12:18:58 UTC 2023 - Peter Simons <psim...@suse.com> + +- Update pandoc-lua-marshal to version 0.2.1.1. + ## 0.2.1.1 + + Released 2023-03-13. + + - The version constraints for hslua packages have been relaxed; + other changes in hslua 2.3.\* do not affect this package. + +------------------------------------------------------------------- +Sat Feb 11 16:10:47 UTC 2023 - Peter Simons <psim...@suse.com> + +- Update pandoc-lua-marshal to version 0.2.1. + Upstream has edited the change log file since the last release in + a non-trivial way, i.e. they did more than just add a new entry + at the top. You can review the file at: + http://hackage.haskell.org/package/pandoc-lua-marshal-0.2.1/src/CHANGELOG.md + +------------------------------------------------------------------- +Wed Jan 18 17:01:10 UTC 2023 - Peter Simons <psim...@suse.com> + +- Update pandoc-lua-marshal to version 0.2.0. + ## 0.2.0 + + Release pending. + + - Depend on pandoc-types 1.23: the `Null` Block constructor has + been removed, and a `Figure` constructor has been added. + + - Support for Lua 5.3 has been dropped; the package now requires + hslua 2.2 or later. + + - The implementation for `List` has been moved to the separate + `hslua-list` module. This module no longer contains C code. + +------------------------------------------------------------------- Old: ---- pandoc-lua-marshal-0.1.7.tar.gz New: ---- pandoc-lua-marshal-0.2.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-pandoc-lua-marshal.spec ++++++ --- /var/tmp/diff_new_pack.Hk5kwX/_old 2023-04-04 21:22:21.665856375 +0200 +++ /var/tmp/diff_new_pack.Hk5kwX/_new 2023-04-04 21:22:21.669856397 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-pandoc-lua-marshal # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,32 +17,53 @@ %global pkg_name pandoc-lua-marshal +%global pkgver %{pkg_name}-%{version} %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.1.7 +Version: 0.2.2 Release: 0 Summary: Use pandoc types in Lua License: MIT URL: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel +BuildRequires: ghc-aeson-devel +BuildRequires: ghc-aeson-prof +BuildRequires: ghc-base-devel +BuildRequires: ghc-base-prof BuildRequires: ghc-bytestring-devel +BuildRequires: ghc-bytestring-prof BuildRequires: ghc-containers-devel +BuildRequires: ghc-containers-prof BuildRequires: ghc-exceptions-devel +BuildRequires: ghc-exceptions-prof BuildRequires: ghc-hslua-devel +BuildRequires: ghc-hslua-list-devel +BuildRequires: ghc-hslua-list-prof BuildRequires: ghc-hslua-marshalling-devel +BuildRequires: ghc-hslua-marshalling-prof +BuildRequires: ghc-hslua-prof BuildRequires: ghc-lua-devel +BuildRequires: ghc-lua-prof BuildRequires: ghc-pandoc-types-devel +BuildRequires: ghc-pandoc-types-prof BuildRequires: ghc-rpm-macros BuildRequires: ghc-safe-devel +BuildRequires: ghc-safe-prof BuildRequires: ghc-text-devel +BuildRequires: ghc-text-prof ExcludeArch: %{ix86} %if %{with tests} BuildRequires: ghc-QuickCheck-devel +BuildRequires: ghc-QuickCheck-prof BuildRequires: ghc-tasty-devel BuildRequires: ghc-tasty-hunit-devel +BuildRequires: ghc-tasty-hunit-prof BuildRequires: ghc-tasty-lua-devel +BuildRequires: ghc-tasty-lua-prof +BuildRequires: ghc-tasty-prof BuildRequires: ghc-tasty-quickcheck-devel +BuildRequires: ghc-tasty-quickcheck-prof %endif %description @@ -67,6 +88,22 @@ This package provides the Haskell %{pkg_name} library development files. +%package -n ghc-%{pkg_name}-doc +Summary: Haskell %{pkg_name} library documentation +Requires: ghc-filesystem +BuildArch: noarch + +%description -n ghc-%{pkg_name}-doc +This package provides the Haskell %{pkg_name} library documentation. + +%package -n ghc-%{pkg_name}-prof +Summary: Haskell %{pkg_name} profiling library +Requires: ghc-%{pkg_name}-devel = %{version}-%{release} +Supplements: (ghc-%{pkg_name}-devel and ghc-prof) + +%description -n ghc-%{pkg_name}-prof +This package provides the Haskell %{pkg_name} profiling library. + %prep %autosetup -n %{pkg_name}-%{version} @@ -91,4 +128,9 @@ %files devel -f %{name}-devel.files %doc CHANGELOG.md README.md +%files -n ghc-%{pkg_name}-doc -f ghc-%{pkg_name}-doc.files +%license LICENSE + +%files -n ghc-%{pkg_name}-prof -f ghc-%{pkg_name}-prof.files + %changelog ++++++ pandoc-lua-marshal-0.1.7.tar.gz -> pandoc-lua-marshal-0.2.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/CHANGELOG.md new/pandoc-lua-marshal-0.2.2/CHANGELOG.md --- old/pandoc-lua-marshal-0.1.7/CHANGELOG.md 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/CHANGELOG.md 2001-09-09 03:46:40.000000000 +0200 @@ -2,6 +2,40 @@ `pandoc-lua-marshal` uses [PVP Versioning][]. +## 0.2.2 + +Released 2023-03-15. + +- Add `__tostring` metamethods to *Blocks* and *Inlines*. + +## 0.2.1.1 + +Released 2023-03-13. + +- The version constraints for hslua packages have been relaxed; + other changes in hslua 2.3.\* do not affect this package. + +## 0.2.1 + +Released 2023-02-11. + +- All userdata types have been given a `__tojson` metamethod. + The methods return the default JSON representations of AST + objects. + +## 0.2.0 + +Released 2023-01-18. + +- Depend on pandoc-types 1.23: the `Null` Block constructor has + been removed, and a `Figure` constructor has been added. + +- Support for Lua 5.3 has been dropped; the package now requires + hslua 2.2 or later. + +- The implementation for `List` has been moved to the separate + `hslua-list` module. This module no longer contains C code. + ## 0.1.7 Released 2022-07-16. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/README.md new/pandoc-lua-marshal-0.2.2/README.md --- old/pandoc-lua-marshal-0.1.7/README.md 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/README.md 2001-09-09 03:46:40.000000000 +0200 @@ -8,7 +8,7 @@ Use pandoc types in Lua. -[GitHub CI]: https://github.com/tarleb/pandoc-lua-marshal/workflows/CI/badge.svg +[GitHub CI]: https://img.shields.io/github/actions/workflow/status/pandoc/pandoc-lua-marshal/ci.yml?branch=main&logo=github [1]: https://github.com/tarleb/pandoc-lua-marshal/actions [Hackage]: https://img.shields.io/hackage/v/pandoc-lua-marshal.svg?logo=haskell [2]: https://hackage.haskell.org/package/pandoc-lua-marshal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/cbits/listmod.c new/pandoc-lua-marshal-0.2.2/cbits/listmod.c --- old/pandoc-lua-marshal-0.1.7/cbits/listmod.c 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/cbits/listmod.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,354 +0,0 @@ -#include <stdlib.h> -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" - -#define LIST_T "List" - -/* compatibility with older Lua versions, which did not define this in the - * header. */ -#ifndef LUA_LOADED_TABLE -/* key, in the registry, for table of loaded modules */ -#define LUA_LOADED_TABLE "_LOADED" -#endif - -/* -** Placeholder function. -*/ -static int missing (lua_State *L) { - return luaL_error(L, - "Function should have been overwritten with one from the table module." - ); -} - -/* Translate a relative table position: negative means back from end */ -static lua_Integer posrelat (lua_Integer pos, size_t len) { - if (pos >= 0) return pos; - else if (0u - (size_t)pos > len) return 0; - else return (lua_Integer)len + pos + 1; -} - -/* -** Check that 'arg' is either a function or a different callable object. -*/ -static void checkcallable (lua_State *L, int arg) { - if (lua_type(L, arg) != LUA_TFUNCTION) { /* is it not a function? */ - if (luaL_getmetafield(L, arg, "__call")) - lua_pop(L, 1); /* pop metamethod */ - else - luaL_checktype(L, arg, LUA_TFUNCTION); /* force an error */ - } -} - -/* -** Creates a List from a table; uses a fresh, empty table if none is -** given. -*/ -static int list_new (lua_State *L) { - lua_settop(L, 2); - if (lua_isnoneornil(L, 2)) { - lua_newtable(L); - lua_remove(L, 2); - } else { - luaL_checktype(L, 2, LUA_TTABLE); - } - lua_pushvalue(L, 1); - lua_setmetatable(L, 2); - return 1; -} - -/* -** Creates a shallow clone of the given list; the clone will contain -** only the list elements, not any other elements that might have been -** present. -*/ -static int list_clone (lua_State *L) { - lua_settop(L, 1); - luaL_checktype(L, 1, LUA_TTABLE); - lua_Integer len = luaL_len(L, 1); - lua_createtable(L, len, 0); /* create new table */ - lua_getmetatable(L, 1); - lua_setmetatable(L, 2); - for (lua_Integer i = 1; i <= len; i++) { - lua_geti(L, 1, i); - lua_seti(L, 2, i); - } - return 1; -} - -/* -** Creates a new list that is the concatenation of its two arguments. -** The result has the same metatable as the first operand. -*/ -static int list_concat (lua_State *L) { - lua_settop(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checktype(L, 2, LUA_TTABLE); - lua_Integer len1 = luaL_len(L, 1); - lua_Integer len2 = luaL_len(L, 2); - lua_createtable(L, len1 + len2, 0); /* result table */ - if (lua_getmetatable(L, 1)) { - lua_setmetatable(L, 3); - } - for (lua_Integer i = 1; i <= len1; i++) { - lua_geti(L, 1, i); - lua_seti(L, 3, i); - } - for (lua_Integer i = 1; i <= len2; i++) { - lua_geti(L, 2, i); - lua_seti(L, 3, len1 + i); - } - return 1; -} - -/* -** Checks equality. Two lists are equal if and only if they have the same -** metatable and if all items are equal. -*/ -static int list_eq (lua_State *L) { - lua_settop(L, 2); - /* compare meta tables */ - if (!(lua_getmetatable(L, 1) && - lua_getmetatable(L, 2) && - lua_rawequal(L, -1, -2))) { - lua_pushboolean(L, 0); - return 1; - }; - lua_pop(L, 2); /* remove metatables */ - - /* ensure both lists have the same length */ - lua_Integer len1 = luaL_len(L, 1); - lua_Integer len2 = luaL_len(L, 2); - if (len1 != len2) { - lua_pushboolean(L, 0); - return 1; - } - - /* check element-wise equality */ - for (lua_Integer i = 1; i <= len1; i++) { - lua_geti(L, 1, i); - lua_geti(L, 2, i); - if (!lua_compare(L, -1, -2, LUA_OPEQ)) { - lua_pushboolean(L, 0); - return 1; - } - } - lua_pushboolean(L, 1); - return 1; -} - -/* -** Appends the second list to the first. -*/ -static int list_extend (lua_State *L) { - lua_settop(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checktype(L, 2, LUA_TTABLE); - lua_Integer len1 = luaL_len(L, 1); - lua_Integer len2 = luaL_len(L, 2); - for (lua_Integer i = 1; i <= len2; i++) { - lua_geti(L, 2, i); - lua_seti(L, 1, len1 + i); - } - return 1; -} - -/* -** Removes elements that do not have the desired property. -*/ -static int list_filter (lua_State *L) { - lua_settop(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - checkcallable(L, 2); - luaL_checkstack(L, 4, NULL); - lua_Integer len = luaL_len(L, 1); - lua_createtable(L, len, 0); /* create new table */ - lua_getmetatable(L, 1); - lua_setmetatable(L, 3); - for (lua_Integer i = 1, j = 0; i <= len; i++) { - lua_pushvalue(L, 2); /* push predicate function */ - lua_geti(L, 1, i); - lua_pushinteger(L, i); - lua_call(L, 2, 1); - if (lua_toboolean(L, -1)) { - lua_geti(L, 1, i); - lua_seti(L, 3, ++j); - } - lua_pop(L, 1); /* remove predicate call result */ - } - return 1; -} - -/* -** Returns the first element that is equal to `needle`, along with that -** element's index, or `nil` if no such element exists. -*/ -static int list_find (lua_State *L) { - luaL_checkstack(L, 2, "List.find"); - lua_settop(L, 3); - luaL_checktype(L, 1, LUA_TTABLE); - lua_Integer len = luaL_len(L, 1); - lua_Integer start = posrelat(luaL_optinteger(L, 3, 1), len); - for (lua_Integer i = start; i <= len; i++) { - lua_geti(L, 1, i); - if (lua_compare(L, 2, -1, LUA_OPEQ)) { - lua_pushinteger(L, i); - return 2; - } - lua_pop(L, 1); /* remove list element result */ - } - lua_pushnil(L); - return 1; -} - -/* -** Returns the first element after the given start index for which the -** predicate function returns a truthy value, along with that element's -** index; returns `nil` if no such element exists. -*/ -static int list_find_if (lua_State *L) { - lua_settop(L, 3); - luaL_checktype(L, 1, LUA_TTABLE); - checkcallable(L, 2); - lua_Integer len = luaL_len(L, 1); - lua_Integer start = posrelat(luaL_optinteger(L, 3, 1), len); - for (lua_Integer i = start; i <= len; i++) { - lua_pushvalue(L, 2); /* predicate function */ - lua_geti(L, 1, i); - lua_pushinteger(L, i); - lua_call(L, 2, 1); - if (lua_toboolean(L, -1)) { - lua_geti(L, 1, i); - lua_pushinteger(L, i); - return 2; - } - lua_pop(L, 1); /* remove predicate call result */ - } - lua_pushnil(L); - return 1; -} - -/* -** Returns a boolean value indicating whether or not the element exists -** in the given list. -*/ -static int list_includes(lua_State *L) { - lua_settop(L, 3); - lua_pushcfunction(L, list_find); - lua_insert(L, 1); - lua_call(L, 3, 1); - luaL_checkstack(L, 1, "List.includes"); - lua_pushboolean(L, lua_toboolean(L, -1)); - return 1; -} - -/* -** Returns a copy of the current list by applying the given function to -** all elements. -*/ -static int list_map(lua_State *L) { - lua_settop(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - checkcallable(L, 2); - lua_Integer len = luaL_len(L, 1); - lua_createtable(L, len, 0); /* create new table */ - luaL_getmetatable(L, LIST_T); /* make result a generic list */ - lua_setmetatable(L, 3); - for (lua_Integer i = 1; i <= len; i++) { - lua_pushvalue(L, 2); /* map function */ - lua_geti(L, 1, i); - lua_pushinteger(L, i); - lua_call(L, 2, 1); - lua_seti(L, 3, i); - } - return 1; -} - -/* -** Pushes the standard `table` module to the stack. -*/ -static void pushtablemodule (lua_State *L) { - lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); - if (!lua_getfield(L, -1, LUA_TABLIBNAME)) { - /* apparently it's not been loaded yes. So open it here (but don't - * 'load' it). */ - lua_pushcfunction(L, luaopen_table); - lua_pushliteral(L, LUA_TABLIBNAME); - lua_call(L, 1, 1); - } - lua_remove(L, -2); /* remove LOADED table */ -} - -/* -** Fields to copy from standard `table` package. -*/ -static const char *tablelib_functions[] = { - "insert", - "remove", - "sort", - NULL -}; - -/* -** Copy fields from standard `table` module to the table at the given -** index. -*/ -static void copyfromtablelib (lua_State *L, int idx) { - int absidx = lua_absindex(L, idx); - pushtablemodule(L); - for (const char **name = tablelib_functions; *name != NULL; *name++) { - if (lua_getfield(L, -1, *name)) { - lua_setfield(L, absidx, *name); - } else { - lua_pop(L, 1); - } - } - lua_pop(L, 1); /* remove table module */ -} - -static const luaL_Reg list_funcs[] = { - {"__concat", list_concat}, - {"__eq", list_eq}, - {"clone", list_clone}, - {"extend", list_extend}, - {"filter", list_filter}, - {"find", list_find}, - {"find_if", list_find_if}, - {"includes", list_includes}, - {"insert", missing}, - {"map", list_map}, - {"new", list_new}, - {"remove", missing}, - {"sort", missing}, - {NULL, NULL} -}; - -static const luaL_Reg metareg[] = { - {"__call", list_new}, - {NULL, NULL} -}; - -/* -** Creates a new metatable for a new List-like type. - */ -int lualist_newmetatable (lua_State *L, const char *name) { - if (luaL_newmetatable(L, name)) { - luaL_setfuncs(L, list_funcs, 0); - /* use functions from standard table module. */ - copyfromtablelib(L, -1); - lua_pushvalue(L, -1); - lua_setfield(L, -2, "__index"); - return 1; - } - return 0; -} - -int luaopen_list (lua_State *L) { - luaL_checkversion(L); - lualist_newmetatable(L, LIST_T); - - lua_newtable(L); - luaL_setfuncs(L, metareg, 0); - lua_setmetatable(L, -2); - return 1; -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/pandoc-lua-marshal.cabal new/pandoc-lua-marshal-0.2.2/pandoc-lua-marshal.cabal --- old/pandoc-lua-marshal-0.1.7/pandoc-lua-marshal.cabal 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/pandoc-lua-marshal.cabal 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,6 @@ cabal-version: 2.4 name: pandoc-lua-marshal -version: 0.1.7 +version: 0.2.2 synopsis: Use pandoc types in Lua description: This package provides functions to marshal and unmarshal pandoc document types to and from Lua. @@ -19,23 +19,23 @@ license-file: LICENSE author: Albert Krewinkel, John MacFarlane maintainer: Albert Krewinkel <alb...@zeitkraut.de> -copyright: © 2017-2022 Albert Krewinkel, John MacFarlane +copyright: © 2017-2023 Albert Krewinkel, John MacFarlane category: Foreign build-type: Simple extra-doc-files: README.md , CHANGELOG.md tested-with: GHC == 8.6.5 - GHC == 8.8.4 - GHC == 8.10.7 - GHC == 9.0.2 - GHC == 9.2.3 + , GHC == 8.8.4 + , GHC == 8.10.7 + , GHC == 9.0.2 + , GHC == 9.2.5 + , GHC == 9.4.4 extra-source-files: test/test-attr.lua , test/test-block.lua , test/test-cell.lua , test/test-citation.lua , test/test-inline.lua , test/test-listattributes.lua - , test/test-list.lua , test/test-metavalue.lua , test/test-pandoc.lua , test/test-simpletable.lua @@ -46,13 +46,15 @@ common common-options build-depends: base >= 4.12 && < 5 + , aeson >= 1.5 && < 2.2 , bytestring >= 0.10 && < 0.12 , containers >= 0.6 && < 0.7 , exceptions >= 0.8 && < 0.11 - , lua >= 2.1 && < 2.3 - , hslua >= 2.1 && < 2.3 - , hslua-marshalling >= 2.1 && < 2.3 - , pandoc-types >= 1.22.1 && < 1.23 + , lua >= 2.2 && < 2.4 + , hslua >= 2.2 && < 2.4 + , hslua-list >= 1.1 && < 1.2 + , hslua-marshalling >= 2.2 && < 2.4 + , pandoc-types >= 1.23 && < 1.24 , safe >= 0.3 && < 0.4 , text >= 1.1.1.0 && < 1.3 || >= 2.0 && < 2.1 @@ -73,7 +75,6 @@ library import: common-options hs-source-dirs: src - c-sources: cbits/listmod.c exposed-modules: Text.Pandoc.Lua.Marshal.AST , Text.Pandoc.Lua.Marshal.Alignment , Text.Pandoc.Lua.Marshal.Attr @@ -100,6 +101,7 @@ , Text.Pandoc.Lua.Topdown , Text.Pandoc.Lua.SpliceList , Text.Pandoc.Lua.Walk + build-depends: hslua-list >= 1.1 && < 1.2 test-suite pandoc-lua-marshal-test import: common-options diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/AST.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/AST.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/AST.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/AST.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ {- | -Copyright: (c) 2021-2022 Albert Krewinkel -SPDX-License-Identifier: MIT -Maintainer: Albert Krewinkel <alb...@zeitkraut.de> +Copyright : © 2021-2023 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <alb...@zeitkraut.de> Use pandoc types in Lua -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Alignment.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Alignment.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Alignment.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Alignment.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,5 @@ {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Attr.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Attr.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Attr.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Attr.hs 2001-09-09 03:46:40.000000000 +0200 @@ -27,6 +27,7 @@ import Control.Applicative ((<|>), optional) import Control.Monad ((<$!>)) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import Data.Text (Text) import HsLua @@ -49,6 +50,10 @@ ### liftPure show <#> parameter peekAttr "Attr" "attr" "" =#> functionResult pushString "string" "native Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeAttr "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "identifier" "element identifier" (pushText, \(ident,_,_) -> ident) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Block.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Block.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Block.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Block.hs 2001-09-09 03:46:40.000000000 +0200 @@ -10,7 +10,8 @@ -} module Text.Pandoc.Lua.Marshal.Block ( -- * Single Block elements - peekBlock + typeBlock + , peekBlock , peekBlockFuzzy , pushBlock -- * List of Blocks @@ -28,6 +29,7 @@ import Control.Applicative ((<|>), optional) import Control.Monad.Catch (throwM) import Control.Monad ((<$!>)) +import Data.Aeson (encode) import Data.Data (showConstr, toConstr) import Data.Maybe (fromMaybe) import Data.Proxy (Proxy (Proxy)) @@ -83,6 +85,20 @@ <#> parameter peekFilter "Filter" "lua_filter" "table of filter functions" =#> functionResult pushBlocks "Blocks" "modified list" rawset (nth 3) + + pushName "__tostring" + pushDocumentedFunction $ lambda + ### liftPure show + <#> parameter peekBlocksFuzzy "Blocks" "self" "" + =#> functionResult pushString "string" "native Haskell representation" + rawset (nth 3) + + pushName "__tojson" + pushDocumentedFunction $ lambda + ### liftPure encode + <#> parameter peekBlocksFuzzy "Blocks" "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" + rawset (nth 3) setmetatable (nth 2) {-# INLINABLE pushBlocks #-} @@ -120,17 +136,23 @@ ### liftPure show <#> udparam typeBlock "self" "" =#> functionResult pushString "string" "Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeBlock "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ possibleProperty "attr" "element attributes" (pushAttr, \case CodeBlock attr _ -> Actual attr Div attr _ -> Actual attr + Figure attr _ _ -> Actual attr Header _ attr _ -> Actual attr Table attr _ _ _ _ _ -> Actual attr _ -> Absent) (peekAttr, \case CodeBlock _ code -> Actual . flip CodeBlock code Div _ blks -> Actual . flip Div blks + Figure _ capt blks -> Actual . (\attr -> Figure attr capt blks) Header lvl _ blks -> Actual . (\attr -> Header lvl attr blks) Table _ c cs h bs f -> Actual . (\attr -> Table attr c cs h bs f) _ -> const Absent) @@ -142,8 +164,12 @@ Table attr c cs h _ f -> Actual . (\bs -> Table attr c cs h bs f) _ -> const Absent) , possibleProperty "caption" "element caption" - (pushCaption, \case {Table _ capt _ _ _ _ -> Actual capt; _ -> Absent}) + (pushCaption, \case + Figure _ capt _ -> Actual capt + Table _ capt _ _ _ _ -> Actual capt + _ -> Absent) (peekCaptionFuzzy, \case + Figure attr _ blks -> Actual . (\c -> Figure attr c blks) Table attr _ cs h bs f -> Actual . (\c -> Table attr c cs h bs f) _ -> const Absent) , possibleProperty "colspecs" "column alignments and widths" @@ -222,9 +248,10 @@ Para inlns -> Actual $ ContentInlines inlns Plain inlns -> Actual $ ContentInlines inlns Header _ _ inlns -> Actual $ ContentInlines inlns - -- inline content + -- block content BlockQuote blks -> Actual $ ContentBlocks blks Div _ blks -> Actual $ ContentBlocks blks + Figure _ _ blks -> Actual $ ContentBlocks blks -- lines content LineBlock lns -> Actual $ ContentLines lns -- list items content @@ -244,6 +271,7 @@ -- block content BlockQuote _ -> Actual . BlockQuote . blockContent Div attr _ -> Actual . Div attr . blockContent + Figure attr c _ -> Actual . Figure attr c . blockContent -- lines content LineBlock _ -> Actual . LineBlock . lineContent -- list items content @@ -324,6 +352,16 @@ <#> optAttrParam =#> blockResult "Div element" + , defun "Figure" + ### liftPure3 (\content mcapt mattr -> + let attr = fromMaybe nullAttr mattr + capt = fromMaybe (Caption mempty mempty) mcapt + in Figure attr capt content) + <#> parameter peekBlocksFuzzy "Blocks" "content" "figure content" + <#> opt (parameter peekCaptionFuzzy "Caption" "caption" "figure caption") + <#> optAttrParam + =#> blockResult "Figure element" + , defun "Header" ### liftPure3 (\lvl content mattr -> Header lvl (fromMaybe nullAttr mattr) content) @@ -341,10 +379,6 @@ <#> parameter (peekList peekInlinesFuzzy) "{Inlines,...}" "content" "lines" =#> blockResult "LineBlock element" - , defun "Null" - ### return Null - =#> blockResult "Null element" - , defun "OrderedList" ### liftPure2 (\items mListAttrib -> let defListAttrib = (1, DefaultStyle, DefaultDelim) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Cell.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Cell.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Cell.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Cell.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE LambdaCase #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> @@ -17,6 +17,7 @@ import Control.Applicative (optional) import Control.Monad ((<$!>)) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import HsLua import Text.Pandoc.Lua.Marshal.Alignment (peekAlignment, pushAlignment) @@ -63,6 +64,10 @@ ### liftPure show <#> parameter peekCell "Cell" "self" "" =#> functionResult pushString "string" "native Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeCell "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "attr" "cell attributes" (pushAttr, \(Cell attr _ _ _ _) -> attr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Citation.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Citation.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Citation.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Citation.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> @@ -15,6 +15,7 @@ ) where import Control.Applicative (optional) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import HsLua as Lua import Text.Pandoc.Definition (Citation (..)) @@ -48,6 +49,10 @@ ### liftPure show <#> parameter peekCitation "Citation" "citation" "" =#> functionResult pushString "string" "native Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeCitation "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "id" "citation ID / key" (pushText, citationId) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/CitationMode.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/CitationMode.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/CitationMode.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/CitationMode.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,5 @@ {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Content.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Content.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Content.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Content.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Filter.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Filter.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Filter.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Filter.hs 2001-09-09 03:46:40.000000000 +0200 @@ -3,7 +3,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE ScopedTypeVariables #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Format.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Format.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Format.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Format.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,5 @@ {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Inline.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Inline.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Inline.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Inline.hs 2001-09-09 03:46:40.000000000 +0200 @@ -9,8 +9,9 @@ Marshal values of types that make up 'Inline' elements. -} module Text.Pandoc.Lua.Marshal.Inline - ( -- * Single Inline elements - peekInline + ( typeInline + -- * Single Inline elements + , peekInline , peekInlineFuzzy , pushInline -- * List of Inlines @@ -28,6 +29,7 @@ import Control.Applicative ((<|>), optional) import Control.Monad.Catch (throwM) import Control.Monad ((<$!>)) +import Data.Aeson (encode) import Data.Data (showConstr, toConstr) import Data.Maybe (fromMaybe) import Data.Text (Text) @@ -76,6 +78,20 @@ <#> parameter peekFilter "Filter" "lua_filter" "table of filter functions" =#> functionResult pushInlines "Blocks" "modified list" rawset (nth 3) + + pushName "__tostring" + pushDocumentedFunction $ lambda + ### liftPure show + <#> parameter peekInlinesFuzzy "Inlines" "self" "" + =#> functionResult pushString "string" "native Haskell representation" + rawset (nth 3) + + pushName "__tojson" + pushDocumentedFunction $ lambda + ### liftPure encode + <#> parameter peekInlinesFuzzy "Inlines" "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" + rawset (nth 3) setmetatable (nth 2) {-# INLINABLE pushInlines #-} @@ -111,6 +127,10 @@ <#> parameter (optional . peekInline) "a" "Inline" "" <#> parameter (optional . peekInline) "b" "Inline" "" =#> functionResult pushBool "boolean" "whether the two are equal" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeInline "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ possibleProperty "attr" "element attributes" (pushAttr, \case diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/List.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/List.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/List.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/List.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,23 +1,19 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel -SPDX-License-Identifier : MIT -Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> +Copyright : © 2021-2023 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> -Marshaling/unmarshaling functions and constructor for 'ListAttributes' -values. +Lua lists with additional methods. -} module Text.Pandoc.Lua.Marshal.List - ( pushPandocList - , luaopen_list_ptr - , pushListModule - , newListMetatable + ( module HsLua.List + , pushPandocList ) where -import Data.ByteString (useAsCString) -import Foreign.C import HsLua +import HsLua.List -- | Pushes a list as a numerically-indexed Lua table, and sets a -- metatable that offers a number of convenience functions. @@ -27,30 +23,3 @@ getmetatable' "List" >>= \case TypeTable -> setmetatable (nth 2) _ -> failLua "List has not been initialized correctly." - --- | Pointer to the function that opens the List module and pushes it to the --- stack. -foreign import ccall unsafe "listmod.c &luaopen_list" - luaopen_list_ptr :: CFunction - --- | Opens the List module and pushes it to the stack. -pushListModule :: LuaError e => LuaE e () -pushListModule = do - pushcfunction luaopen_list_ptr - call 0 1 - --- | Creates a new list metatable with the given name. -foreign import ccall "listmod.c lualist_newmetatable" - lualist_newmetatable :: State -> CString -> IO CInt - --- | Pushes the metatable of the given List type, creating it if --- necessary. The @setup@ operation is run when the metatable did not --- exists, was created, and is then at the top of the stack. The --- operation may modify the table but must be balanced, and must leave --- the stack as it found it. -newListMetatable :: Name -> LuaE e () {-^ setup -} -> LuaE e () -newListMetatable (Name name) setup = do - l <- state - liftIO (useAsCString name (lualist_newmetatable l)) >>= \case - 0 -> pure () -- metatable already registered; no need to setup again - _ -> setup diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/ListAttributes.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/ListAttributes.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/ListAttributes.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/ListAttributes.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> @@ -20,6 +20,7 @@ ) where import Control.Applicative (optional) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import HsLua import Text.Pandoc.Definition @@ -33,6 +34,10 @@ <#> parameter (optional . peekListAttributes) "a" "ListAttributes" "" <#> parameter (optional . peekListAttributes) "b" "ListAttributes" "" =#> functionResult pushBool "boolean" "whether the two are equal" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeListAttributes "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "start" "number of the first list item" (pushIntegral, \(start,_,_) -> start) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/MathType.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/MathType.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/MathType.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/MathType.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,5 @@ {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/MetaValue.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/MetaValue.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/MetaValue.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/MetaValue.hs 2001-09-09 03:46:40.000000000 +0200 @@ -3,7 +3,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Pandoc.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Pandoc.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Pandoc.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Pandoc.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> @@ -8,7 +8,8 @@ -} module Text.Pandoc.Lua.Marshal.Pandoc ( -- * Pandoc - peekPandoc + typePandoc + , peekPandoc , pushPandoc , mkPandoc -- * Meta @@ -21,6 +22,7 @@ import Control.Applicative (optional) import Control.Monad ((<$!>)) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import HsLua import Text.Pandoc.Lua.Marshal.Block (peekBlocksFuzzy, pushBlocks) @@ -55,6 +57,10 @@ ### liftPure show <#> parameter peekPandoc "Pandoc" "doc" "" =#> functionResult pushString "string" "native Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typePandoc "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "blocks" "list of blocks" (pushBlocks, \(Pandoc _ blks) -> blks) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/QuoteType.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/QuoteType.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/QuoteType.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/QuoteType.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,5 @@ {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Row.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Row.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Row.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Row.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE LambdaCase #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> @@ -17,6 +17,7 @@ import Control.Applicative (optional) import Control.Monad ((<$!>)) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import HsLua import Text.Pandoc.Lua.Marshal.Attr (peekAttr, pushAttr) @@ -56,6 +57,10 @@ ### liftPure show <#> parameter peekRow "Row" "self" "" =#> functionResult pushString "string" "native Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeRow "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "attr" "row attributes" (pushAttr, \(Row attr _) -> attr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Shared.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Shared.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/Shared.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/Shared.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/SimpleTable.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/SimpleTable.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/SimpleTable.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/SimpleTable.hs 2001-09-09 03:46:40.000000000 +0200 @@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <alb...@zeitkraut.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/TableFoot.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/TableFoot.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/TableFoot.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/TableFoot.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> @@ -14,6 +14,7 @@ ) where import Control.Applicative (optional) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import HsLua import Text.Pandoc.Lua.Marshal.Attr (peekAttr, pushAttr) @@ -41,6 +42,10 @@ ### liftPure show <#> parameter peekTableFoot "TableFoot" "self" "" =#> functionResult pushString "string" "native Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeTableFoot "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "attr" "table foot attributes" (pushAttr, \(TableFoot attr _) -> attr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/TableHead.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/TableHead.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/TableHead.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/TableHead.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> @@ -14,6 +14,7 @@ ) where import Control.Applicative (optional) +import Data.Aeson (encode) import Data.Maybe (fromMaybe) import HsLua import Text.Pandoc.Lua.Marshal.Attr (peekAttr, pushAttr) @@ -41,6 +42,10 @@ ### liftPure show <#> parameter peekTableHead "TableHead" "self" "" =#> functionResult pushString "string" "native Haskell representation" + , operation (CustomOperation "__tojson") $ lambda + ### liftPure encode + <#> udparam typeTableHead "self" "" + =#> functionResult pushLazyByteString "string" "JSON representation" ] [ property "attr" "table head attributes" (pushAttr, \(TableHead attr _) -> attr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/TableParts.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/TableParts.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Marshal/TableParts.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Marshal/TableParts.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {- | -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel SPDX-License-Identifier : MIT Maintainer : Albert Krewinkel <tarleb+pan...@moltkeplatz.de> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Walk.hs new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Walk.hs --- old/pandoc-lua-marshal-0.1.7/src/Text/Pandoc/Lua/Walk.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/src/Text/Pandoc/Lua/Walk.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,5 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {- | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/test/test-block.lua new/pandoc-lua-marshal-0.2.2/test/test-block.lua --- old/pandoc-lua-marshal-0.1.7/test/test-block.lua 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/test/test-block.lua 2001-09-09 03:46:40.000000000 +0200 @@ -122,6 +122,48 @@ ) end) }, + group 'Figure' { + test('access content via property `content`', function () + local elem = Figure{BlockQuote{Plain 'word'}} + assert.are_same(elem.content, {BlockQuote{'word'}}) + assert.are_equal(type(elem.content), 'table') + + elem.content = { + Para{Str 'one'}, + Para{Str 'two'} + } + assert.are_equal( + Figure{ + Para 'one', + Para 'two' + }, + elem + ) + end), + test('access caption via property `caption`', function () + local figure = Figure('word', {short='short', long='caption'}) + assert.are_equal(figure.caption.long, Blocks 'caption') + assert.are_equal(figure.caption.short, Inlines 'short') + assert.are_equal(type(figure.caption), 'table') + + figure.caption = {long = 'One day I was...', short = 'My day'} + assert.are_equal( + Figure('word', {long = 'One day I was...', short = 'My day'}), + figure + ) + end), + test('access Attr via property `attr`', function () + local figure = Figure('word', {long='caption'}, {'my-fig', {'sample'}}) + assert.are_equal(figure.attr, Attr{'my-fig', {'sample'}}) + assert.are_equal(type(figure.attr), 'userdata') + + figure.attr = Attr{'my-other-figure', {'example'}} + assert.are_equal( + Figure('word', {long='caption'}, {'my-other-figure', {'example'}}), + figure + ) + end) + }, group 'Header' { test('access inlines via property `content`', function () local header = Header(1, 'test') @@ -177,11 +219,6 @@ ) end) }, - group 'Null' { - test('Can be constructed', function () - assert.are_equal(Null().t, 'Null') - end) - }, group 'OrderedList' { test('access items via property `content`', function () local para = Plain 'one' @@ -372,6 +409,17 @@ ) end) }, + group 'tostring' { + test('works on an empty list', function () + assert.are_equal(tostring(Blocks{}), '[]') + end), + test('para singleton', function () + assert.are_equal( + tostring(Blocks{Para 'Hallo'}), + '[Para [Str "Hallo"]]' + ) + end), + }, group 'walk' { test('modifies Inline subelements', function () local blocks = Blocks{Para 'Hello, World!'} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/test/test-inline.lua new/pandoc-lua-marshal-0.2.2/test/test-inline.lua --- old/pandoc-lua-marshal-0.1.7/test/test-inline.lua 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/test/test-inline.lua 2001-09-09 03:46:40.000000000 +0200 @@ -325,6 +325,20 @@ ) end) }, + group 'tostring' { + test('works on an empty list', function () + assert.are_equal( + tostring(Inlines{}), + '[]' + ) + end), + test('simple inlines', function () + assert.are_equal( + tostring(Inlines 'Bonjour, Monsieur !'), + '[Str "Bonjour,",Space,Str "Monsieur",Space,Str "!"]' + ) + end), + }, group 'walk' { test('modifies Inline subelements', function () assert.are_same( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/test/test-list.lua new/pandoc-lua-marshal-0.2.2/test/test-list.lua --- old/pandoc-lua-marshal-0.1.7/test/test-list.lua 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/test/test-list.lua 1970-01-01 01:00:00.000000000 +0100 @@ -1,317 +0,0 @@ --- --- Tests for the pandoc types module --- -local tasty = require 'tasty' - -local group = tasty.test_group -local test = tasty.test_case -local assert = tasty.assert - -return { - group 'List' { - test('is a table', function () - assert.are_equal(type(List), 'table') - end), - group 'constructor' { - test('returns a new list if called without args', function () - assert.are_same(List(), {}) - end), - }, - - group 'clone' { - test('changing the clone does not affect original', function () - local orig = List:new {23, 42} - local copy = orig:clone() - copy[1] = 5 - assert.are_same({23, 42}, orig) - assert.are_same({5, 42}, copy) - end), - test('result is a list', function () - local orig = List:new {23, 42} - assert.are_equal(List, getmetatable(orig:clone())) - end), - }, - - group 'extend' { - test('extends list with other list', function () - local primes = List:new {2, 3, 5, 7} - primes:extend {11, 13, 17} - assert.are_same({2, 3, 5, 7, 11, 13, 17}, primes) - end) - }, - - group 'filter' { - test('keep elements for which property is truthy', function () - local is_small_prime = function (x) - return x == 2 or x == 3 or x == 5 or x == 7 - end - local numbers = List:new {4, 7, 2, 9, 5, 11} - assert.are_same(List{7, 2, 5}, numbers:filter(is_small_prime)) - end), - test('predecate function gets current index as second arg', function () - local args = List() - local collect_args = function (...) - args[#args+1] = {...} - return false - end - (List{0, 1, 1, 2, 3, 5, 8}):filter(collect_args) - assert.are_same( - args, - List{{0, 1}, {1, 2}, {1, 3}, {2, 4}, {3, 5}, {5, 6}, {8, 7}} - ) - end), - test('accepts callable table as function', function () - local always_true = function (t, x) return true end - local callable = setmetatable({}, {__call = always_true}) - assert.are_same( - List{0}, - List{0}:filter(callable) - ) - end), - test('fails on non-callable table', function () - assert.error_matches( - function () List{1}:filter({}) end, - 'bad argument %#1 to \'filter\' %(function expected, got table%)' - ) - end), - }, - - group 'find' { - test('returns element and index if found', function () - local list = List:new {5, 23, 71} - local elem, idx = list:find(71) - assert.are_same(71, elem) - assert.are_same(3, idx) - end), - test('respects start index', function () - local list = List:new {19, 23, 29, 71} - assert.are_equal(23, list:find(23, 1)) - assert.are_equal(23, list:find(23, 2)) - assert.are_equal(23, list:find(23, -4)) - assert.is_nil(list:find(23, 3)) - assert.is_nil(list:find(23, -2)) - end), - test('returns nil if element not found', function () - assert.is_nil((List:new {18, 20, 22, 0, 24}):find('0')) - end), - test('fails if start index is not an integer', function () - assert.error_matches( - function () List:new{}:find(0, 'NaN') end, - 'number expected, got string' - ) - end), - }, - - group 'find_if' { - test('returns element and index if found', function () - local perm_prime = List:new {2, 3, 5, 7, 11, 13, 17, 31, 37, 71} - local elem, idx = perm_prime:find_if(function (x) return x >= 10 end) - assert.are_same(11, elem) - assert.are_same(5, idx) - end), - test('gets current index as second arg', function () - assert.are_equal( - 5, - (List{9, 8, 7, 6, 5, 4, 3, 2, 1}):find_if( - function (x, i) return x == i end - ) - ) - end), - test('returns nil if element not found', function () - local is_zero = function (n) return n == 0 end - assert.is_nil((List:new {18, 20, 22, 24, 27}):find_if(is_zero)) - end), - test('respects start index', function () - local list = List:new {9, 29, 3, 71} - assert.are_equal(71, list:find_if(function(n) return n > 10 end, 3)) - assert.are_equal(29, list:find_if(function(n) return n > 10 end, -3)) - end), - test('fails if start index is not an integer', function () - assert.error_matches( - function () List:new{}:find(0, 'NaN') end, - 'number expected, got string' - ) - end), - test('accepts callable table', function () - local always_true = function (t, x) return true end - local callable = setmetatable({}, {__call = always_true}) - assert.are_equal(List{1}:find_if(callable), 1) - end), - test('fails on non-callable table', function () - assert.error_matches( - function () List():find_if({}) end, - 'bad argument %#1 to \'find_if\' %(function expected, got table%)' - ) - end), - }, - - group 'includes' { - test('finds elements in list', function () - local lst = List:new {'one', 'two', 'three'} - assert.is_truthy(lst:includes('one')) - assert.is_truthy(lst:includes('two')) - assert.is_truthy(lst:includes('three')) - assert.is_falsy(lst:includes('four')) - end), - test('doesn\'t crash with long lists', function () - local lst = List:new() - for i = 1, 1000 do - lst[#lst + 1] = tostring(i) - end - assert.is_truthy(lst:includes '999') - end) - }, - - group 'insert' { - test('is a function', function () - assert.are_equal(type(List.insert), 'function') - end), - test('insert value at end of list.', function () - local count_norsk = List {'en', 'to', 'tre'} - count_norsk:insert('fire') - assert.are_same({'en', 'to', 'tre', 'fire'}, count_norsk) - end), - test('insert value in the middle of list.', function () - local count_norsk = List {'fem', 'syv'} - count_norsk:insert(2, 'seks') - assert.are_same({'fem', 'seks', 'syv'}, count_norsk) - end) - }, - - group 'map' { - test('applies function to elements', function () - local primes = List:new {2, 3, 5, 7} - local squares = primes:map(function (x) return x^2 end) - assert.are_same({4, 9, 25, 49}, squares) - end), - test('leaves original list unchanged', function () - local primes = List:new {2, 3, 5, 7} - local squares = primes:map(function (x) return x^2 end) - assert.are_same({2, 3, 5, 7}, primes) - end), - test('map function gets index as second argument', function () - local primes = List:new {2, 3, 5, 7} - local indices = primes:map(function (x, i) return i end) - assert.are_same(List{1, 2, 3, 4}, indices) - end), - test('map returns a generic list', function () - local custom = CustomList{'α', 'β'} - assert.are_equal(debug.getmetatable(custom).__name, 'CustomList') - assert.are_same( - debug.getmetatable(custom:map(tostring)).__name, - 'List' - ) - end), - test('accepts callable table', function () - local plus_length = function (t, x) return x + #t end - local callable = setmetatable({1, 2}, {__call = plus_length}) - assert.are_equal(List{1, 3}:map(callable), List{3, 5}) - end), - test('fails on non-callable table', function () - assert.error_matches( - function () List{1}:map({}) end, - 'bad argument %#1 to \'map\' %(function expected, got table%)' - ) - end), - }, - - group 'new' { - test('keeps elements in list', function () - local test = {1, 1, 2, 3, 5} - assert.are_same(List:new(test), test) - end), - test('return empty list if no argument is given', function () - assert.are_same({}, List:new()) - end), - test('metatable of result is pandoc.List', function () - local test = List:new{5} - assert.are_equal(List, getmetatable(test)) - end) - }, - - group 'remove' { - test('is a function', function () - assert.are_equal(type(List.remove), 'function') - end), - test('remove value at end of list.', function () - local understand = List {'jeg', 'forstår', 'ikke'} - local norsk_not = understand:remove() - assert.are_same({'jeg', 'forstår'}, understand) - assert.are_equal('ikke', norsk_not) - end), - test('remove value at beginning of list.', function () - local count_norsk = List {'en', 'to', 'tre'} - count_norsk:remove(1) - assert.are_same({'to', 'tre'}, count_norsk) - end) - }, - - group 'sort' { - test('is a function', function () - assert.are_equal(type(List.sort), 'function') - end), - test('sort numeric list', function () - local numbers = List {71, 5, -1, 42, 23, 0, 1} - numbers:sort() - assert.are_same({-1, 0, 1, 5, 23, 42, 71}, numbers) - end), - test('reverse-sort numeric', function () - local numbers = List {71, 5, -1, 42, 23, 0, 1} - numbers:sort(function (x, y) return x > y end) - assert.are_same({71, 42, 23, 5, 1, 0, -1}, numbers) - end) - }, - }, - group 'Operations' { - group 'concatenation' { - test('yields a concatenated list', function () - assert.are_same(List {3, 4, 5, 6}, List{3, 4} .. List {5, 6}) - end), - test('does not modify its operands', function () - local a = List {54, 74} - local b = List {90, 2014} - local result = a .. b - assert.are_same(a, List{54, 74}) - assert.are_same(b, List{90, 2014}) - end), - test('sets metatable of first operand on result', function () - local result = {1, 4} .. List{9, 16} - assert.are_equal(nil, getmetatable(result)) - result = List{1, 4} .. {9, 16} - assert.are_equal(List, getmetatable(result)) - end), - }, - group 'equality' { - test('lists are equal if all elements are equal', function () - assert.are_equal( - List {5, 6, 7, 8}, - List {5, 6, 7, 8} - ) - end), - test('lists are not equal if their metatables are different', function () - assert.is_truthy( - List {18, 20, 2, 0, 24} ~= - CustomList {18, 20, 2, 0, 24} - ) - end), - test('lists are not equal if one is a plain table', function () - assert.is_truthy( - List {18, 20, 2, 0, 24} ~= - {18, 20, 2, 0, 24} - ) - end), - test('lists are not equal if an element differs', function () - assert.is_truthy( - List {18, 20, 22, 23, 24} ~= - List {18, 20, 22, 0, 24} - ) - end), - test('can compare to a string', function () - assert.is_truthy( - List {'a', 'b', 'c'} ~= - "abc" - ) - end), - } - }, -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pandoc-lua-marshal-0.1.7/test/test-pandoc-lua-marshal.hs new/pandoc-lua-marshal-0.2.2/test/test-pandoc-lua-marshal.hs --- old/pandoc-lua-marshal-0.1.7/test/test-pandoc-lua-marshal.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/pandoc-lua-marshal-0.2.2/test/test-pandoc-lua-marshal.hs 2001-09-09 03:46:40.000000000 +0200 @@ -25,18 +25,6 @@ main :: IO () main = do - listTests <- run @Lua.Exception $ do - openlibs - pushListModule *> setglobal "List" - -- Create a custom List type with constructor "CustomList" - pushHaskellFunction $ do - settop 1 - newListMetatable "CustomList" (pure ()) - setmetatable (nthBottom 1) - return 1 - setglobal "CustomList" - translateResultsFromFile "test/test-list.lua" - listAttributeTests <- run @Lua.Exception $ do openlibs register' mkListAttributes @@ -87,7 +75,6 @@ defaultMain $ testGroup "pandoc-lua-marshal" [ roundtrips - , listTests , listAttributeTests , attrTests , citationTests