Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-line string as part of sequence

Tags:

syntax

yaml

I can't figure out how to use a multi-line string as part of a yaml sequence:

foo:   - bar   - bar2   - > super duper long  string that I would like  to have on multiple lines   - Another item 

Is it possible?

like image 294
Nepoxx Avatar asked Oct 11 '17 19:10

Nepoxx


People also ask

Can a string be multiple lines?

Raw StringsThey can span multiple lines without concatenation and they don't use escaped sequences. You can use backslashes or double quotes directly.

How do you turn a string into multiple lines?

Creating a multiline string in Go is actually incredibly easy. Simply use the backtick ( ` ) character when declaring or assigning your string value. str := `This is a multiline string.

How pass multi line string in YAML?

By default, line breaks are replaced by space characters for consecutive non-empty lines: String key = parseYamlKey("folded. yaml", "key"); assertEquals("Line1 Line2 Line3", key);

What character is used to indicate that you are using a multi line string where the whitespace and line breaks should be preserved?

Use | if you want those linebreaks to be preserved as \n (for instance, embedded markdown with paragraphs).


1 Answers

If you want to use a folded scalar:

foo:   - bar   - bar2   - >      super duper long      string that I would like      to have on multiple lines   - Another item 

Note that there may not be content on the line of the folded scalar's header (the line with the >).

Alternatively, you can just use a plain scalar:

foo:   - bar   - bar2   - super duper long     string that I would like     to have on multiple lines   - Another item 
like image 163
flyx Avatar answered Sep 17 '22 11:09

flyx