Skip to content

Instantly share code, notes, and snippets.

@Muthuuk
Forked from jonschlinkert/examples.md
Created May 17, 2020 17:20
Show Gist options
  • Select an option

  • Save Muthuuk/cca8136960de9242e57749a8f19ccccb to your computer and use it in GitHub Desktop.

Select an option

Save Muthuuk/cca8136960de9242e57749a8f19ccccb to your computer and use it in GitHub Desktop.

Revisions

  1. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 14 additions and 14 deletions.
    28 changes: 14 additions & 14 deletions examples.md
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,11 @@ name: Jon
    ``` yaml
    # YAML
    object:
    attributes:
    - attr1
    - attr2
    - attr3
    methods: [ getter, setter ]
    attributes:
    - attr1
    - attr2
    - attr3
    methods: [ getter, setter ]
    ```
    parses to this `json`

    @@ -23,9 +23,9 @@ parses to this `json`
    ``` yaml
    # YAML
    sonnet: |
    I wish I could
    write a poem
    but I can"t
    I wish I could
    write a poem
    but I can"t
    ```
    parses to:

    @@ -45,16 +45,16 @@ document: this is doc 2
    ```yaml
    name: SomeObject
    attributes:
    - attr1
    - attr2
    - attr3
    - attr1
    - attr2
    - attr3
    methods: [ getter, setter ]
    ---
    name: MyPrettyObject
    attributes:
    - attr1
    - attr2
    - attr3
    - attr1
    - attr2
    - attr3
    methods: [ getter, setter ]
    ```
    parses to:
  2. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion examples.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ object:
    - attr3
    methods: [ getter, setter ]
    ```
    to `json`
    parses to this `json`

    ``` json
    {"object": {"attributes": ["attr1", "attr2", "attr3"], ...
  3. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion examples.md
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ sonnet: |
    parses to:

    ``` json
    {"sonnet": "I wish I could\nwrite a poem\nbut I can"t\n"}
    {"sonnet": "I wish I could\nwrite a poem\nbut I can't\n"}
    ```

    ``` yaml
  4. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 12 additions and 21 deletions.
    33 changes: 12 additions & 21 deletions examples.md
    Original file line number Diff line number Diff line change
    @@ -17,20 +17,20 @@ object:
    to `json`

    ``` json
    {'object': {'attributes': ['attr1', 'attr2', 'attr3'], ...
    {"object": {"attributes": ["attr1", "attr2", "attr3"], ...
    ```

    ``` yaml
    # YAML
    sonnet: |
    I wish I could
    write a poem
    but I can't
    but I can"t
    ```
    parses to:

    ``` json
    {'sonnet': "I wish I could\nwrite a poem\nbut I can't\n"}
    {"sonnet": "I wish I could\nwrite a poem\nbut I can"t\n"}
    ```

    ``` yaml
    @@ -60,14 +60,14 @@ methods: [ getter, setter ]
    parses to:

    ``` json
    {'attributes': ['attr1', 'attr2', 'attr3'],
    'methods': ['getter', 'setter'],
    'name': 'SomeObject'}
    {'attributes': ['attr1', 'attr2', 'attr3'],
    'methods': ['getter', 'setter'],
    'name': 'MyPrettyObject'}
    {"attributes": ["attr1", "attr2", "attr3"],
    "methods": ["getter", "setter"],
    "name": "SomeObject"}
    {"attributes": ["attr1", "attr2", "attr3"],
    "methods": ["getter", "setter"],
    "name": "MyPrettyObject"}
    ```
    YAML also supports variables, or **repeated nodes**. The simplest explanation is that you define something as a variable by preceding it with ''&NAME value'' and you can refer to it with ''*NAME'' e.g.:
    YAML also supports variables, or **repeated nodes**. The simplest explanation is that you define something as a variable by preceding it with "&NAME value" and you can refer to it with "*NAME" e.g.:

    ``` yaml
    # YAML
    @@ -76,14 +76,5 @@ other_thing: *NAME
    ```
    Parses to:
    ``` json
    {'other_thing': 'foobar', 'some_thing': 'foobar'}
    ```









    {"other_thing": "foobar", "some_thing": "foobar"}
    ```
  5. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 89 additions and 0 deletions.
    89 changes: 89 additions & 0 deletions examples.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    adapted from [this blog](http://jessenoller.com/blog/2009/04/13/yaml-aint-markup-language-completely-different)

    ``` yaml
    # YAML
    name: Jon
    ```
    ``` yaml
    # YAML
    object:
    attributes:
    - attr1
    - attr2
    - attr3
    methods: [ getter, setter ]
    ```
    to `json`

    ``` json
    {'object': {'attributes': ['attr1', 'attr2', 'attr3'], ...
    ```

    ``` yaml
    # YAML
    sonnet: |
    I wish I could
    write a poem
    but I can't
    ```
    parses to:

    ``` json
    {'sonnet': "I wish I could\nwrite a poem\nbut I can't\n"}
    ```

    ``` yaml
    # YAML
    ---
    document: this is doc 1
    ---
    document: this is doc 2
    ...
    ```

    ```yaml
    name: SomeObject
    attributes:
    - attr1
    - attr2
    - attr3
    methods: [ getter, setter ]
    ---
    name: MyPrettyObject
    attributes:
    - attr1
    - attr2
    - attr3
    methods: [ getter, setter ]
    ```
    parses to:

    ``` json
    {'attributes': ['attr1', 'attr2', 'attr3'],
    'methods': ['getter', 'setter'],
    'name': 'SomeObject'}
    {'attributes': ['attr1', 'attr2', 'attr3'],
    'methods': ['getter', 'setter'],
    'name': 'MyPrettyObject'}
    ```
    YAML also supports variables, or **repeated nodes**. The simplest explanation is that you define something as a variable by preceding it with ''&NAME value'' and you can refer to it with ''*NAME'' e.g.:

    ``` yaml
    # YAML
    some_thing: &NAME foobar
    other_thing: *NAME
    ```
    Parses to:
    ``` json
    {'other_thing': 'foobar', 'some_thing': 'foobar'}
    ```









  6. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions yaml-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # YAML 1.1: Reference card
    ---
    ## Collection indicators:
    ### Collection indicators:
    ``` yml
    '? ' : Key indicator.
    ': ' : Value indicator.
    @@ -9,7 +9,7 @@
    '[]' : Surround in-line series branch.
    '{}' : Surround in-line keyed branch.
    ```
    ## Scalar indicators:
    ### Scalar indicators:
    ``` yml
    '''' : Surround in-line unescaped scalar ('' escaped ').
    '"' : Surround in-line escaped scalar (see escape codes below).
    @@ -20,12 +20,12 @@
    1-9 : Explicit indentation modifier ('|1' or '>2').
    # Modifiers can be combined ('|2-', '>+1').
    ```
    ## Alias indicators:
    ### Alias indicators:
    ``` yml
    '&' : Anchor property.
    '*' : Alias indicator.
    ```
    ## Tag property: # Usually unspecified.
    ### Tag property: # Usually unspecified.
    ``` yml
    none : Unspecified tag (automatically resolved by application).
    '!' : Non-specific tag (by default, "!!map"/"!!seq"/"!!str").
    @@ -34,34 +34,34 @@
    '!h!foo': Requires "%TAG !h! <prefix>" (and then means "<prefix>foo").
    '!<foo>': Verbatim tag (always means "foo").
    ```
    ## Document indicators:
    ### Document indicators:
    ``` yml
    '%' : Directive indicator.
    '---': Document header.
    '...': Document terminator.
    ```
    ## Misc indicators:
    ### Misc indicators:
    ``` yml
    ' #' : Throwaway comment indicator.
    '`@' : Both reserved for future use.
    ```
    ## Special keys:
    ### Special keys:
    ``` yml
    '=' : Default "value" mapping key.
    '<<' : Merge keys from another mapping.
    ```
    ## Core types: # Default automatic tags.
    ### Core types: # Default automatic tags.
    ``` yml
    '!!map' : { Hash table, dictionary, mapping }
    '!!seq' : { List, array, tuple, vector, sequence }
    '!!str' : Unicode string
    ```
    ## More types:
    ### More types:
    ``` yml
    '!!set' : { cherries, plums, apples }
    '!!omap': [ one: 1, two: 2 ]
    ```
    ## Language Independent Scalar types:
    ### Language Independent Scalar types:
    ``` yml
    { ~, null } : Null (no value).
    [ 1234, 0x4D2, 02333 ] : [ Decimal int, Hexadecimal int, Octal int ]
    @@ -74,7 +74,7 @@
    : >-
    Base 64 binary value.
    ```
    ## Escape codes:
    ### Escape codes:
    ``` yml
    Numeric : { "\x12": 8-bit, "\u1234": 16-bit, "\U00102030": 32-bit }
    Protective: { "\\": '\', "\"": '"', "\ ": ' ', "\<TAB>": TAB }
  7. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 34 additions and 12 deletions.
    46 changes: 34 additions & 12 deletions yaml-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,16 @@
    # YAML 1.1: Reference card
    ---
    Collection indicators:
    ## Collection indicators:
    ``` yml
    '? ' : Key indicator.
    ': ' : Value indicator.
    '- ' : Nested series entry indicator.
    ', ' : Separate in-line branch entries.
    '[]' : Surround in-line series branch.
    '{}' : Surround in-line keyed branch.
    Scalar indicators:
    ```
    ## Scalar indicators:
    ``` yml
    '''' : Surround in-line unescaped scalar ('' escaped ').
    '"' : Surround in-line escaped scalar (see escape codes below).
    '|' : Block scalar indicator.
    @@ -16,34 +19,50 @@ Scalar indicators:
    '+' : Keep chomp modifier ('|+' or '>+').
    1-9 : Explicit indentation modifier ('|1' or '>2').
    # Modifiers can be combined ('|2-', '>+1').
    Alias indicators:
    ```
    ## Alias indicators:
    ``` yml
    '&' : Anchor property.
    '*' : Alias indicator.
    Tag property: # Usually unspecified.
    ```
    ## Tag property: # Usually unspecified.
    ``` yml
    none : Unspecified tag (automatically resolved by application).
    '!' : Non-specific tag (by default, "!!map"/"!!seq"/"!!str").
    '!foo' : Primary (by convention, means a local "!foo" tag).
    '!!foo' : Secondary (by convention, means "tag:yaml.org,2002:foo").
    '!h!foo': Requires "%TAG !h! <prefix>" (and then means "<prefix>foo").
    '!<foo>': Verbatim tag (always means "foo").
    Document indicators:
    ```
    ## Document indicators:
    ``` yml
    '%' : Directive indicator.
    '---': Document header.
    '...': Document terminator.
    Misc indicators:
    ```
    ## Misc indicators:
    ``` yml
    ' #' : Throwaway comment indicator.
    '`@' : Both reserved for future use.
    Special keys:
    ```
    ## Special keys:
    ``` yml
    '=' : Default "value" mapping key.
    '<<' : Merge keys from another mapping.
    Core types: # Default automatic tags.
    ```
    ## Core types: # Default automatic tags.
    ``` yml
    '!!map' : { Hash table, dictionary, mapping }
    '!!seq' : { List, array, tuple, vector, sequence }
    '!!str' : Unicode string
    More types:
    ```
    ## More types:
    ``` yml
    '!!set' : { cherries, plums, apples }
    '!!omap': [ one: 1, two: 2 ]
    Language Independent Scalar types:
    ```
    ## Language Independent Scalar types:
    ``` yml
    { ~, null } : Null (no value).
    [ 1234, 0x4D2, 02333 ] : [ Decimal int, Hexadecimal int, Octal int ]
    [ 1_230.15, 12.3015e+02 ]: [ Fixed float, Exponential float ]
    @@ -54,9 +73,12 @@ Language Independent Scalar types:
    R0lG...BADS=
    : >-
    Base 64 binary value.
    Escape codes:
    ```
    ## Escape codes:
    ``` yml
    Numeric : { "\x12": 8-bit, "\u1234": 16-bit, "\U00102030": 32-bit }
    Protective: { "\\": '\', "\"": '"', "\ ": ' ', "\<TAB>": TAB }
    C : { "\0": NUL, "\a": BEL, "\b": BS, "\f": FF, "\n": LF, "\r": CR,
    "\t": TAB, "\v": VTAB }
    Additional: { "\e": ESC, "\_": NBSP, "\N": NEL, "\L": LS, "\P": PS }
    Additional: { "\e": ESC, "\_": NBSP, "\N": NEL, "\L": LS, "\P": PS }
    ```
  8. @jonschlinkert jonschlinkert revised this gist Mar 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yaml-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    %YAML 1.1 # Reference card
    # YAML 1.1: Reference card
    ---
    Collection indicators:
    '? ' : Key indicator.
  9. @jonschlinkert jonschlinkert created this gist Mar 15, 2013.
    62 changes: 62 additions & 0 deletions yaml-cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    %YAML 1.1 # Reference card
    ---
    Collection indicators:
    '? ' : Key indicator.
    ': ' : Value indicator.
    '- ' : Nested series entry indicator.
    ', ' : Separate in-line branch entries.
    '[]' : Surround in-line series branch.
    '{}' : Surround in-line keyed branch.
    Scalar indicators:
    '''' : Surround in-line unescaped scalar ('' escaped ').
    '"' : Surround in-line escaped scalar (see escape codes below).
    '|' : Block scalar indicator.
    '>' : Folded scalar indicator.
    '-' : Strip chomp modifier ('|-' or '>-').
    '+' : Keep chomp modifier ('|+' or '>+').
    1-9 : Explicit indentation modifier ('|1' or '>2').
    # Modifiers can be combined ('|2-', '>+1').
    Alias indicators:
    '&' : Anchor property.
    '*' : Alias indicator.
    Tag property: # Usually unspecified.
    none : Unspecified tag (automatically resolved by application).
    '!' : Non-specific tag (by default, "!!map"/"!!seq"/"!!str").
    '!foo' : Primary (by convention, means a local "!foo" tag).
    '!!foo' : Secondary (by convention, means "tag:yaml.org,2002:foo").
    '!h!foo': Requires "%TAG !h! <prefix>" (and then means "<prefix>foo").
    '!<foo>': Verbatim tag (always means "foo").
    Document indicators:
    '%' : Directive indicator.
    '---': Document header.
    '...': Document terminator.
    Misc indicators:
    ' #' : Throwaway comment indicator.
    '`@' : Both reserved for future use.
    Special keys:
    '=' : Default "value" mapping key.
    '<<' : Merge keys from another mapping.
    Core types: # Default automatic tags.
    '!!map' : { Hash table, dictionary, mapping }
    '!!seq' : { List, array, tuple, vector, sequence }
    '!!str' : Unicode string
    More types:
    '!!set' : { cherries, plums, apples }
    '!!omap': [ one: 1, two: 2 ]
    Language Independent Scalar types:
    { ~, null } : Null (no value).
    [ 1234, 0x4D2, 02333 ] : [ Decimal int, Hexadecimal int, Octal int ]
    [ 1_230.15, 12.3015e+02 ]: [ Fixed float, Exponential float ]
    [ .inf, -.Inf, .NAN ] : [ Infinity (float), Negative, Not a number ]
    { Y, true, Yes, ON } : Boolean true
    { n, FALSE, No, off } : Boolean false
    ? !!binary >
    R0lG...BADS=
    : >-
    Base 64 binary value.
    Escape codes:
    Numeric : { "\x12": 8-bit, "\u1234": 16-bit, "\U00102030": 32-bit }
    Protective: { "\\": '\', "\"": '"', "\ ": ' ', "\<TAB>": TAB }
    C : { "\0": NUL, "\a": BEL, "\b": BS, "\f": FF, "\n": LF, "\r": CR,
    "\t": TAB, "\v": VTAB }
    Additional: { "\e": ESC, "\_": NBSP, "\N": NEL, "\L": LS, "\P": PS }
    62 changes: 62 additions & 0 deletions yaml-cheatsheet.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    %YAML 1.1 # Reference card
    ---
    Collection indicators:
    '? ' : Key indicator.
    ': ' : Value indicator.
    '- ' : Nested series entry indicator.
    ', ' : Separate in-line branch entries.
    '[]' : Surround in-line series branch.
    '{}' : Surround in-line keyed branch.
    Scalar indicators:
    '''' : Surround in-line unescaped scalar ('' escaped ').
    '"' : Surround in-line escaped scalar (see escape codes below).
    '|' : Block scalar indicator.
    '>' : Folded scalar indicator.
    '-' : Strip chomp modifier ('|-' or '>-').
    '+' : Keep chomp modifier ('|+' or '>+').
    1-9 : Explicit indentation modifier ('|1' or '>2').
    # Modifiers can be combined ('|2-', '>+1').
    Alias indicators:
    '&' : Anchor property.
    '*' : Alias indicator.
    Tag property: # Usually unspecified.
    none : Unspecified tag (automatically resolved by application).
    '!' : Non-specific tag (by default, "!!map"/"!!seq"/"!!str").
    '!foo' : Primary (by convention, means a local "!foo" tag).
    '!!foo' : Secondary (by convention, means "tag:yaml.org,2002:foo").
    '!h!foo': Requires "%TAG !h! <prefix>" (and then means "<prefix>foo").
    '!<foo>': Verbatim tag (always means "foo").
    Document indicators:
    '%' : Directive indicator.
    '---': Document header.
    '...': Document terminator.
    Misc indicators:
    ' #' : Throwaway comment indicator.
    '`@' : Both reserved for future use.
    Special keys:
    '=' : Default "value" mapping key.
    '<<' : Merge keys from another mapping.
    Core types: # Default automatic tags.
    '!!map' : { Hash table, dictionary, mapping }
    '!!seq' : { List, array, tuple, vector, sequence }
    '!!str' : Unicode string
    More types:
    '!!set' : { cherries, plums, apples }
    '!!omap': [ one: 1, two: 2 ]
    Language Independent Scalar types:
    { ~, null } : Null (no value).
    [ 1234, 0x4D2, 02333 ] : [ Decimal int, Hexadecimal int, Octal int ]
    [ 1_230.15, 12.3015e+02 ]: [ Fixed float, Exponential float ]
    [ .inf, -.Inf, .NAN ] : [ Infinity (float), Negative, Not a number ]
    { Y, true, Yes, ON } : Boolean true
    { n, FALSE, No, off } : Boolean false
    ? !!binary >
    R0lG...BADS=
    : >-
    Base 64 binary value.
    Escape codes:
    Numeric : { "\x12": 8-bit, "\u1234": 16-bit, "\U00102030": 32-bit }
    Protective: { "\\": '\', "\"": '"', "\ ": ' ', "\<TAB>": TAB }
    C : { "\0": NUL, "\a": BEL, "\b": BS, "\f": FF, "\n": LF, "\r": CR,
    "\t": TAB, "\v": VTAB }
    Additional: { "\e": ESC, "\_": NBSP, "\N": NEL, "\L": LS, "\P": PS }