# -*- CPERL -*-
# /=====================================================================\ #
# |  hyperref                                                           | #
# | 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 LaTeXML::Package;

RequirePackage('url');

# Need some work here!?!?
DefMacro('\pdfcatalog{}','');
DefRegister('\pdfcompresslevel',Number(0));

# \href{url}{text}
DefConstructor('\href Semiverbatim  Semiverbatim',
	       "<ltx:ref href='#href'>#2</ltx:ref>",
	       properties=>sub { (href=>CleanURL(LookupValue('BASE_URL').ToString($_[1]))); } );

# \nolinkurl{url}
DefConstructor('\nolinkurl Semiverbatim','#1');

# \hyperbaseurl{url}
DefPrimitive('\hyperbaseurl Semiverbatim',sub { AssignValue(BASE_URL=>ToString($_[1])); });

# \hyperimage{url}
# ?
# \hyperdef{category}{name}{text}
DefConstructor('\hyperdef Semiverbatim Semiverbatim Semiverbatim',
	       "<ltx:anchor xml:id='#id'>#3</ltx:anchor>",
	       properties=>sub { (id=>ToString($_[1]).'.'.ToString($_[2])); } );
DefConstructor('\hyperref Semiverbatim Semiverbatim Semiverbatim Semiverbatim',
	       "<ltx:ref href='#href'>#4</ltx:ref>",
	       properties=>sub { (href=>CleanURL(LookupValue('BASE_URL').ToString($_[1])
						 .'#'.ToString($_[2]).'.'.ToString($_[3]))); } );

DefConstructor('\htmlref Semiverbatim  Semiverbatim',
	       "<ltx:ref labelref='#label'>#1</ltx:ref>",
	       properties=>sub { (label=>CleanLabel($_[2])); });

# \hyperlink{name}{text}
# \hypertarget{name}{text}
DefConstructor('\hyperlink Semiverbatim {}',
	       "<ltx:ref idref='#1'>#2</ltx:ref>");
DefConstructor('\hypertarget Semiverbatim {}',
	       "<ltx:anchor xml:id='#1'>#2</ltx:anchor>");

# Hmm...
DefMacro('\autoref Semiverbatim','\ref{#1}');

# Covered in LaTeX.pool, but non-ref character is ignored.
# \ref*{label} 
# \pageref*{label}

# \pdfstringdef{macroname}{texstring}
# ???
1;
