'Hardlinebreak' setting in blackfriday is not adding a <br> tag

I like writing with

lots

of

line

breaks

I added “hardlinebreak” to my config.toml thinking it would add a
for every new line in the markdown file.

The config even seems to picks it up nicely
image

But when I go and build the site
https://i.imgur.com/Og8AtaT.png

I can add them manually with a backslash
Even if the way it does it is a little funky
https://i.imgur.com/8NJqMf2.png

I see there are similar posts to this one but they seemed to be caused by the funky windows newline character but that dosn’t apply to me.

In the layout I just drop in the {{ .Content }} without any messing with it.


On linux, hugo version 0.35

I’m not familiar with the subtleties of blackfriday, but, sometimes markdown parsers will force a <br> if you use two spaces. If $ means space, something like:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.$$
$$
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.$$
$$
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Maybe try it?

That would be better than using the backslash thing. But I did try that and it still didn’t add line breaks.

I haven’t tried enabling that extension in config.toml, but it works when added to front matter.

Example

+++
title = "Hard line break (TOML)"
tags = ["blackfriday", "toml"]
draft = false
[blackfriday]
  extensions = ["hardLineBreak"]
+++

a
b
c

Above, _a_, _b_ and _c_ must appear on separate lines.
<p>a<br />
b<br />
c</p>

For more help, you’ll need to share your site source, especially the config.toml.

2 Likes

I did try that, but I seemed to get the same result except not showing up in the hugo config output.


The config.toml is pretty minimal I’ve tried moving the blackfriday block around but it dosn’t do anything. And as the config command seems to be showing that hugo sees it. I can’t imagine how it would be the problem.

baseURL = "https://www.example.com/"
languageCode = "en-us"
title = "Let Them Eat Cake"
ignoreFiles = [ "\\.mp4$", "\\.mov$", "\\.avi$" ]

[blackfriday]
    extensions = ["hardLineBreak"]

[params]
  email = "PBn@example.com"

  S3 = "https://PBn.s3host.com"
  box = "https://www.example.com/v"

I have tried using two different version of Hugo, the one that came with my package manager and the newest one.

An example of a front matter I would use on a post would be:

+++
date = 2018-02-04T15:45:00-08:00
title = "Title "
categories = ["misc"]
header = "yellowheader"
author = "PBn"
rating = ""
marquee = "The marquee is just a custom summery for the front page"
[blackfriday]
  extensions = ["hardLineBreak"]
+++
blah blah blah 

And the acutal single.html file:

{{ partial "header.html" . }}
	<main class="container">
		<article>
			<div class="{{ index .Params "header" | default "postheader" }}">
				<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
				{{ with .Params.author }}
						<h5> {{ . }} </h5>
				{{ end }}
				<h6><time>{{ .Date.Format "02.01.06 15:04" }}</time></h6>
			</div>
			<div class = "content">
				{{ .Content }}
			</div>
			<div>
				<ul id="tags">
					{{ range .Params.tags }}
					<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a> </li>
					{{ end }}
				</ul>
			</div>
			<div>
				{{ template "_internal/disqus.html" . }}
			</div>
		</article>

	</main>
{{ partial "sidebar.html" . }}
{{ partial "footer.html" . }}

The bones of the site are modeled on Blank

It is worth noting that if I create a new Blank hugo site on the same computer and turn hardlinebreaks on it will work. So something has to have changed I just have no idea what I did.

Ah - this is how a [blackfriday] per Page config is done. I didn’t got it from the docs - but now it’s clear…
:+1:

Blackfriday flags must be grouped under the blackfriday key and can be set on both the site level and the page level. Any setting on a page will override its respective site setting.

Thx a lot

1 Like

Hah, funny. I don’t use any blackfriday configuration in my personal sites. But while developing ox-hugo, and all the different test cases (250+ at the moment, thinking of wildest ways any user would set their post front-matter in Org files), I’ve learned so much about setting front-matter parameters, templating, debugging internal variables (1, 2), using page bundles, etc.

Even if someone is not using ox-hugo, they can at least look at the examples in this ox-hugo-generated test Markdown files dir.

1 Like