Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

comments - 你如何在YAML中阻止评论?(How do you do block comments in YAML?)

如何评论YAML中的一行线?

  ask by Thierry Lam translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

(YAML支持内联注释,但不支持块注释。)

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 :

(与维基百科的 JSON比较:)

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.

(语法差异很微妙,在实践中很少出现:JSON允许扩展字符集,如UTF-32,YAML需要在分隔符之后的空格,如逗号,等号和冒号,而JSON不需要,并且一些非标准的JSON实现将语法扩展为包括Javascript的/* ... */评论。)

Handling such edge cases may require light pre-processing of the JSON before parsing as in-line YAML.

(在解析为内联YAML之前,处理此类边缘情况可能需要对JSON进行轻度预处理。)

# If you want to write
# a block-commented Haiku
# you'll need three pound signs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...