...

Text file src/github.com/alecthomas/chroma/v2/lexers/testdata/yaml.actual

Documentation: github.com/alecthomas/chroma/v2/lexers/testdata

     1---  # document start
     2
     3# Comments in YAML look like this.
     4
     5comment_after_string_key: string value # comments can follow on same line
     6nested_comment: # this is a comment right next to a key
     7  sub_key: sub string value # sub comment
     8  inline_not_comment: string#hash #nospacecomment
     9  bool_comment: True # comment after bool
    10  int_comment: 123 # comment after int
    11  date_comment: 2010-11-12 # comment after date
    12  single_quote: 'single # quote string' # comment after single quote string
    13  double_quote: "double # quote string" # comment after double quote string
    14  key: no comment
    15
    16################
    17# SCALAR TYPES #
    18################
    19
    20# Our root object (which continues for the entire document) will be a map,
    21# which is equivalent to a dictionary, hash or object in other languages.
    22key: value
    23another_key: Another value goes here.
    24a_number_value: 100
    25scientific_notation: 1e+12
    26# The number 1 will be interpreted as a number, not a boolean. if you want
    27# it to be interpreted as a boolean, use true
    28boolean: true
    29boolean_different_case: False
    30boolean_yes: YES
    31null_value: null
    32key with spaces: value
    33# Notice that strings don't need to be quoted. However, they can be.
    34however: 'A string, enclosed in quotes.'
    35'Keys can be quoted too.': "Useful if you want to put a ':' in your key."
    36single quotes: 'have ''one'' escape pattern'
    37double quotes: "have many: \", \0, \t, \u263A, \x0d\x0a == \r\n, and more."
    38# UTF-8/16/32 characters need to be encoded
    39Superscript two: \u00B2
    40
    41# Multi-line flow scalars can be unquoted or quoted.
    42unquoted_scalar: Multiline scalar
    43                 with 'quotes' in the middle.
    44                 This is the last line.
    45single_quoted_scalar: 'Multiline single quoted scalar
    46                 with "quotes" in the middle
    47                 Last line'
    48double_quoted_scalar: "Multiline double quoted scalar
    49                 with 'quotes' in the middle
    50                 end"
    51# Multiple-line strings can be written either as a 'literal block' (using |),
    52# or a 'folded block' (using '>').
    53literal_block: |
    54    This entire block of text will be the value of the 'literal_block' key,
    55    with line breaks being preserved.
    56
    57    The literal continues until de-dented, and the leading indentation is
    58    stripped.
    59
    60        Any lines that are 'more-indented' keep the rest of their indentation -
    61        these lines will be indented by 4 spaces.
    62folded_style: >
    63    This entire block of text will be the value of 'folded_style', but this
    64    time, all newlines will be replaced with a single space.
    65
    66    Blank lines, like above, are converted to a newline character.
    67
    68        'More-indented' lines keep their newlines, too -
    69        this text will appear over two lines.
    70literal_block_with_strip_chomping: |-
    71    This entire block of text will be the value of the 'literal_block' key,
    72    with line breaks being preserved and the strip chomping indicator.
    73
    74    The literal continues until de-dented, and the leading indentation is
    75    stripped.
    76
    77        Any lines that are 'more-indented' keep the rest of their indentation -
    78        these lines will be indented by 4 spaces.
    79literal_block_with_keep_chomping: |+
    80    This entire block of text will be the value of the 'literal_block' key,
    81    with line breaks being preserved and the keep chomping indicator.
    82
    83    The literal continues until de-dented, and the leading indentation is
    84    stripped.
    85
    86a: |
    87  multiline literal
    88  line 2
    89b: >
    90  multiline: folded
    91  line 2
    92c: |-
    93  multiline # literal strip
    94  line 2
    95d: >-
    96  multiline folded strip
    97  line 2: test
    98
    99  # not a comment
   100   indented by 1
   101e: |+
   102  multiline literal keep
   103  line: 2
   104# this is a comment
   105f: >+
   106 multiline folded keep one space
   107 line 2
   108g: |
   109  multiline literal with only one line
   110h: test
   111
   112block_scalars_with_indent:
   113  a: |
   114    multiline literal
   115    line 2
   116  b: >
   117    multiline: folded
   118    line 2
   119  c: |-
   120      multiline # literal strip
   121      line 2 6 leading spaces
   122
   123  d: >-
   124    multiline folded strip
   125    line 2: test
   126    # not a comment
   127  e: |+
   128    multiline literal keep
   129    line: 2
   130  # this is a comment
   131  f: >+
   132    multiline folded keep
   133    line 2
   134  g: |
   135    multiline literal with only one line
   136  h: test
   137
   138####################
   139# COLLECTION TYPES #
   140####################
   141
   142# Nesting uses indentation. 2 space indent is preferred (but not required).
   143a_nested_map:
   144  key: value
   145  another_key: Another Value
   146  another_nested_map:
   147    hello: hello
   148
   149# Maps don't have to have string keys.
   1500.25: a float key
   151
   152# Keys can also be complex, like multi-line objects
   153# We use ? followed by a space to indicate the start of a complex key.
   154? |
   155  This is a key
   156  that has multiple lines
   157: and this is its value
   158
   159# YAML also allows mapping between sequences with the complex key syntax
   160# Some language parsers might complain
   161# An example
   162? - Manchester United
   163  - Real Madrid
   164: [2001-01-01, 2002-02-02]
   165
   166# Sequences (equivalent to lists or arrays) look like this
   167# (note that the '-' counts as indentation):
   168a_sequence:
   169  - Item 1
   170  - Item 2
   171  - 0.5  # sequences can contain disparate types.
   172  - Item 4
   173  - key: value
   174    another_key: another_value
   175  -
   176    - This is a sequence
   177    - inside another sequence
   178  - - - Nested sequence indicators
   179      - can be collapsed
   180
   181# Since YAML is a superset of JSON, you can also write JSON-style maps and
   182# sequences:
   183json_map: {"key": "value"}
   184json_seq: [3, 2, 1, "takeoff"]
   185and quotes are optional: {key: [3, 2, 1, takeoff]}
   186
   187#######################
   188# EXTRA YAML FEATURES #
   189#######################
   190
   191# YAML also has a handy feature called 'anchors', which let you easily duplicate
   192# content across your document. Both of these keys will have the same value:
   193anchored_content: &anchor_name This string will appear as the value of two keys.
   194other_anchor: *anchor_name
   195
   196# Anchors can be used to duplicate/inherit properties
   197base: &base
   198  name: Everyone has same name
   199
   200# The regexp << is called Merge Key Language-Independent Type. It is used to
   201# indicate that all the keys of one or more specified maps should be inserted
   202# into the current map.
   203
   204foo: &foo
   205  <<: *base
   206  age: 10
   207
   208bar: &bar
   209  <<: *base
   210  age: 20
   211
   212# foo and bar would also have name: Everyone has same name
   213
   214# YAML also has tags, which you can use to explicitly declare types.
   215explicit_string: !!str 0.5
   216# Some parsers implement language specific tags, like this one for Python's
   217# complex number type.
   218python_complex_number: !!python/complex 1+2j
   219
   220# We can also use yaml complex keys with language specific tags
   221? !!python/tuple [5, 7]
   222: Fifty Seven
   223# Would be {(5, 7): 'Fifty Seven'} in Python
   224
   225####################
   226# EXTRA YAML TYPES #
   227####################
   228
   229# Strings and numbers aren't the only scalars that YAML can understand.
   230# ISO-formatted date and datetime literals are also parsed.
   231datetime: 2001-12-15T02:59:43.1Z
   232datetime_with_spaces: 2001-12-14 21:59:43.10 -5
   233date: 2002-12-14
   234
   235# The !!binary tag indicates that a string is actually a base64-encoded
   236# representation of a binary blob.
   237gif_file: !!binary |
   238  R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
   239  OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
   240  +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
   241  AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
   242
   243# YAML also has a set type, which looks like this:
   244set:
   245  ? item1
   246  ? item2
   247  ? item3
   248or: {item1, item2, item3}
   249
   250# Sets are just maps with null values; the above is equivalent to:
   251set2:
   252  item1: null
   253  item2: null
   254  item3: null
   255
   256...  # document end

View as plain text