Hugo

Hugo 0.60.1 shortcodes problem, probably a bug in goldmark or in hugo

Hi, all
I have a shortcodes in layouts/shortcodes/important.html

<div class=“center” >
<div class=“important”>
{{ .Inner | markdownify }}
</div>
</div>

in markdown the following code
{{% important %}}
abc
{{% /important %}}

show

acc
</div>

I dont know why the extra </div> show up while setting markup = glodmark in front matter, if I set markup to blackfriday or mmark, it works well.

I am experiencing problems as well.
part of my shortcode is:

    <div class="col-md-4">
      <div class="image pull-left">
{{ if isset .Params "url" }}      
          <a href="{{ .Params.url | relLangURL }}">
              <img src="{{.Site.BaseURL}}{{.Params.img}}" class="img-responsive" alt="">
          </a>
{{ else }}
          <img src="{{.Site.BaseURL}}{{.Params.img}}" class="img-responsive" alt="">
{{ end }}
      </div>
    </div>

The divs are rendered ok but the links (<a…) are rendered wrong. Wrapped in pre/code and html escaped:

    <div class="col-md-4">
      <div class="image pull-left">
<pre><code>      &lt;a href=&quot;/products/x62t&quot;&gt;
          &lt;img src=&quot;//localhost:1313//img/X62T.png&quot; class=&quot;img-responsive&quot; alt=&quot;&quot;&gt;
      &lt;/a&gt;
<p>&lt;/div&gt;

I did set unsafe to true in the markup.goldmark config. With ‘defaultMarkdownHandler = “blackfriday”’ everything is fine.

Look at https://discourse.gohugo.io/t/0-60-0-goldmark-html-indentation-in-partial-shortcode-wrapped-in-pre-code/22019/16

I Guess you can workaround if you flat your code without indentation

You link does not work for me but I saw the issue on github.

You are right. Flattening makes it work. However indenting helps me a lot so I hope there will be another solution in the future. For now I’ll stick with blackfriday.

Yes, flat code is one solution, also,
in config.toml
[markup]
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
and use "< " instead of “%” in markdown also works for goldmark. For example:

{{< myshortcode >}}
something .
{{< /myshorcode >}}