/usr/share/perl5/LaTeXML/Package/hyperref.sty.ltxml is in latexml 0.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | # -*- 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 warnings;
use LaTeXML::Package;
RequirePackage('url');
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Follow hyperref's manual.pdf
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# 3. Package Options
# Most (all?) options currently ignored; seen handling at end. But:
# * the various color ones should be used for styling
# * The metadata could be used to augment the RDFa
foreach my $option ( # 3.1 General Options
qw(draft final debug verbose implicit hypertexnames naturalnames
a4paper a5paper b5paper letterpaper legalpaper executivepaper setpagesizes),
# 3.2 Configuration Options
qw(raiselinks breaklinks pageanchor plainpages nesting),
# 3.3 Backend Drivers
qw(dvipdfm dvipdfmx dvips dvipsone dviwindo hypertex latex2html
nativepdf pdfmark pdftex ps2pdf tex4ht textures vtex vtexpdfmark xetex),
# 3.4 Extension Options
qw(extension hyperfigures backref pagebackref hyperindex
pageanchors plainpages hyperfootnotes encap linktocpage
breaklinks colorlinks linkcolor anchorcolor citecolor filecolor
menucolor pagecolor urlcolor frenchlinks),
# 3.5 PDF-specific display options
qw(bookmarks bookmarksopen bookmarksopenlevel bookmarksnumbered bookmarstype
CJKbookmarks pdfhighlight citebordercolor filebordercolor linkbordercolor
menubordercolor pagebordercolor urlbordercolor runbordercolor pdfborder),
# 3.6 PDF display and information options
qw(baseurl pdfpagemode pdfview pdfstartpage pdfstartview pdfpagescrop
pdfcenterwindow pdfdirection pdfdisplaydoctitle pdfduplex pdffitwindow
pdfmenubar pdfnewwindow pdfnonfullscreenpagemode pdfnumcopies
pdfpagelayout pdfpagelabels pdfpagetransition pdfpicktrackbypdfsize
pdfprintarea pdfprintclip pdfprintpagerange pdfprintscaling pdftoolbar
pdfviewarea pdfviewclip pdfprintpagerange pdfprintscaling
pdftoolbar pdfviewarea pdfviewclip pdfwindowui unicode),
# PDF display and information options that provide interesting Metadata
qw(pdftitle pdfauthor pdfsubject pdfcreator pdfproducer pdfkeywords pdflang)
) {
DeclareOption($option, undef); }
# \hypersetup{keyvals} configures various parameters,
# I think none matter much to latexml, but we do need to at least ignore it.
DefMacro('\hypersetup{}', '');
# for each pdf keyword, provide [property,(content|resource),datatype]
our %pdfkey_property = (
baseurl => '', # xmp:BaseURL ??
pdfauthor => ['dcterms:creator', 'content'],
pdfkeywords => ['dcterms:subject', 'content'], # & pdf:Keywords
pdflang => ['dcterms:language', 'content'],
pdfproducer => '', # pdf:Producer & xmp:CreatorTool
pdfsubject => ['dcterms:subject', 'content'],
pdftitle => ['dcterms:title', 'content'],
# Include hyperxmp's keywords, as well.
pdfauthortitle => '', # photoshop:AuthorsPosition
pdfcaptionwriter => '', # photoshop:CaptionWriter !?!?!?
pdfcopyright => ['dcterms:rights', 'content'], # & xmpRights:Marked
pdflicenseurl => ['cc:licence', 'resource'], # xmpRights:WebStatement
pdfmetalang => '', # dcterms:language ??
);
# date=>dcterms:date xmp:CreateDate xmp:ModifyDate xmp:MetadataDate ?
# document identifier => xmlMM:DocumentID
# file format => dcterms:format
# LaTeX file name => dcterms:source
# Digest & store the properties for generating RDFa
# This can appear anywhere in the doc, including preamble.
# Note also that the last value for any given key replaces previous ones! (eg.ONE author entry)
DefPrimitive('\hypersetup RequiredKeyVals', sub {
my ($stomach, $kv) = @_;
my $inpreamble = LookupValue('inPreamble');
AssignValue(inPreamble => 0);
my @pairs = $kv->getPairs;
while (@pairs) {
my ($key, $value) = (shift(@pairs), shift(@pairs));
AssignMapping('PDF.RDFa_properties', $key, Digest($value)); }
AssignValue(inPreamble => $inpreamble);
return; });
PushValue('@at@end@document', T_CS('\@add@PDF@RDFa@triples'));
DefConstructor('\@add@PDF@RDFa@triples', sub {
my ($document, $xproperty, $content) = @_;
if (my $root = $document->getDocument->documentElement) {
foreach my $key (LookupMappingKeys('PDF.RDFa_properties')) {
if (my $entry = ($pdfkey_property{$key})) {
my ($property, $object, $datatype) = @$entry;
my $value = LookupMapping('PDF.RDFa_properties', $key);
my $node = $document->openElementAt($root, 'ltx:rdf',
property => $property, $object => $value,
($datatype ? (datatype => $datatype) : ()));
# Must do directly; $document->setAttribute omits empty attributes
$node->setAttribute(about => '');
$document->closeElementAt($node); } } } });
# Need some work here!?!?
DefMacro('\pdfcatalog{}', '');
DefRegister('\pdfcompresslevel', Number(0));
RawTeX('\newif\ifHy@pdfstring\Hy@pdfstringfalse');
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Additional User Macros
# \href{url}{text}
DefConstructor('\href Semiverbatim {}',
"<ltx:ref href='#href'>#2</ltx:ref>",
properties => sub { (href => CleanURL(LookupValue('BASE_URL') . ToString($_[1]))); });
# \url{url} from url.sty
# Redefine \@url to sanitize the argument less
DefMacro('\@Url Token', sub {
my ($gullet, $cmd) = @_;
my $mouth = $gullet->getMouth;
my ($open, $close, $url);
$open = $gullet->readToken;
StartSemiverbatim();
if ($open->equals(T_BEGIN)) {
$open = T_OTHER('{'); $close = T_OTHER('}');
$url = $gullet->readBalanced; }
else {
$close = $open = T_OTHER($open->getString);
$url = $mouth->readTokens($close); }
EndSemiverbatim();
# Identical with url's \@Url except that it sanitizes the arg less
my @toks = map { ($_->getCatcode == CC_CS ? $_ : T_OTHER(ToString($_))) } $url->unlist;
(Invocation(T_CS('\@@Url'),
T_OTHER(ToString($cmd)), Tokens($open), Tokens($close),
Tokens(@toks),
Tokens(T_CS('\UrlFont'), T_CS('\UrlLeft'), @toks, T_CS('\UrlRight')))->unlist,
T_CS('\endgroup')); });
# \nolinkurl{url}
DefConstructor('\nolinkurl Semiverbatim', '#1');
# \hyperbaseurl{url}
DefPrimitive('\hyperbaseurl Semiverbatim', sub { AssignValue(BASE_URL => ToString($_[1])); });
# \hyperimage{imageurl}{text}
DefConstructor('\hyperimage Semiverbatim {}', "<ltx:graphic graphic='#1' description='#2'/>");
# \hyperdef{category}{name}{text}
DefConstructor('\hyperdef Semiverbatim Semiverbatim Semiverbatim',
"<ltx:anchor xml:id='#id'>#3</ltx:anchor>",
properties => sub { (id => CleanID(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])
. '#' . CleanID(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>",
properties => sub { (id => CleanID($_[1])); });
DefConstructor('\hypertarget Semiverbatim {}',
"<ltx:anchor xml:id='#id'>#2</ltx:anchor>",
properties => sub { (id => CleanID(ToString($_[1]))); });
# Should create an anchor with automatically chosen name;
# But it's to be used where LaTeXML already would have created an anchor & link...
# Should leverage
DefMacroI('\phantomsection', undef, '');
# This only approximates the "contextual label" that should precede the number,
# and ignores the user-definable macros.
# But, we normally defer such bookkeeping until postprocessing....sigh
DefMacro('\autoref Semiverbatim', '\ref{#1}');
DefConstructor('\autoref Semiverbatim',
"<ltx:ref show='type refnum' labelref='#label'/>",
properties => sub { (label => CleanLabel($_[2])); });
# Covered in LaTeX.pool, but non-ref character is ignored.
# \ref*{label}
# \pageref*{label}
# I wonder if this is good enough for our context?
# \pdfstringdef{macroname}{texstring}
DefMacro('\pdfstring{Token}{}', '\def#1{#2}');
#======================================================================
# 4.1 Replacement macros
# \texorpdfstring{TeXString}{PDFstring}
DefMacro('\texorpdfstring{}{}', '#1');
#======================================================================
# 4.2 Utility macros
# \hypercalcbp{dimen}
DefMacro('\hypercalcbp{Dimension}', sub {
my ($gullet, $dimen) = @_;
Explode($dimen->valueOf / $STATE->convertUnit('bp')); });
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# 5 Acrobat-specific behaviour
# \Acrobatmenu{menuoption}{text}
# These create buttons that activate Acrobat Reader or Exchange actions.
# It's doubtful that they have meaningful analogs in our context?
DefMacro('\Acrobatmenu{}{}', '[#1 Button: #2]');
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# 6 PDF and HTML forms
# hmm... we might actually want to do this?
# But, we need schema support!
#----------------------------------------------------------------------
# Fields:
# \TextField[parameters]{label}
# \CheckBox[parameters]{label}
# \ChoiceMenu[parameters]{label}{choices}
# \PushButton[parameters]{label}
# \Submit[parameters]{label}
# \Reset[parameters]{label}
#----------------------------------------------------------------------
# Layout:
# typically: "#1 #2"
# \LayoutTextField{label}{field}
# \LayoutChoiceField{label}{field}
# \LayoutCheckField{label}{field}
#----------------------------------------------------------------------
# What to show
# \MakeRadioField{width}{height}
# \MakeCheckField{width}{height}
# \MakeChoiceField{width}{height}
# \MakeButtonField{text}
#======================================================================
# 6.1 Forms environment parameters
# action URL
# encoding name
# method name (post|get)
#======================================================================
# 6.2 Forms optional parameters
# [a bunch] colors, events, etc; See the doc when we actually support.
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# hyperref uses KeyVals for options!
# until we come up with a nice, clean formal scheme, just hack through...
#### ProcessOptions();
# This doesn't really quite work, since when \usepackage digests the options, spaces go away!
if (my $options = LookupValue('opt@hyperref.sty')) {
foreach my $option (@$options) {
if (my ($key, $value) = $option =~ /^(.*?)\s*=\s*(.*?)$/) {
AssignMapping('PDF.RDFa_properties', $key, $value); } } }
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1;
|