Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list-table.lua throws version-number error when called via --filter, but works with --lua-filter #10

Closed
julianbarg opened this issue Mar 26, 2024 · 5 comments

Comments

@julianbarg
Copy link

I did a bunch of trial and error, but this error message really threw me for a loop. Running

pandoc test.md -o test.pdf --filter ./list-table.lua

I get the error lua: /home/jules/.pandoc/lua_filters/list-table3.lua:8: pandoc version >=2.11 is required . (Needless to say, I am using a newer version.) The filter works as expected when calling it via:

pandoc test.md -o test.pdf --lua-filter ./list-table.lua

@helpatbbf
Copy link

--filter runs a program:

% pandoc --help | grep filter
  -F PROGRAM            --filter=PROGRAM                                      
  -L SCRIPTPATH         --lua-filter=SCRIPTPATH     

Is this the standard list-table.lua? If it was executable (it would presumably need a lua shebang line) I guess it would run standalone and perhaps you'd get this output, but when I try it I just get this:

% pandoc simple.md --filter ./list-table.lua 
Error running filter ./list-table.lua:
Could not find executable ./list-table.lua

@wlupton
Copy link
Member

wlupton commented Mar 26, 2024

(Sorry, that was me logged in as the wrong user.)

@julianbarg
Copy link
Author

I tried it as both an executable and non-executable. Yes, I got that error message, too, and so I ran chmod +x on the file to "advance" to the error message above.

@wlupton
Copy link
Member

wlupton commented Mar 27, 2024

OK. Did you also add a shebang line? I'm guessing that you did something like this (I didn't know that this worked):

#!/usr/bin/env lua
-- lua filter for RST-like list-tables in Markdown.
-- Copyright (C) 2021 Martin Fischer, released under MIT license

if PANDOC_VERSION and PANDOC_VERSION.must_be_at_least then
    PANDOC_VERSION:must_be_at_least("2.11")
else
    error("pandoc version >=2.11 is required")
end
...

With this I get the same as you:

% pandoc simple.md --filter ./list-table.lua 
lua: ././list-table.lua:8: pandoc version >=2.11 is required
stack traceback:
	[C]: in function 'error'
	././list-table.lua:8: in main chunk
	[C]: in ?
Error running filter ./list-table.lua:
Filter returned error status 1

This happens because the lua script is running as a standalone executable and isn't receiving any lua context from pandoc, so PANDOC_VERSION is nil, the if test fails, and you get the error message.

But the bottom line is that this was never going to work! Do you now see why? If not, I suggest re-reading the relevant section of the manual.

@julianbarg
Copy link
Author

I see, that makes sense. The debugging experience was frustrating, but that seems to be on pandoc's side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants