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

# Can we load hyperref, to get all it's random sundry definitions?
# No, too many weird extra packages loaded.
## InputDefinitions('hyperref', type => 'sty', noltxml => 1);

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# 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,
# 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
DefKeyVal('Hyp', 'baseurl', 'Semiverbatim');

sub hyperref_setoption {
  my ($key, $value) = @_;
  AssignMapping('Hyperref_options', $key, $value);
  if ($key eq 'baseurl') {
    AssignValue(BASE_URL => ToString($value)); }
  return; }

# Digest & store the options;
# Some are useful 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:Hyp', sub {
    my ($stomach, $kv) = @_;
    my @pairs = $kv->getPairs;
    while (@pairs) {
      my ($key, $value) = (shift(@pairs), shift(@pairs));
      hyperref_setoption($key, Digest($value)); }
    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('Hyperref_options')) {
        if (my $entry = ($pdfkey_property{$key})) {
          my ($property, $object, $datatype) = @$entry;
          my $value = LookupMapping('Hyperref_options', $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}
DefMacro('\href Verbatim {}', '\@@Url\href{}{}{#1}{#2}');

# \url{url} from url.sty... well sorta
# It's slightly different in that it expands the argument
# Redefine \@url to sanitize the argument less
DefMacro('\@Url Token', sub {
    my ($gullet, $cmd) = @_;
    my ($open, $close, $url);
    $open = $gullet->readToken;
    StartSemiverbatim('%');
    Let('~', T_OTHER('~'));    # Needs special protection?
    if ($open->equals(T_BEGIN)) {
      $open = T_OTHER('{'); $close = T_OTHER('}');
      $url  = $gullet->readBalanced(1); }            # Expand as we go!
    else {
      $url  = T_OTHER($open->getString);
      $open = T_OTHER('{'); $close = T_OTHER('}'); }
    EndSemiverbatim();
    my @toks = grep { $_->getCatcode != CC_SPACE; } $url->unlist;
    # Identical with url's \@Url except, let CS's through!
    @toks = map { (($_->getCatcode == CC_CS) ? $_ : T_OTHER(ToString($_))) } @toks;
    (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]))); });

DefMacro('\hyperref', '\@ifnextchar[\hyperref@@ii\hyperref@@iv');
# 2 argument form
DefConstructor('\hyperref@@ii OptionalSemiverbatim {}',
  "<ltx:ref labelref='#label'>#2</ltx:ref>",
  properties => sub { (label => CleanLabel($_[1])); });
# 4 argument form
DefConstructor('\hyperref@@iv Semiverbatim Semiverbatim Semiverbatim Semiverbatim',
  "<ltx:ref href='#href'>#4</ltx:ref>",
  properties => sub {
    (href => ComposeURL(LookupValue('BASE_URL'), $_[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])); });
DefMacro('\hyper@@link{}{}{}', '\hyperlink{#2}{#3}');

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, '');

Let('\footref', '\ref');    # ?

# 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
DefConstructor('\autoref Semiverbatim',
  "<ltx:ref class='ltx_refmacro_autoref' show='autoref' labelref='#label' _force_font='true'/>",
  properties => sub { (label => CleanLabel($_[1])); });

DefMacro('\lx@autorefnum@@{}', sub {
    my ($gullet, $type) = @_;
    my $type_s  = ToString($type);
    my $counter = LookupMapping('counter_for_type', $type_s) || $type_s;
    return Tokens(
      (LookupDefinition(T_CS('\\' . $type_s . 'autorefname'))
        ? (Tokens(T_CS('\\' . $type_s . 'autorefname'), T_CS('\text@nobreakspace')))
        : ()),
      (LookupDefinition(T_CS('\p@' . $counter)) ? T_CS('\p@' . $counter) : ()),
      T_CS('\the' . $counter)); });

Let('\HyOrg@addtoreset', '\@addtoreset');
Let('\H@refstepcounter', '\refstepcounter');

AssignMapping('type_tag_formatter', 'autoref' => '\lx@autorefnum@@');

# Blech...
map { DefMacroI(T_CS('\\' . $_ . 'autorefname'), undef, '\itemautorefname'); }
  qw(@itemi @itemii @itemiii @itemiv @itemv @itemvi
  enumi enumii enumiii enumiv
  @desci @descii @desciii @desciv @descv @descvi);

# 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}');

DefMacro('\pdfstringdefDisableCommands', '');    # Hopefully noop is sufficient?
#======================================================================
# 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();
# Note that hyperref uses keyval + kvoptions
if (my $options = LookupValue('opt@hyperref.sty')) {
  foreach my $option (@$options) {
    if (my ($key, $value) = $option =~ /^(.*?)\s*=\s*(.*?)$/) {
      hyperref_setoption($key, $value); } } }

