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

[WIP]: Lua: Add function pandoc.init #9862

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Jun 9, 2024

This function allows to initialize the state in PANDOC_STATE, but only if it hasn't been initialized yet. The function has no effect in filters and custom readers/writers, but only in standalone scripts.

Any function that queries the state will cause it to be auto-initialized to the default value, so there should be no behavior changes.

The Haskell API probably needs more work, I tried to keep changes small for now.

@jgm
Copy link
Owner

jgm commented Jun 9, 2024

Could you say a bit more about the kind of things that would require this, by way of motivation?

@tarleb
Copy link
Collaborator Author

tarleb commented Jun 9, 2024

Sure, sorry. The background is that I'm extending the Inara system used by JOSS, because I need to create files with names that are built from metadata values to match the schema expected by PUBMED. I don't want to use much shell scripting for that, which is why I'm trying to write it as a standalone Lua script. [WIP]

There script always runs with the default CommonState, so without user data directory and . as resource path. It's not a big problem, because it's fairly easy to work around this, but some code would be shorter if I could configure the CommonState. The goal would be to write something like

pandoc.init {
  user_data_dir = '/usr/share/openjournals/data',
}

so I could do things like

local template = pandoc.template.default 'html5'

to get templates from that data directory (if they exist).

In summary, it's less that I need it, and more that it seems to be a missing functionality that potentially helpful in some cases.

@jgm
Copy link
Owner

jgm commented Jun 9, 2024

No objections on my part!

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

Successfully merging this pull request may close these issues.

2 participants