Skip to content

v0.108.0

Compare
Choose a tag to compare
@bep bep released this 06 Dec 13:58

With Hugo v0.108.0 you can render standalone Markdown images without a surrounding paragraph. Both the HTML- and CommonMark-specification defines image as an inline element. For Markdown, this has meant that if you put an image on its own (not inlined in another paragraph), it would be wrapped in <p></p> tags, even if you provide your own Render Hook Template.

Now you can get by this annoyance by setting markup.goldmark.parser.wrapStandAloneImageWithinParagraph = false

[markup]
  [markup.goldmark]
    [markup.goldmark.parser]
      wrapStandAloneImageWithinParagraph = false
      [markup.goldmark.parser.attribute]
        block = true

In the above we have also enabled attribute support for Markdown blocks to illustrate another nice side effect of this; it's now possible to use Markdown attributes (e.g. CSS classes) on standalone images:

This is an inline image: ![Inline Image](/inline.jpg). Some more text.

![Block Image](/block.jpg)
{.blue}

The images in the above Markdown example would, given the hook template below, be rendered wrapped in a figure element with the blue CSS class applied in the latter example.

{{ if .IsBlock }}<figure class="{{ .Attributes.class }}"><img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" /></figure>
{{ else }}<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />{{ end }}

Two new fields are added to the render context passed to image render hooks:

Bug fixes

  • common/hugio: Fix multiWriteCloser.Close 5067775 @bep #10505
  • tpl/collections: Fix some index cases where the indices given is a slice and be more lenient with nil inputs d373774 @bep #10489

Improvements

Dependency Updates

  • deps: Upgrade github.com/bep/godartsass v0.15.0 => v0.16.0 f5b5b71 @bep
  • build(deps): bump github.com/getkin/kin-openapi from 0.109.0 to 0.110.0 50549c8 @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.16 to 0.15.18 535ea8c @dependabot[bot]
  • build(deps): bump golang.org/x/text from 0.4.0 to 0.5.0 8bbec42 @dependabot[bot]
  • build(deps): bump github.com/evanw/esbuild from 0.15.15 to 0.15.16 0bfa293 @dependabot[bot]
  • deps: Upgrade github.com/bep/godartsass v0.14.0 => v0.15.0 83080df @bep

Documentation