Dear all,

this is to let you know that CTAN includes the TinyYAML Lua library [1]
from the Apache APISIX project [2] since the release of Markdown 2.11.0
on October 2 [3].

 [1]: https://github.com/api7/lua-tinyyaml
 [2]: https://apisix.apache.org/
 [3]: 
https://ctan.org/ctan-ann/id/[email protected]

You can use the library in your work to parse YAML documents, see the
below example. A more complete demonstration of the library should
appear in TUGboat 43:1.

    $ cat > document.yaml
    title: 'This is a title: with a colon'
    authors:
    - Jane Doe
    - John Doe
    year: 2021
    abstract: |
      This is the abstract
      
      It contains two paragraphs.

    $ cat > script.lua
    local kpse = require('kpse')
    kpse.set_program_name('luatex')

    local ty = require('markdown-tinyyaml')
    local file = io.open('document.yaml', 'r')
    local text = file:read('*a')
    local data = ty.parse(text)

    print('The document is titled *'
       .. data.title .. '*.')
    print('It has ' .. #data.authors
       .. ' authors: '
       .. table.concat(data.authors, ' and ')
       .. '.')
    print('It was written one year after '
       .. (data.year - 1) .. '.')
    print('Its abstract starts with *'
       .. data.abstract:sub(0, 20) .. ' …*')

    $ texlua script.lua
    The document is titled *This is a title: with a colon*. It has
    2 authors: Jane Doe and John Doe. It was written one year after
    2020. Its abstract starts with *This is the abstract ...*

Best,
Vít Novotný

Attachment: signature.asc
Description: PGP signature

Reply via email to