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

Support for custom content format renderers and transformations #7921

Open
rgov opened this issue Nov 3, 2020 · 5 comments
Open

Support for custom content format renderers and transformations #7921

rgov opened this issue Nov 3, 2020 · 5 comments
Labels
Milestone

Comments

@rgov
Copy link

rgov commented Nov 3, 2020

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 invoking dot, 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?

  1. 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).

  2. 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:

  1. Parse file content with Goldmark
  2. Generate HTML
  3. Perform shortcode expansion
  4. Output

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.

@rgov rgov added the Proposal label Nov 3, 2020
@rgov
Copy link
Author

rgov commented Nov 3, 2020

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.

@rigtorp
Copy link

rigtorp commented Nov 17, 2020

This is related to #7765 Add support for generating figures and diagrams.

@bep bep modified the milestones: v0.79, v0.80 Nov 27, 2020
@bep bep modified the milestones: v0.80, v0.81 Jan 2, 2021
@bep bep modified the milestones: v0.81, v0.82 Feb 19, 2021
@bep bep modified the milestones: v0.82, v0.83 Mar 21, 2021
@bep bep modified the milestones: v0.83, v0.84 May 1, 2021
@bep bep modified the milestones: v0.84, v0.85 Jun 18, 2021
@bep bep modified the milestones: v0.85, v0.86 Jul 5, 2021
@bep bep modified the milestones: v0.86, v0.87, v0.88 Jul 26, 2021
@bep bep modified the milestones: v0.88, v0.89 Sep 2, 2021
@bep bep modified the milestones: v0.89, v0.90 Nov 2, 2021
@bep bep modified the milestones: v0.90, v0.91.0 Dec 13, 2021
@bep bep added this to the v0.115.0 milestone 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
@BBaoVanC
Copy link

BBaoVanC commented Nov 10, 2023

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.

@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

6 participants