# -*- mode: Perl -*-
# /=====================================================================\ #
# |  nameref                                                           | #
# | 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;
RequirePackage('refcount');
RequirePackage('gettitlestring');
RequirePackage('ltxcmds');

# We want to display the actual "name" of the labeled structure (e.g. \section),
#   which is accessible via show="title"
#
# TODO: The star forms prevent nested double links.
DefConstructor('\nameref OptionalMatch:* Semiverbatim',
  "<ltx:ref ?#1(class='ltx_refmacro_nameref ltx_nolink')(class='ltx_refmacro_nameref')
    show='title' labelref='#label' _force_font='true'/>",
  properties => sub { (label => CleanLabel($_[2])); });

DefMacro('\Nameref', '\nameref');    #\def\Nameref#1{‘\nameref{#1}’ on page~\pageref{#1}}

DefMacro('\Sectionformat{}{}', '#1');

DefMacro('\Ref', '\ref');            # can be improved if "varioref.sty" is loaded?

DefMacro('\slabel', '\label'); #The original nameref docs say: "Overload an AMS LaTEX command, which uses \newlabel. Sigh!"

DefMacro('\vnameref', '\nameref');    # We can improve if we had \vpageref

1;
