# -*- mode: Perl -*-
# /=====================================================================\ #
# |  keyval                                                             | #
# | Implementation of keyval for LaTeXML                                | #
# |=====================================================================| #
# | Thanks to Tom Wiesing <tom.wiesing@gmail.com>                       | #
# | Part of LaTeXML:                                                    | #
# |  Public domain software, produced as part of work done by the       | #
# |  United States Government & not subject to copyright in the US.     | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov>                        #_#     | #
# | http://dlmf.nist.gov/LaTeXML/                              (o o)    | #
# \=========================================================ooo==U==ooo=/ #
package LaTeXML::Package::Pool;
use strict;
use warnings;
use LaTeXML::Package;

InputDefinitions('keyval', type => 'sty', noltxml => 1)
  || Warn(":missing:keyval.sty Couldn't find keyval.sty");

# HOOK into define@key to make the latexml definitions as well
DefPrimitive('\define@key{}{}[]{}', sub {
    my ($stomach, $keyset, $key, $default, $code) = @_;

    $keyset = ToString($keyset);
    $key    = ToString($key);

    DefKeyVal($keyset, $key, '', ToString($default), code => $code);

    return; });

# \setkeys{keyset}{keyvals}
DefMacro('\setkeys{}', sub {
    my ($gullet, $keyset) = @_;
    my ($values) = ReadParameters($gullet, 'RequiredKeyVals:' . ToString($keyset));
    $values->setKeysExpansion; });

#======================================================================
1;
