-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Add Pandoc support, refactor external helpers #4060
Conversation
ba056de
to
182f139
Compare
A quick question: Is it a remote possibility to do "shell injection" via pandoc --strip-comments && rm -rf / In the above I'm mostly worried about the people on the forum etc. that asks me questions of the type "can you clone my site and see what the problem is?" ... If I would start worrying about some malware type of situations, I would stop doing that. Note that I would expect the |
I don't think shell injection can be achieved in It's unfortunate though, most of the allure of using (If you're worried about malicious config files in general, I'll also note in passing that it looks like attackers can also specify arbitrary executables in the configuration option |
I will make a note about the |
I will think about this a little, about the cost vs value vs added support etc. This isn't "core Hugo", so any new additions in this department should come cheaply, and this currently does not look like it. |
182f139
to
4274cdc
Compare
I dropped the options for now to keep things simple. If there's demand for external options we (or somebody else) can revisit this later. |
Recognize the Pandoc format under the file extension .pandoc or .pdc, and shell out to pandoc as an external helper to format Pandoc content. Refactor out repeated code with external helpers. Change the error output formatting. I did not see any of the external helpers print the string "<input>" to represent stdin as a file; just prepending the file name to error output is more general and doesn't sacrifice that much in terms of readability.
4274cdc
to
a3f0dc6
Compare
Actually I'm going to go out on a limb and make |
Any updates? The PR as it currently stands should be fairly cheap; it doesn't use |
@bep any updates on the status of this PR, or anything else you'd like to be changed? |
It looks very good, I will merge it in "a couple of days"; I will probably have to get a 0.31.1 patch release out the window, and try to keep the master branch as quiet as possible right after a release. |
I stumbled upon this PR because I was interested in adding the feature as well. Thanks for putting in the effort to do this! I wonder if the current references to "pandoc" (especially in the documentation) should be changed to more explicitly reference "pandoc markdown", since pandoc itself is not a format, per se. |
Is it possible to reconsider allowing options to pandoc (either via If you are reluctant to add arbitrary flags, one option is to simply add |
I’m curious if you see utility in pandoc’s MD-to-Word functionality (what I admittedly have to use Pandoc for most at work) for Hugo sites. I could see some very cool COPE workflows for users who need to create PDF versions of content as well. I’ve been woefully absent in the Hugo world for the past few months. Thanks for your work on this. I might be an edge case, but I’m really excited about this feature! |
Documentation here: https://gohugo.io/content-management/formats/#additional-formats-through-external-helpers This is a refactor to inlude panadoc support, still with default arguments - Hugo version 0.32 and higher. |
Ah, it looks like you dropped this feature from the PR:
Well I was actually very much looking forward to seeing that, for passing custom asciidoc default arguments. This is a valuable improvement (for asciidoc users).
Yes I need this / would like to see this.
This is a similar / same reasons why asciidoctor users also need this @betaveros do you still want to make a new PR for the |
Hello, For my usecase, I certainly see value in this feature, because I would like to be able to pass options to asciidoctor like
|
I've run into this as well - need to customize args passed to asciidoctor - attributes, plugins etc and right now there's no way to do it short of putting everything in each asciidoc file Also, is something like PR 4310 planned? It doesn't say why it was closed (just points to this issue) |
@shawnohare Re your #4060 (comment) I use org-mode. So I pass I think that inferring |
This would be certainly helpful! |
I use the following hack to get In my
In my project directory, create a file
You can adapt the flags to pandoc as per your requirement. |
Can this be averted by passing options to pandoc via the API, as opposed to shell invocation? |
I do not get the "pandoc format". For me the the format is markdown (or whatever) and pandoc is the renderer. Sounds for me like saying the "Safari format" when talking about rendering html. Is there a way to setup pandoc without changing file extension or page front end for all the site ? |
The answer by @adityam is great. It basically overrides Set the file
and set the file
A site can now be served with the Pandoc overrides by calling |
@rikhuijzer it would be nice if we didn't have to resort to bash trickery though. it's an answer, not a solution |
@RMStoica-zivver Why do you aim this critique to me exactly? Actually, I get that this is not a priority. I assume that a typical user would like to build the Hugo website via CI. The default Hugo Docker image does not include pandoc [1]. So you will always have to create a build image yourself with Pandoc and Hugo. Switching to the Netlify build image [2] is okay but you don't have any Pandoc extensions there, such as [1] https://hub.docker.com/r/jojomi/hugo/dockerfile |
@rikhuijzer it was not a critique of course, just a statement of fact - that the answer by @adytiam is a workaround, not a solution to the problem of hugo not passing arguments to pandoc or any other external renderer. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Recognize the Pandoc format under the file extension .pandoc or .pdc,
and shell out to pandoc as an external helper to format Pandoc content.
Add a configuration option, externalHelperArguments, that can be used to
override the additional arguments passed to external helpers.
Refactor out repeated code with external helpers. Change the error
output formatting. I did not see any of the external helpers print the
string "
<input>
" to represent stdin as a file; just prepending the filename to error output is more general and doesn't sacrifice that much in
terms of readability.