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

get_filename4code should have an accompanying function to get rid of the temporary directories #87

Closed
jerri opened this issue Apr 28, 2021 · 4 comments · Fixed by #88
Closed

Comments

@jerri
Copy link
Contributor

jerri commented Apr 28, 2021

As far as I understand the code the function get_filename4code is supposed to create a temporary directory to work with files while doing the filtering. Unfortunately there is no suggested function that cleans up the temporary files after filtering. This leads to a lot of pandoc filters to leave directories in the current running pwd that are not really necessary anymore (e.g. mermaid_images, plantuml_images etc.). These files get generated in whatever directory the filter was executed.

On top of the clean-function the code should maybe be impemented by using real tempdir-functionality, thereby creating the files in a temp-directory of the server. Because based on where you start pandoc and what permissions you have in the current directory the current approach can lead to errors, when the directory can't be created, or worse, dirtying of directories that by chance have the same name.

@jgm
Copy link
Owner

jgm commented Apr 28, 2021

I agree with all of this. However, this project is in a 'barely maintained' state right now. I'm not a Python programmer. If you want to submit a PR, I'd definitely consider this change.
You might also consider panflute, which is a more fully featured and Pythonic library for writing pandoc filters.

@ickc
Copy link
Collaborator

ickc commented Apr 30, 2021

Most if not all of the pandocfilters examples are ported to panflute. You can give it a try: https://github.com/sergiocorreia/panflute

I'm not aware of such a helper function in panflute to create temp-dir. (but you should check first.) But you can submit PR there and I can help merging it.

@jerri
Copy link
Contributor Author

jerri commented Apr 30, 2021

HAHA... :-) "Barely maintained", but two answers within less than 24h. Thanks for your swift feedback.
The reason I point out this topic is, that a lot of pandoc filters are out in the wild based on this library and all suffering this problem of creating unnecessary directories all over the place.
I will check it out and see if I can come up with a PR that at least creates the temporary directory in a sane place. Have to see when I can find time for that.

@jerri
Copy link
Contributor Author

jerri commented May 1, 2021

I created a PR to correct the behaviour. #88

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 a pull request may close this issue.

3 participants