# -*- mode: Perl -*-
# /=====================================================================\ #
# |  wrapfig                                                            | #
# | 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;

#**********************************************************************
# New environment from package wrapfigure:
# \caption will handle refnums, etc.
DefEnvironment('{wrapfigure} [Number] {} [Dimension] {Dimension}',
  "<ltx:figure xml:id='#id' inlist='#inlist' float='#float'>"
    . "#tags"
    . "#body"
    . "</ltx:figure>",
  afterDigestBegin => sub {
    my $dir = ToString($_[1]->getArg(2));
    $_[1]->setProperty(float => ($dir eq 'r' ? 'right'
        : ($dir eq 'l' ? 'left'
          : undef))); },
  beforeDigest => sub { beforeFloat('figure'); },
  afterDigest  => sub { afterFloat($_[1]); });

DefEnvironment('{wraptable} [Number] {} [Dimension] {Dimension}',
  "<ltx:table xml:id='#id' inlist='#inlist' float='#float'>"
    . "#tags"
    . "#body"
    . "</ltx:table>",
  afterDigestBegin => sub {
    my $dir = ToString($_[1]->getArg(2));
    $_[1]->setProperty(float => ($dir eq 'r' ? 'right'
        : ($dir eq 'l' ? 'left'
          : undef))); },
  beforeDigest => sub { beforeFloat('table'); },
  afterDigest  => sub { afterFloat($_[1]); });

DefMacro('\WFclear', '\par');
DefRegister('\wrapoverhang' => Dimension(0));

#**********************************************************************

1;
