Another extra space after link issue

The case boils down to this example from a partial:

{{- "[google](http://google.com)." | markdownify -}}

Notice that there is no space after the link before the period.

The output has a newline:

<a href="http://google.com" target="_blank" rel="noreferrer noopener">google</a>
.

Which creates space before the period:
image

The full partial is:

{{- with readFile . -}}
	<div class="notes">
		{{- "[google](http://google.com )." | markdownify -}}
	</div>
{{- end -}}

I hard-coded an example text for simplicity. It usually is a . (bare period).

The renderer configuration is:

markup:
  goldmark:
    renderer:
      unsafe: true

hugo v0.133.1+extended linux/amd64

What do I miss? How do I get rid of the whitespace? It seems to be only present before punctuation characters.

Looks like your render hook adds an extra newline due to having a newline at end of file.

See this for example this topics:

As suggested either save the file without a trailing newline or use the proposed trick , by adding this code to the end of your render hook:

{{- /* trim whitspace */  -}}
1 Like

Thank you for the reply.

I did see these links. They come up as first suggestions when entering this question. The EOF newline answers do not seem applicable as (1) I am feeding a string to markdownify, no newline, which creates the space, (2) I checked, and the partial does not have the new line at its EOF. All template components already have the {{- ... -}}.

I shall still find out what the render hook is and what to add.

OK, fixed. Indeed, it was the theme’s

themes/<theme>/layouts/_default/_markup/render-link.html

Which had the new line at the end. Removing it resolved the issue.

Thanks again for the quick guidance!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.