RawTeX(<<'EoTeX');
\def\HyLang@afrikaans{%
  \def\equationautorefname{Vergelyking}%
  \def\footnoteautorefname{Voetnota}%
  \def\itemautorefname{Item}%
  \def\figureautorefname{Figuur}%
  \def\tableautorefname{Tabel}%
  \def\partautorefname{Deel}%
  \def\appendixautorefname{Bylae}%
  \def\chapterautorefname{Hoofstuk}%
  \def\sectionautorefname{Afdeling}%
  \def\subsectionautorefname{Subafdeling}%
  \def\subsubsectionautorefname{Subsubafdeling}%
  \def\paragraphautorefname{Paragraaf}%
  \def\subparagraphautorefname{Subparagraaf}%
  \def\FancyVerbLineautorefname{Lyn}%
  \def\theoremautorefname{Teorema}%
  \def\pageautorefname{Bladsy}%
}
\def\HyLang@english{%
  \def\equationautorefname{Equation}%
  \def\footnoteautorefname{footnote}%
  \def\itemautorefname{item}%
  \def\figureautorefname{Figure}%
  \def\tableautorefname{Table}%
  \def\partautorefname{Part}%
  \def\appendixautorefname{Appendix}%
  \def\chapterautorefname{chapter}%
  \def\sectionautorefname{section}%
  \def\subsectionautorefname{subsection}%
  \def\subsubsectionautorefname{subsubsection}%
  \def\paragraphautorefname{paragraph}%
  \def\subparagraphautorefname{subparagraph}%
  \def\FancyVerbLineautorefname{line}%
  \def\theoremautorefname{Theorem}%
  \def\pageautorefname{page}%
}
\def\HyLang@french{%
  \def\equationautorefname{\'Equation}%
  \def\footnoteautorefname{note}%
  \def\itemautorefname{item}%
  \def\figureautorefname{Figure}%
  \def\tableautorefname{Tableau}%
  \def\partautorefname{Partie}%
  \def\appendixautorefname{Appendice}%
  \def\chapterautorefname{chapitre}%
  \def\sectionautorefname{section}%
  \def\subsectionautorefname{sous-section}%
  \def\subsubsectionautorefname{sous-sous-section}%
  \def\paragraphautorefname{paragraphe}%
  \def\subparagraphautorefname{sous-paragraphe}%
  \def\FancyVerbLineautorefname{ligne}%
  \def\theoremautorefname{Th\'eor\`eme}%
  \def\pageautorefname{page}%
}
\def\HyLang@german{%
  \def\equationautorefname{Gleichung}%
  \def\footnoteautorefname{Fu\ss note}%
  \def\itemautorefname{Punkt}%
  \def\figureautorefname{Abbildung}%
  \def\tableautorefname{Tabelle}%
  \def\partautorefname{Teil}%
  \def\appendixautorefname{Anhang}%
  \def\chapterautorefname{Kapitel}%
  \def\sectionautorefname{Abschnitt}%
  \def\subsectionautorefname{Unterabschnitt}%
  \def\subsubsectionautorefname{Unterunterabschnitt}%
  \def\paragraphautorefname{Absatz}%
  \def\subparagraphautorefname{Unterabsatz}%
  \def\FancyVerbLineautorefname{Zeile}%
  \def\theoremautorefname{Theorem}%
  \def\pageautorefname{Seite}%
}
\def\HyLang@italian{%
  \def\equationautorefname{Equazione}%
  \def\footnoteautorefname{nota}%
  \def\itemautorefname{punto}%
  \def\figureautorefname{Figura}%
  \def\tableautorefname{Tabella}%
  \def\partautorefname{Parte}%
  \def\appendixautorefname{Appendice}%
  \def\chapterautorefname{Capitolo}%
  \def\sectionautorefname{sezione}%
  \def\subsectionautorefname{sottosezione}%
  \def\subsubsectionautorefname{sottosottosezione}%
  \def\paragraphautorefname{paragrafo}%
  \def\subparagraphautorefname{sottoparagrafo}%
  \def\FancyVerbLineautorefname{linea}%
  \def\theoremautorefname{Teorema}%
  \def\pageautorefname{Pag.\@}%
}
\def\HyLang@magyar{%
  \def\equationautorefname{Egyenlet}%
  \def\footnoteautorefname{l\'abjegyzet}%
  \def\itemautorefname{Elem}%
  \def\figureautorefname{\'Abra}%
  \def\tableautorefname{T\'abl\'azat}%
  \def\partautorefname{R\'esz}%
  \def\appendixautorefname{F\"uggel\'ek}%
  \def\chapterautorefname{fejezet}%
  \def\sectionautorefname{szakasz}%
  \def\subsectionautorefname{alszakasz}%
  \def\subsubsectionautorefname{alalszakasz}%
  \def\paragraphautorefname{bekezd\'es}%
  \def\subparagraphautorefname{albekezd\'es}%
  \def\FancyVerbLineautorefname{sor}%
  \def\theoremautorefname{T\'etel}%
  \def\pageautorefname{oldal}%
}
\def\HyLang@portuges{%
  \def\equationautorefname{Equa\c c\~ao}%
  \def\footnoteautorefname{Nota de rodap\'e}%
  \def\itemautorefname{Item}%
  \def\figureautorefname{Figura}%
  \def\tableautorefname{Tabela}%
  \def\partautorefname{Parte}%
  \def\appendixautorefname{Ap\^endice}%
  \def\chapterautorefname{Cap\'itulo}%
  \def\sectionautorefname{Se\c c\~ao}%
  \def\subsectionautorefname{Subse\c c\~ao}%
  \def\subsubsectionautorefname{Subsubse\c c\~ao}%
  \def\paragraphautorefname{par\'agrafo}%
  \def\subparagraphautorefname{subpar\'agrafo}%
  \def\FancyVerbLineautorefname{linha}%
  \def\theoremautorefname{Teorema}%
  \def\pageautorefname{P\'agina}%
}
\def\HyLang@russian{%
  \def\equationautorefname{\cyr\cyrv\cyrery\cyrr.}%
  \def\footnoteautorefname{%
    \cyr\cyrp\cyro\cyrd\cyrs\cyrt\cyrr.\ \cyrp\cyrr\cyri\cyrm.%
  }%
  \def\itemautorefname{\cyr\cyrp.}%
  \def\figureautorefname{\cyr\cyrr\cyri\cyrs.}%
  \def\tableautorefname{\cyr\cyrt\cyra\cyrb\cyrl.}%
  \def\partautorefname{\cyr\cyrch.}%
  \def\chapterautorefname{\cyr\cyrg\cyrl.}%
  \def\sectionautorefname{\cyr\cyrr\cyra\cyrz\cyrd.}%
  \def\appendixautorefname{\cyr\cyrp\cyrr\cyri\cyrl.}%
  \def\subsectionautorefname{\cyr\cyrr\cyra\cyrz\cyrd.}%
  \def\subsubsectionautorefname{\cyr\cyrr\cyra\cyrz\cyrd.}%
  \def\paragraphautorefname{\cyr\cyrp.}%
  \def\subparagraphautorefname{\cyr\cyrp.}%
  \def\FancyVerbLineautorefname{\cyr\cyrs\cyrt\cyrr.}%
  \def\theoremautorefname{\cyr\cyrt\cyre\cyro\cyrr.}%
  \def\pageautorefname{\cyr\cyrs.}%
}
\def\HyLang@spanish{%
  \def\equationautorefname{Ecuaci\'on}%
  \def\footnoteautorefname{Nota a pie de p\'agina}%
  \def\itemautorefname{Elemento}%
  \def\figureautorefname{Figura}%
  \def\tableautorefname{Tabla}%
  \def\partautorefname{Parte}%
  \def\appendixautorefname{Ap\'endice}%
  \def\chapterautorefname{Cap\'itulo}%
  \def\sectionautorefname{Secci\'on}%
  \def\subsectionautorefname{Subsecci\'on}%
  \def\subsubsectionautorefname{Subsubsecci\'on}%
  \def\paragraphautorefname{P\'arrafo}%
  \def\subparagraphautorefname{Subp\'arrafo}%
  \def\FancyVerbLineautorefname{L\'inea}%
  \def\theoremautorefname{Teorema}%
  \def\pageautorefname{P\'agina}%
}
\def\HyLang@catalan{%
\def\equationautorefname{Equaci\'o}%
\def\footnoteautorefname{Nota al peu de p\`agina}%
\def\itemautorefname{Element}%
\def\figureautorefname{Figura}%
\def\tableautorefname{Taula}%
\def\partautorefname{Part}%
\def\appendixautorefname{Ap\`endix}%
\def\chapterautorefname{Cap\'itol}%
\def\sectionautorefname{Secci\'o}%
\def\subsectionautorefname{Subsecci\'o}%
\def\subsubsectionautorefname{Subsubsecci\'o}%
\def\paragraphautorefname{Par\`agraf}%
\def\subparagraphautorefname{Subpar\`agraf}%
\def\FancyVerbLineautorefname{L\'inia}%
\def\theoremautorefname{Teorema}%
\def\pageautorefname{P\`agina}%
}
\def\HyLang@vietnamese{%
  \def\equationautorefname{Ph\uhorn{}\ohorn{}ng tr\`inh}%
  \def\footnoteautorefname{Ch\'u th\'ich}%
  \def\itemautorefname{m\d{u}c}%
  \def\figureautorefname{H\`inh}%
  \def\tableautorefname{B\h{a}ng}%
  \def\partautorefname{Ph\`\acircumflex{}n}%
  \def\appendixautorefname{Ph\d{u} l\d{u}c}%
  \def\chapterautorefname{ch\uhorn{}\ohorn{}ng}%
  \def\sectionautorefname{m\d{u}c}%
  \def\subsectionautorefname{m\d{u}c}%
  \def\subsubsectionautorefname{m\d{u}c}%
  \def\paragraphautorefname{\dj{}o\d{a}n}%
  \def\subparagraphautorefname{\dj{}o\d{a}n}%
  \def\FancyVerbLineautorefname{d\`ong}%
  \def\theoremautorefname{\DJ{}\d{i}nh l\'y}%
  \def\pageautorefname{Trang}%
}

% For now...
\HyLang@english
EoTeX
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1;
