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

Configure external helpers via output formats #6089

Open
florisdf opened this issue Jul 16, 2019 · 12 comments
Open

Configure external helpers via output formats #6089

florisdf opened this issue Jul 16, 2019 · 12 comments
Labels
Milestone

Comments

@florisdf
Copy link

florisdf commented Jul 16, 2019

Hi,

The support of pandoc adds many options to possible output formats for Hugo. However, it is now limited to html output. I guess an incredible amount of flexibility would be added when external helpers, like pandoc, can be configured via the output formats configuration, e.g.

[mediaTypes]
  [mediaTypes."text/tex"]
    suffixes = ["tex"]
    
[outputFormats]
  [outputFormats.TeX]
    mediaType = "text/tex"
    helper = "pandoc"
    helperArgs = ["-t latex"]

This would make for a hassle-free way to generate PDF versions of web pages.

Or is this beyond the scope of Hugo?

@bep bep added the Proposal label Jul 17, 2019
@bep bep added this to the v0.57 milestone Jul 17, 2019
@bep
Copy link
Member

bep commented Jul 17, 2019

So your general idea is great. We should definitively connect the "content renderer" (let us worry about the terms (as used in the config struct) later, but the "helper" is not great).

  • We currently have a one-to-many from output format to "content renderer", using the extension to detect ad => asciidoc etc. We may need a way to express that here as well.
  • Currently we use always render with a layout (using the output format as one of the lookup keys); in your example I assume you don't want that. So we could add a noLayout flag, meaning just write .Content to disk.

Also, I'm not sure we can/would want to allow passing on arbitrary flags to helpers. We have no way to support everything and it has a lot of unknowns in the security department (pandoc may have a -exec flag for what I know).

@kaushalmodi @regisphilibert and gang may chime in with their view on this topic.

@regisphilibert
Copy link
Member

I'll go even though I might be missing something.

Not sure how this would work?

In the given example will Hugo load the pandoc Go Module itself? If so, how shall we install it? npm?
If so can't we already have hugo publish the file as is (template file: .Content) and let webpack handle the PDF conversion or else?

@bep
Copy link
Member

bep commented Jul 17, 2019

@regis Hugo already supports Pandoc.

@florisdf
Copy link
Author

florisdf commented Jul 17, 2019

@bep It might be an idea to use the suffix of the destination file to determine the output format for the renderer? In my example, since the destination has suffix ".tex", hugo can use pandoc as it supports TeX output. Eventually, one could specifically configure the renderer in the config file if the default doesn't suit.

Also, I think the current approach of determining the renderer based on the suffix of the content file conflicts with the idea of separating "form" and "content". Determining the renderer/output format based on the output file makes more sense, in my opinion, supposing that all renderers support a similar markdown dialect.

Finally, I think a layout file is still useful for other output formats apart from html. For LaTeX, it could contain something like

\documentclass[12pt, a4]{article}
\usepackage[utf8]{inputenc}
 
\title{ {{ .Title }} }
\date{ {{ .Date }} }

\begin{document}
{{ .Content }}
\end{document}

This would then be saved in a file like layouts/_default/single.tex so the hugo lookup rules would be just the way they are now.

@bep bep modified the milestones: v0.57, v0.58 Jul 31, 2019
@bep bep modified the milestones: v0.58, v0.59 Aug 13, 2019
@bep bep modified the milestones: v0.59, v0.60 Sep 6, 2019
@bep bep modified the milestones: v0.60, v0.61 Oct 21, 2019
@bep bep modified the milestones: v0.61, v0.62, v0.63 Nov 25, 2019
@bep bep modified the milestones: v0.63, v0.64 Dec 11, 2019
@bep bep modified the milestones: v0.64, v0.65 Jan 22, 2020
@bep bep modified the milestones: v0.65, v0.66 Jan 30, 2020
@bep bep modified the milestones: v0.66, v0.67 Mar 2, 2020
@bep bep modified the milestones: v0.67, v0.68 Mar 9, 2020
@bep bep modified the milestones: v0.68, v0.69 Mar 20, 2020
@bep bep modified the milestones: v0.113.0, v0.115.0 Jun 13, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants