Multiline title, doesn't work

This method to get multiple lines in a title doesn’t work for me:

description = “”"
Here is a description
of the old page
*the* new page and some
“”"
in your theme you would have:

{{.Description | markdownify}}

I did:

+++
Title = “”“Changing the human condition
with Instinctive Raw Paleodiet”“”

With only one pair of quotation marks, multi-line is rejected. that means now it’s recognized at least. While it’s called upon in inject/content-before.html:

{{ if not .Params.notitle }}
<h1 id=“title”><p>{{ .Title | markdownify }}</p></h1>
{{ end }}

But the title still appears in one line. No difference. What did I miss ?

It would help if you added a link to a public repository or PR with your site. But I’m guessing it’s just a basic markdown issue. Markdown treats multiple lines of text as one paragraph. Adding a blank line between the lines of text will create new paragraphs.

Here’s for you

First, paragraph elements are not permitted within heading elements; HTML validation will fail.

Second, please read the “string” section of the TOML specification. The syntax will depend on whether you want a newline, a <br> element, or multiple paragraphs.

What an eyesore that syntax…
Neither that:

title = “”"
Roses are red
Violets are blue"“”

nor that:

title = “Roses are red\nViolets are blue”

or that:

title = “Roses are red\rViolets are blue”

or:

Title =“Roses are red \u000A Violets are blue”

work, no control character whatsoever has any effect ! Menu entries look the same.

Please read my previous post again, but this time read it carefully.

  1. You cannot place paragraph elements within heading elements.
  2. Please read the “string” section of the TOML specification.
  3. The syntax will depend on whether you want a newline, a <br> element, or multiple paragraphs.

Ok there are two issues. The multiple-lines headings AND the multiple-line menu entry. Yeah I forgot to display the two issues in my RP. But none of the solutions work for entry elements, I did read your post carefully ! With this:

title = “Roses are red\nViolets are blue”

I literally copied your site’s example and it’s not doing anything, \n is just ignored !

The syntax will depend on whether you want a newline, a <br> element, or multiple paragraphs.

Great, with menus I got NONE of these, whatever I try. So instead could you tell what do you see in menus with \n?

For headings,
work… but not for level 1 heading, which I apply this class to:

h1 {
display:flex;
margin-top:0;
align-items: center;
justify-content: center;
text-align:center;
height:6.4rem;
margin-left: -1vw;
margin-right:-1vw;
border: thin solid gold;
color: red;
}

for an unknown reason markdown is not rendered with this.

front matter

foo = '''
This is line 1.\
This is line 2.
'''

template

{{ .Params.foo | $.Page.RenderString }}

rendered

This is line 1.<br>
This is line 2.

That solved my menu entry issue, thanks !
I understand Renderstring (I could not have predicted it though, does it really make sense for rendering not be automatic ?) but the triple single quotes, wtf ? It wasn’t in the toml specification, right ?


works in headings, all of them, great. But do you happen to know why &#x000d or &#x000a (or any control character I presume) aren’t rendered in headings ? They’re SEEN since removing “| safehtml” show the code it generates, but it’s not displayed. Nor does traditional trailing \ work.

Yes, it does. The field or variable may or may not contain markdown. The template author has to make that determination.

Yes, it is. That’s why I asked you to read carefully.

Yes, it does, if the string is passed through .Page.RenderString. Make sure you are viewing the generated HTML (view source in your browser with Ctrl + U).

Regarding your other questions:

  • &#x000d; is a carriage return (no line feed) so it won’t be visbile

  • &#x000a; works as expected, but you need to view source in your browser to see the newline

    front matter

    +++
    foo = "Line 1&#x000a;Line 2"
    +++
    

    template

    {{ .Params.foo | .Page.RenderString }}
    

    rendered HTML (view source in your browser)

    Line 1
    Line 2
    

A newline character is not the same thing as a <br> element in HTML.

so it was “Multi-line literal strings”. But how was I supposed to understand that “there is no escaping whatsoever. All other content between the delimiters is interpreted as-is without modification.” meant control characters would be rendered as I hoped, and not as literal “\t” “\n” etc ? Give me a break…
This {{ $title = .Title | $.Page.RenderString }} produces my menu entry. But this: Title = "Cooking:\u000&the original sin" shows only a space instead of a newline.

The field or variable may or may not contain markdown. The template author has to make that determination.

Sorry, yes, I was wrong. However \ should work for headings by default, since it’s a .md file. And it still doesn’t, only
works.

This render-heading.html:

{{ if eq .Level 1 }}
<h1 id=title>
{{ .Text | .Page.RenderString }}
</h1>
{{ else }}
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
{{ .Text | .Page.RenderString }}
<a class="anchor" href="#{{ .Anchor | safeURL }}">#</a>
</h{{ .Level }}>
{{ end }}

fails because Error: Error building site: "/home/drm/WEBSITE/content/docs/Autres_cachés/purity_spirale.md:1:1": "/home/drm/WEBSITE/themes/hugo-book/layouts/_default/_markup/render-heading.html:3:18": execute of template failed: template: _default/_markup/render-heading.html:3:18: executing "_default/_markup/render-heading.html" at <.Page.RenderString>: error calling RenderString: text is already rendered, repeating it may cause infinite recursion.
Without, trailing \ are not recognized.

Ah… I got it, the hexcode does produce the a newline is the html code, but html itself doesn’t render newline as such.
Obviously the user couldn’t care less about what appears in the source, he wants the damn specially included unicode character to be displayed as is, any other behavior is stupid. &#x000a, the newline character, wherever I put it. If the language or tool or whatnot doesn’t get than a newline character means newline, it makes no sense.

A newline character is not the same thing as a <br> element in HTML.

Yes, but I don’t care nor should I. hugo/goldmark should translate these characters in the corresponding html elements to show what they’re meant to show.

I stop my rant, I have what I wanted, thanks.

When you rant, others on this forum are less inclined to provide assistance in the future.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.