[luatex] TinyYAML available in CTAN since October 2

Vít Novotný witiko at gmail.com
Sat Nov 20 17:38:29 CET 2021


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/mailman.4254.1633189642.2581.ctan-ann@ctan.org

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ý
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://tug.org/pipermail/luatex/attachments/20211120/d0f2781e/attachment.sig>


More information about the luatex mailing list.