Hard linebreaks not working in md


#1

As I want hard linebreaks between paragraphs in my markdown files, I added [blackfriday] extensions = ["hardLineBreak"] to config.toml. But, there are no linebreaks rendered in the html. I restarted hugo server and rebuild the site, but no effect.


#2

Did you add it to the configuration file or the front matter of your markdown?

+++
[blackfriday]
  extensions = ["hardLineBreak"]
+++

The docs are a bit confusing - the override should be in the markdown.

It’s possible to set some options for Markdown rendering in a content’s front matter as an override to the BlackFriday rendering options set in your project configuration.

#3

Does this mean one needs to add this option to the frontmatter? Adding it to config.toml is not enough? If so, it seems a bit weird adding config stuff to content files…
How would one write this in yaml?


#4

Yes, you must add it to the front matter. I only use TOML, so I can’t help with the YAML equivalent.


#5

Hmm, is there a reason we cannot just have a global setting? (Haven’t figured out yet how to express this setting in YAML.


#6

Try https://gohugo.io/commands/hugo_convert/


#7

@artelse This worked fine for me in my config.toml

[blackfriday]
    extensions = [hardLineBreak]

This should work across the entire site, although @michael_henderson is right that anything in your front matter will override anything you set in your global/site config. Cheers.


#8

You’re right, it does. I’m not sure why it didn’t seem to earlier. Thanks :slightly_smiling:


#9

@rdwatters that’s what I would expect, but in my case it refuses to insert line breaks. I also tried your variation to omit "" around the setting, but that is not allowed of course. So yeah… any ideas how to kick Hugo into expected behavior?


#10

I can’t reproduce this behavior @artelse. Can you tell me a bit more about your machine, Hugo version, etc.

(And ignore the lack of punctuation from my previous comment; I need to stop responding on my phone.)


#11

@rdwatters Hugo Static Site Generator v0.19 darwin/amd64 BuildDate: 2017-02-27T12:36:32+01:00 on macOS 10.12.3. Line endings are 0x0A standard LF. Any other info that can be helpful?


#12

@rdwatters @michael_henderson It appears to be a CSS issue. The CSS framework I use collapsed all margins and paddings on the p element to zero. Thanks for the help!


#13

Cool. Did you check your inspector? The hard line breaks should related to inserting <br/> independent of the CSS…just double checking.

For future users, would you mind please adding [SOLVED] to the thread title? Cheers.


#14

Oh, <br/>s have not been inserted… back to the problem then…


#15

I’m still not able to recreate this issue. Do you happen to have a repo I can look at for local testing please?


#16

Note that the blackfriday config can live in both site config and page front matter (page settings will override site). I did it this way before we had multi language, as I needed parts of my site with angled quotes (Norwegian).


#17

@rdwatters no repo, am working locally. It shouldn’t matter I am working in my own theme stuff does it? config.toml should get the linebreaks working. One other thing, I have Hugo binary not globally installed.


#18

No it shouldn’t. I only ask because I can’t recreate your issue locally and I too am working with Hugo on macOS. I wanted to see about pulling your repo and running it locally for debugging purposes. I feel like there is something else missing here…


#19

Interestingly, when I run hugo --verbose the first line doesn’t show what config file is loaded:
INFO 2017/03/20 23:44:23 Using config file:
One would think it doesn’t see the config file, but I can use site variables like .Site.Title and they are rendered just fine. So indeed something is wrong here.


#20

I’m on macOS, too. It’s working in both the front matter and the config.toml file.

<p>first line.<br />
second line.<br />
fourth line.</p>