# -*- mode: Perl -*-
# /=====================================================================\ #
# |  caption.sty                                                        | #
# | Implementation for LaTeXML                                          | #
# |=====================================================================| #
# | 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;

# Basically all of this is ignorable (other than needing the macros defined).
# In principle, we could make use of some of the fonts...
#RequirePackage('ragged2e');
#RequirePackage('keyval');

DefMacro('\captionsetup[]{}', Tokens());

DefMacro('\DeclareCaptionStyle{}[]{}',        Tokens());
DefMacro('\DeclareCaptionLabelFormat{}{}',    Tokens());
DefMacro('\DeclareCaptionLabelSeparator{}{}', Tokens());

DefMacro('\DeclareCaptionFont{}{}',          Tokens());
DefMacro('\DeclareCaptionFormat{}{}',        Tokens());
DefMacro('\DeclareCaptionJustification{}{}', Tokens());
DefMacro('\DeclareCaptionOption{}{}',        Tokens());
DefMacro('\DeclareCaptionPackage{}',         Tokens());

DefMacro('\bothIfFirst{}{}', sub {
    my ($gullet, $first, $second) = @_;
    ($first->unlist ? ($first->unlist, $second->unlist) : ()); });

DefMacro('\bothIfSecond{}{}', sub {
    my ($gullet, $first, $second) = @_;
    ($second->unlist ? ($first->unlist, $second->unlist) : ()); });

DefMacro('\AtBeginCaption{}',       Tokens());
DefMacro('\AtEndCaption{}',         Tokens());
DefMacro('\ContinuedFloat',         Tokens());
DefMacro('\ProcessOptionsWithKV{}', Tokens());

DefMacro('\captionfont', Tokens());
DefMacro('\captionsize', Tokens());

DefRegister('\captionparindent'  => Dimension(0));
DefRegister('\captionindent'     => Dimension(0));
DefRegister('\captionhangindent' => Dimension(0));
DefRegister('\captionmargin'     => Dimension(0));
DefRegister('\captionwidth'      => Dimension(0));

DefMacro('\caption',
  '\lx@donecaptiontrue
 \@ifundefined{@captype}
    {\@@generic@caption}
    {\@ifstar{\@scaption}{\expandafter\@caption\expandafter{\@captype}}}');
DefMacro('\@scaption {}', '\@@caption{#1}');

# This is a horrible thing that fakes a caption anywhere.
# It isn't necessarily in a figure or any float, so it can't really match our schema
DefMacro('\captionof', '\@ifstar{\@scaptionof}{\@captionof}');
DefMacro('\@captionof {}[]{}',
  '\GenericInfo{\string\captionof}{\space will not generate proper caption or list of #1s}'
    . '{\let\@@toccaption\@gobble\let\@@caption\@fake@@caption\let\@tag\@fake@tag'
    . '\def\@captype{#1}\@caption{#1}[#2]{#3}}');
DefMacro('\@scaptionof {}{}',
  '\GenericInfo{\string\captionof}{\space will not generate proper caption or list of #1s}'
    . '{\let\@@caption\@fake@@caption'
    . '\def\@captype{#1}\@scaption{#2}}');
DefConstructor('\@fake@tag[][]{}',
  "?#3(<ltx:text class='ltx_tag'>#1#3#2</ltx:text>)()");
DefConstructor('\@fake@@caption{}', "<ltx:block class='ltx_caption'>#1</ltx:block>");

DefMacro('\clearcaptionsetup',    Tokens());
DefMacro('\rotcaption',           Tokens());
DefMacro('\showcaptionsetup[]{}', Tokens());

1;
