vdid
September 2, 2024, 6:30am
1
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:
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.
irkode
September 2, 2024, 6:52am
2
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
vdid
September 2, 2024, 7:52pm
3
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.
vdid
September 2, 2024, 8:02pm
4
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!
system
Closed
September 4, 2024, 8:03pm
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.