Skip to content

pandoc.scaffolding.Writer.Blocks(blocks) results in error table expected, got number #10817

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

Open
rnwst opened this issue May 3, 2025 · 5 comments

Comments

@rnwst
Copy link
Contributor

rnwst commented May 3, 2025

Explain the problem.
Running the following file test.lua:

Writer = pandoc.scaffolding.Writer
Writer.Block.Para = function(para) return 'para' end
Writer.Blocks({pandoc.Para('asdf'), pandoc.Para('qwer')})

as follows:

pandoc lua test.lua

results in the following error:

Error running Lua:
table expected, got number
stack traceback:
	test.lua:3: in main chunk

Based on what is written in the custom writer documentation, I think this should work -- but it is entirely possible that I missed something!

Pandoc version?

pandoc 3.6.4
Features: +server +lua
Scripting engine: Lua 5.4
@rnwst rnwst added the bug label May 3, 2025
@jgm
Copy link
Owner

jgm commented May 3, 2025

Writer.Block.Para = function(para) return 'para' end

You're returning a string from a function that expects a block or a list of blocks.
Could that be the problem?

@rnwst
Copy link
Contributor Author

rnwst commented May 3, 2025

The documentation states:

The render functions must return a string, a pandoc.layout Doc element, or a list of such elements.

Furthermore, if I remove that line from the script, the same error happens, so I don't think that's the issue.

@jgm
Copy link
Owner

jgm commented May 6, 2025

You're right. I'm not sure what is going on here -- it may be that something in scaffolding has gotten broken. Have you tried earlier pandoc versions?

@rnwst
Copy link
Contributor Author

rnwst commented May 8, 2025

I haven't tried using older versions of pandoc yet -- I just discovered this while playing around with custom writers, but I don't actually have a use case for a custom writer at the moment, so getting to the bottom of this has not been a priority. I thought I'd open an issue though, so that it is captured at least. I'm happy to look into this further when I find the time.

@tarleb
Copy link
Collaborator

tarleb commented May 20, 2025

I can confirm this bug. It seems that the scaffolding writer works correctly when called via the Writer function, but not when any of the individual element functions is called outside of that.

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

No branches or pull requests

3 participants