编辑“YAML”
该编辑可以被撤销。 请检查下面的对比以核实您想要撤销的内容,然后发布下面的更改以完成撤销。
最后版本 | 您的文本 | ||
第1行: | 第1行: | ||
[[Image:yaml.gif|right|200px|thumb|YAML [[Logo]]]] | [[Image:yaml.gif|right|200px|thumb|YAML [[Logo]]]] | ||
'''YAML''',是一个可读性高,用来表达资料序列的编程语言。YAML参考了其他多种语言,包括:[[XML]]、[[C语言]]、[[Python]]、[[Perl]]以及[[电子邮件]] | '''YAML''',是一个可读性高,用来表达资料序列的编程语言。YAML参考了其他多种语言,包括:[[XML]]、[[C语言]]、[[Python]]、[[Perl]]以及[[电子邮件]]格式RFC2822。Clark Evans在[[2001年]]在首次发表了这种语言,另外Ingy döt Net与Oren Ben-Kiki也是这语言的共同设计者。目前已经有数种编程语言或脚本语言支援(或解析)这种语言。YAML是"YAML Ain't a Markup Language"(YAML不是一种置标语言)的递归缩写。在开发的这种语言时,YAML 的意思其实是:"Yet Another Markup Language"(仍是一种置标语言),但为了强调这种语言以数据做为中心,而不是以置标语言为重点,而用返璞词重新命名。 | ||
== YAML的功能 == | == YAML的功能 == | ||
第13行: | 第13行: | ||
date: 2007-08-06 | date: 2007-08-06 | ||
customer: | customer: | ||
given: Dorothy | given: Dorothy | ||
family: Gale | family: Gale | ||
items: | items: | ||
- part_no: A4786 | - part_no: A4786 | ||
descrip: Water Bucket (Filled) | descrip: Water Bucket (Filled) | ||
price: 1.47 | price: 1.47 | ||
quantity: 4 | |||
- part_no: E1628 | - part_no: E1628 | ||
descrip: High Heeled "Ruby" Slippers | descrip: High Heeled "Ruby" Slippers | ||
price: 100.27 | price: 100.27 | ||
quantity: 1 | quantity: 1 | ||
bill-to: &id001 | bill-to: &id001 | ||
street: | | street: | | ||
123 Tornado Alley | |||
Suite 16 | |||
city: East Westville | city: East Westville | ||
state: KS | state: KS | ||
ship-to: *id001 | ship-to: *id001 | ||
specialDelivery: > | specialDelivery: > | ||
Follow the Yellow Brick | Follow the Yellow Brick | ||
Road to the Emerald City. | Road to the Emerald City. | ||
Pay no attention to the | Pay no attention to the | ||
man behind the curtain. | man behind the curtain. | ||
... | ... | ||
</pre> | </pre> | ||
注意在YAML中,字符串不一定要用双引号标示。另外,在缩排中空白字符的数目并不是非常重要,只要相同阶层的元素左侧对齐就可以了(不过不能使用TAB字符)。这个文件的的顶层由七个键值组成:其中一个键值"items",是个两个元素构成的阵列(或称清单),这清单中的两个元素同时也是包含了四个键值的杂凑表。文件中重复的部分用这个方法处理:使用锚点(&)和参考(*)标签将"bill-to"杂凑表的内容复制到"ship-to"杂凑表。也可以在文件中加入选择性的空行,以增加可读性。在一个档案中,可同时包含多个文件,并用"——"分隔。选择性的符号"..."可以用来表示档案结尾(在利用串流的通讯中,这非常有用,可以在不关闭串流的情况下,发送结束讯号)。 | |||
== YAML语言的构成元素 == | == YAML语言的构成元素 == | ||
第88行: | 第88行: | ||
Who got on a bus bound for Ealing | Who got on a bus bound for Ealing | ||
#他搭上一班往伊靈的公車 | #他搭上一班往伊靈的公車 | ||
It said on the door | It said on the door | ||
#門上這麼說的 | #門上這麼說的 | ||
"Please don't spit on the floor" | "Please don't spit on the floor" | ||
#"請勿在地上吐痰" | #"請勿在地上吐痰" | ||
So he carefully spat on the ceiling | So he carefully spat on the ceiling | ||
#所以他小心翼翼的吐在天花板上 | #所以他小心翼翼的吐在天花板上 | ||
</pre> | </pre> | ||
根据设定,前方的引领空白符号(leading white space)必须排成条状,以便和其他资料或是行为(如范例中的缩排)明显区分。 | 根据设定,前方的引领空白符号(leading white space)必须排成条状,以便和其他资料或是行为(如范例中的缩排)明显区分。 | ||
第244行: | 第244行: | ||
<font name='times' size=10> | <font name='times' size=10> | ||
<p><i>"Three is always greater than | <p><i>"Three is always greater than | ||
two, even for large values of two"</i> | |||
</p><p> --Author Unknown </p></font> | |||
date: 2007-06-01 | date: 2007-06-01 | ||
</pre> | </pre> |