Skip to content

How to construct Sources in lua? #10668

Answered by tarleb
CodeSandwich asked this question in Q&A
Discussion options

You must be logged in to vote

There is currently no way to construct Sources items in Lua scripts. Pandoc passes a list of Sources to custom readers, so that the reader has access to the filenames and can access files separately if needed. The read function accepts Sources for convenience and for backwards compatibility, because pandoc used to pass only a single string at first.

We could think about adding a pandoc.Sources constructor, but I'm not sure if it would be worth the effort. The pandoc.mediabag.fetch function alreday provides a way to access a file's content with a single function call:

local mimetype, content = pandoc.mediabag.fetch(FILENAME)

Or, if one doesn't want to assign a variable, pandoc.read(select(…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CodeSandwich
Comment options

Answer selected by CodeSandwich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants