Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you do block comments in YAML?

Tags:

comments

yaml

How do I comment a block of lines in YAML?

like image 514
Thierry Lam Avatar asked Feb 16 '10 21:02

Thierry Lam


People also ask

Can you put comments in YAML?

In order to add comments to a YAML file, you simply have to use the # (hashtag symbol) at the start of the line. For example, below is an example of one commented line in a YAML file.

Does YAML support multiline comment?

Block level comments in yaml Block comments are to comment the multiple lines. YAML has no support for block comments by default, You can use multiple inline comments with single-line syntax.


1 Answers

YAML supports inline comments, but does not support block comments.

From Wikipedia:

Comments begin with the number sign ( # ), can start anywhere on a line, and continue until the end of the line

A comparison with JSON, also from Wikipedia:

The syntax differences are subtle and seldom arise in practice: JSON allows extended charactersets like UTF-32, YAML requires a space after separators like comma, equals, and colon while JSON does not, and some non-standard implementations of JSON extend the grammar to include Javascript's /* ... */ comments. Handling such edge cases may require light pre-processing of the JSON before parsing as in-line YAML.

# If you want to write # a block-commented Haiku # you'll need three pound signs 
like image 52
Dolph Avatar answered Nov 09 '22 00:11

Dolph