-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Support for custom content format renderers and transformations #7921
Comments
Pipelines were discussed in #3207 but the discussion focused on assets (images, etc.) not content. A similar proposal is to customize how external helpers are invoked to support different output formats (#6089). The proposal in this issue would be able to achieve this as well, if the output steps of the pipeline can be overridden (for example, to add an HTML to LaTeX step). Plugins have been discussed but the issue brought up is security. Since this is configured entirely by the user, and not by third-party templates or content, it doesn't have the same drawbacks as #796. (Though, if someone wished, they would be able to implement an exec shortcode for themselves using this proposal, by adding a custom transformation.) Also, by allowing for external transformation tools, they do not need to all be written in Go. This makes it more attractive than true plug-ins for people who are familiar with languages such as JavaScript or Python. |
This is related to #7765 Add support for generating figures and diagrams. |
I would love this feature, one example I can think of is making a markdown -> Gopher renderer, so I could make a Gopher version of my site automatically rendered from my markdown source. |
There are some kinds of transformations that I'd like to be able to perform on my content that are not possible or easy with shortcodes.
For instance, it is not currently possible to wrap each rendered section of a Markdown document from its
# heading
to its last paragraph in a<section>
tag, or to change how footnotes are rendered, or to embed a Graphviz diagram in my content file and have it rendered to an embedded SVG by invokingdot
, etc. These kinds of changes would require patching Hugo.Now that Hugo has the ability to execute external tools like Asciidoctor, why not make it more flexible so that users can provide their own content format renderers?
Hugo publishes a specification on how a renderer is invoked and how it should return rendered content (e.g., the body of the rendered content, and a list of anchors for the table of contents).
The user configures how the renderer is invoked, such as: the tool's path; the file extension for the content; whether to perform further shortcode expansion on the output.
(Rather than allow a complex configuration of command line arguments for an existing tool like Asciidoctor, the user would provide an adapter script.)
This extends nicely to supporting content pipelines (unrelated to existing asset pipelines). The default pipeline for
.md
files might look like this:If I want to customize this pipeline, I could use the same building blocks, and insert an external transformation (or multiple) that modifies the Markdown before it gets rendered by Goldmark, or before it renders to HTML, etc.
The text was updated successfully, but these errors were encountered: