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

pandoc.WriterOptions does not complain if it is passed an uncompiled template #8321

Closed
fiapps opened this issue Sep 25, 2022 · 0 comments
Closed

Comments

@fiapps
Copy link

fiapps commented Sep 25, 2022

The following Lua filter code is incorrect, because the template has not been compiled, but pandoc.WriterOptions does not throw an error for an invalid template value, it just silently ignores it and produces a non-standalone document. I consider it a bug that there is no error.

An alternative solution would be for pandoc.WriterOptions to try to compile the template if it is passed a string instead of a compiled template for template.

function write_markdown_file(doc, filename)
  local options = pandoc.WriterOptions{
    template = pandoc.template.default('markdown')
  }
  local data = pandoc.write(doc, 'markdown', options)
  local file <close>, error = io.open(filename, 'w')
  if file == fail then
    io.stderr:write(string.format('Failed to write Markdown file: %s\n', error))
    os.exit(1)
  end
  file:write(data)
end

I'm using pandoc 2.19.2 on macOS 12.6. See also the pandoc-discuss thread that led to filing this bug.

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

2 participants