Skip to content

Allow output formats to get the published output of output formats earlier in the chain #14026

@bep

Description

@bep

So, me implementing #14025 was triggered by this tweet: https://x.com/tobi/status/1973397055969104109

While the above should now be both possible and practical, it got me thinking:

  • What if the outputs are defined as [html, markdown]
  • Subsequent output format renderings have access to the io.Reader of any previously rendered output format. A io.Reader for performance, but it should also be possible to turn into a string once with {{ $s := $myreader | string }}

With the transform.HTMLToMarkdown as an example in layouts/all.markdown:

{{ witn .Site.Published "html" }}
   {{ transform.HTMLToMarkdown . | safeHTML }}
{{ end }}

The above assumes that transform.HTMLToMarkdown gets rid of any irrelevant markup.

Note that I'm not totally sure how useful this is, but 'm jotting it down while it's fresh.

The only real challenge with the above that I can think of is with templates.Defer, but is sounds doable. We have already an issue with the output minifier being run before we do defer replacements, so a cleanup in this department should be done anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions