Should a text file end with a newline, or not? At first glance this may seem like a tabs vs. spaces discussion, but the POSIX standard provides the following definitions:
-
Text File: A file that contains characters organized into zero or more lines.
-
Line: A sequence of zero or more non-newline characters plus a terminating newline character.
By definition, a text file without a newline has zero lines. It seems to me that every text file with content should have at least one line, which means it needs to end with a newline.
So, keep your editor configured as it is, and add this to the end of layouts/_default/_markup/render-link.html:
{{- /* This comment removes trailing newlines. */ -}}
Here’s a screen capture of my editor:
You are not the first to encounter this behavior, nor will you be the last. See:
- #6832: Single whitespace character after custom link template for Goldmark (Closed)
- #6949: render hook template render-link.html adds newline (Closed)
As these issues have been closed without action (implicitly “as designed”), I am disinclined to create a new issue.