From 9af5b1ca8bf849f12a21fe8a5a91ab4249cf5ff2 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Fri, 7 Jun 2024 17:56:49 +0200 Subject: Lua: add function `pandoc.template.get`. The function allows to specify a template with the same argument value that would be used with the `--template` command line parameter. Closes: #9854 Co-authored-by: Carsten Gips --- .../test/lua/module/pandoc-template.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'pandoc-lua-engine/test/lua/module') diff --git a/pandoc-lua-engine/test/lua/module/pandoc-template.lua b/pandoc-lua-engine/test/lua/module/pandoc-template.lua index ba18986ff..65e0798f5 100644 --- a/pandoc-lua-engine/test/lua/module/pandoc-template.lua +++ b/pandoc-lua-engine/test/lua/module/pandoc-template.lua @@ -1,4 +1,5 @@ local tasty = require 'tasty' +local pandoc = require 'pandoc' local template = require 'pandoc.template' local assert = tasty.assert @@ -24,8 +25,25 @@ return { ) end), test('fails on unknown format', function () + local success, msg = pcall(function () + return pandoc.utils.type(template.default 'nosuchformat') + end) + assert.is_falsy(success) + end), + }, + group 'get' { + test('is function', function () + assert.are_equal(type(template.get), 'function') + end), + test('searches the template data directory', function () + assert.are_equal( + template.default 'html5', + template.get 'default.html5' + ) + end), + test('fails on non-existent file', function () local success, msg = pcall(function () - return pandoc.utils.type(template.default 'nosuchformat') + return pandoc.utils.type(template.get 'nosuchfile.nope') end) assert.is_falsy(success) end), -- cgit v1.2.3