Skip to content

[ANN] lyaml-6.0 released

Compare
Choose a tag to compare
@gvvaughan gvvaughan released this 27 Jul 01:00
· 230 commits to master since this release

Read and write YAML format files with Lua.

I am happy to announce release 6.0 of lyaml.

lyaml's home page is at http://github.com/gvvaughan/lyaml, and we have new LDoc generated API documentation at http://gvvaughan.github.io/lyaml for this release.

Noteworthy changes in release 6.0 (2015-07-27) [stable]

New Features

  • lyaml.load now correctly reads a !!bool tagged scalar from a YAML document, or an implicit bool value, according to the specification.

    %TAG ! tag:yaml.org,2002:
    ---
    truthy:
      - !bool Y
      - !bool y
      - !bool True
      - !bool "on"
    falsey:
      - !bool n
      - !bool OFF
      - !bool garbage
  • lyaml.load now correctly reads a !!float tagged scalar from a YAML document, or an implicit float value, according to the specification.

  • lyaml.load now correctly reads a !!int tagged scalar from a YAML document, or an implicit integer value, according to the specification.

  • lyaml.load now supports the !!merge key type according to the specification.

    - &MERGE { x: 1, y: 2 }
    - &OVERRIDE { x: 0, z: 1 }
    -
      << : [&MERGE, &OVERRIDE]
      z: 3

    The anchored tables remain in the document too, so this results in the following Lua table:

    {                           -- START_STREAM
      {                         -- START_DOCUMENT
        { x = 1, y = 2 },       -- MERGE
        { x = 0, z = 1 },       -- OVERRIDE
        { x = 1, y = 2, z = 3}, -- <<<
      }                         -- END_DOCUMENT
    }                           -- END_STREAM

Bug fixes

  • Multi-line strings were previously being dumped using single quotes which caused the dumped YAML to break.

    For example, { foo = "a\nmultiline\nstring" } would get dumped as:

    foo: 'a
    
    multiline
    
    string'

    Note the extra line-breaks in between each line. This also causes YAML parsing to fail (since the blank lines didn't have the expected indentation).

    This patch fixes the dump to use the YAML literal syntax for any multi-line strings so the same example gets dumped as:

    foo: |-
      a
      multiline
      string
  • lyaml.load now correctly reads the !!null tag in a YAML document as an lyaml.null reference, identical to the "~" shorthand syntax, according to the specification.

Incompatible Changes

  • lyaml.load now takes a table of options as an optional second argument, not a simple boolean to determine whether all documents should be returned from the stream. For now, a true second argument will be converted to the modern equivalent:

    lyaml.load (document, { all = true })
  • lyaml.dump now takes a table of options as an optional second argument, not an initial table of anchors. For now, a second argument without any new API keys will be converted to the modern equivalent:

    lyaml.dump (t, { anchors = arg2 })

Install it with LuaRocks, using:

luarocks install lyaml 6.0