Josef-Friedrich / luakeys

LuaTeX package to parse key value options in Lua only, like keyval, kvsetkeys, kvoptions, xkeyval, pgfkeys but in Lua

Home Page:https://www.ctan.org/pkg/luakeys

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: lower-case keys

kalekje opened this issue · comments

Just curious if you or others are interested in a feature to make all key entries lowercase for case-insensitive usage? Eg.

luakeys.parse("TEST=Test") -> {test='Test'}

This should not be too difficult to implement

luakeys.parse(
  'TEST=Test',
  {
    converter = function (key, value, depth, current_table, root_table)
      if type(key) == 'string' then
        return key:lower(), value 
      end
      return key, value -- return key, value to change nothing
    end
  }
)

I have named the option case_insensitve_keys.

Breaking change in v0.6:

Instead of { case_insensitve_keys: true } you have to write { format_keys = { 'lower' } }

local result = luakeys.parse('KEY=value', { format_keys = { 'lower' } })
luakeys.debug(result) -- { key = 'value' }