baseURL = "http://example.org/"
languageCode = "en-us"
title = "Test Site"
This markdown:
This line has 2 spaces after the period.
This line has nothing after the period.
This line has a backslash after the period.\
This line has nothing after the period.
This line has nothing after the period.
Produces this HTML:
<p>
This line has 2 spaces after the period.<br>
This line has nothing after the period.
This line has a backslash after the period.<br>
This line has nothing after the period.
This line has nothing after the period.
</p>
If I add this to config.toml
[markup.goldmark.renderer]
hardWraps = true
The same markup produces this HTML:
<p>
This line has 2 spaces after the period.<br>
This line has nothing after the period.<br>
This line has a backslash after the period.<br>
This line has nothing after the period.<br>
This line has nothing after the period.
</p>
I’m not sure what you’re doing differently. Perhaps your editor is configured to strip trailing spaces from each line upon save.
You could setup your IDE to NOT remove whitespace in markdown files. Mine (IntelliJ) can do that
Other than that: adding three br’s looks a lot like you are trying to add a bottom margin to something. That is task of the “display” part of your website and this is done in CSS. Quite easy with margin-bottom: 1rem; for instance (change the 1rem).
The CommonMark specification allows you to insert hard breaks with either (a) two or more spaces at the end of a line, or (b) a blackslash (\). Spaces at the beginning of a line are ignored.
My IDE does not remove any whitespace
Not exactly, I just need one more line break in a longer article to get a bit more space and improve the readability.
git clone --single-branch -b hugo-forum-topic-32049 https://github.com/jmooring/hugo-testing hugo-forum-topic-32049
cd hugo-forum-topic-32049
hugo server
My final solution is now to create a custom raw-html shortcode which contains only {{ .Inner }} that I use like this: {{< raw-html >}}<br>{{< / raw-html >}}
<p>
Foo
<br>
</p>
<h1 id="title">Title</h1>
<p>
<br><br><br>
Bar
</p>
layouts/shortcodes/br.html
{{- $msg := "The optional argument passed to the %s shortcode must be an integer greater than or equal to zero. See %s" -}}
{{- if ne 0 (.Get 0) -}}
{{- with .Get 0 -}}
{{- if eq (printf "%T" .) "int" -}}
{{- if lt . 0 -}}
{{- errorf $msg $.Name $.Position -}}
{{- else -}}
{{- range seq 1 . -}}
<br>
{{- end -}}
{{- end -}}
{{- else -}}
{{- errorf $msg $.Name $.Position -}}
{{- end -}}
{{- else -}}
<br>
{{- end -}}
{{- end -}}