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

Custom writer: give full access to doc in optional Setup function #4967

Merged
merged 2 commits into from
Oct 14, 2018

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Oct 13, 2018

Custom writers can specify an optional Setup function. The function
takes the full Pandoc document as input and should not return any value.
Users can use this function to configure the writer depending on the
given document's content or its metadata.

Closes: #4957

@jgm
Copy link
Owner

jgm commented Oct 13, 2018

Could you give an example of usage, and also update the sample custom writer in data/ so we have this function?

Custom writers can specify an optional `Setup` function. The function
takes the full Pandoc document as input and should not return any value.
Users can use this function to configure the writer depending on the
given document's content or its metadata.

Closes: jgm#4957
@tarleb tarleb force-pushed the custom-writer-setup branch from 0953964 to f6c14df Compare October 13, 2018 19:01
The change allows to control the image format used to encode the image
produced from dot code.
@tarleb tarleb force-pushed the custom-writer-setup branch from f6c14df to a29d100 Compare October 13, 2018 19:09
@tarleb
Copy link
Collaborator Author

tarleb commented Oct 13, 2018

I've added example usage to data/sample.lua; the image format used in data urls can now be controlled with the image_format metadata field.

I'm honestly still unsure if a Setup function is the best way for this. I mainly chose it because it's simple. Would a global PANDOC_AST be better? It wouldn't incur much of a cost if we used a marshaling method similar to what's now done with Sec (from Shared.Element) data.

@jgm jgm merged commit 4954406 into jgm:master Oct 14, 2018
@tarleb tarleb deleted the custom-writer-setup branch October 14, 2018 06:43
@tarleb
Copy link
Collaborator Author

tarleb commented Oct 14, 2018

I had a change of mind and replaced the Setup function with a global variable. I think it's less confusing and easier to use. @jgm, please revert if you disagree with that change.

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

Successfully merging this pull request may close these issues.

2 participants