<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%
% Copyright (C) 2010-2019 Javier Bezos http://www.texnia.com
%
% This file may be distributed and/or modified under the conditions of
% the MIT License. A version can be found at the end of this file.
%
% TODO:
% noshorthands -&gt; shorthands=off, nocitations, nocrossrefs

\ProvidesPackage{babeltools}[2010/10/14 v1.1 Tools for the babel system (beta)]

\edef\bbtl@savedcatcodes{%
 \catcode`\noexpand\~=\the\catcode`\~
 \catcode`\noexpand\:=\the\catcode`\:
 \catcode`\noexpand\"=\the\catcode`\"}
\catcode`\~=\active
\catcode`\"=12
\catcode`\:=12

\def\bbtl@meaning{\expandafter\strip@prefix\meaning}

\def\bbtl@ifshorthand#1{%
  \@expandtwoargs\in@{#1}{\bbtl@o@shorthands}%
  \ifin@
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
   
\let\bbtl@afterbabelhook\@empty
\newcommand\AfterBabel[1]{%
  \g@addto@macro\bbtl@afterbabelhook{#1}}

\let\bbtl@atendofbabelhook\@empty
\newcommand\AtEndOfBabel[1]{%
  \g@addto@macro\bbtl@atendofbabelhook{#1}}

\let\bbtl@beforebabelhook\@empty
\newcommand\BeforeBabel[1]{%
  \g@addto@macro\bbtl@beforebabelhook{#1}}


% Citations and cross refs
% ~~~~~~~~~~~~~~~~~~~~~~~~

\let\bbtl@ignorepackages\@empty

\DeclareOption{nocitations}
  {\g@addto@macro\bbtl@ignorepackages{,cite,natbib,}%
   \AfterBabel{%
     \bbtl@restore@org{nocite}%
     \bbtl@restore@org{bibcite}%
     \bbtl@restore@org{@bibitem}%S
     \bbtl@restore@org{@citex}}}

\DeclareOption{nocrossrefs}
  {\g@addto@macro\bbtl@ignorepackages{,varioref,}%
   \BeforeBabel{%
     \bbtl@save@org{@newl@bel}}% babel DOESN'T save it!
   \AfterBabel{%
     \bbtl@restore@org{@newl@bel}%
     \bbtl@restore@org{ref}%  Robust
     \bbtl@restore@org{pageref}}}%  Robust

% Shorthands
% ~~~~~~~~~~
%
% New shorthands
% --------------

\DeclareOption{adaptive}%
  {\AfterBabel{%
     \let\bbtl@initiate@active@char\initiate@active@char
     \let\initiate@active@char\bbtl@set@shorthand
     \let\bbtl@declare@shorthand\declare@shorthand
     \let\declare@shorthand\bbtl@declare
     \let\bbl@activate\bbtl@activate
     \let\bbtl@deactivate\bbl@deactivate
     \let\bbl@deactivate\bbtl@restore}}

% Do \bbtl@initiate@active@char but don't make the char active.
% Not necessary and a source of bugs.

\def\bbtl@set@shorthand#1{%
  \expandafter\edef\csname bbtl@savecat\string#1\endcsname
    {\the\catcode`#1}%
  \bbtl@initiate@active@char{#1}%
  \catcode`#1=\csname bbtl@savecat\string#1\endcsname\relax
  \addto\bbtl@select{\shorthandon{#1}}}

\def\bbtl@use@shorthand{%
  \if@safe@actives
    \bbl@afterelse
    \string
  \else
    \bbl@afterfi
    {\ifx\thepage\relax
       \bbl@afterelse
       \string
     \else
       \bbl@afterfi
       \bbtl@use@sh
     \fi}%
  \fi}

\def\bbtl@use@sh#1{%
  \ifx\protect\@unexpandable@protect
     \bbl@afterelse
     \noexpand#1%
   \else%
     \bbl@afterfi
     \textormath
       {\csname active@char\string#1\endcsname}%
       {\csname normal@char\string#1\endcsname}%
   \fi}

\gdef\bbtl@activate#1{%
  \begingroup
    \lccode`\~=`#1
    \lowercase{%
   \endgroup
   \def~{\bbtl@use@shorthand~}}}

\def\bbtl@restore#1{%
  \shorthandon{#1}%
  \begingroup
    \lccode`\~=`#1
    \lowercase{%
  \endgroup
  \bbtl@deactivate{~}}}

\def\bbtl@declare#1#2{%
  \@ifundefined{bbtl@savecat\expandafter\string\@firstoftwo#2\@empty}%
    {\@gobble}%
    {\bbtl@declare@shorthand{#1}{#2}}}

% No shorthands
% -------------

% This is done after 'adaptive', if present.

\DeclareOption{shorthands=off}%
  {\AfterBabel{\bbl@doshorthands}}

\def\babelshorthand#1{%
  \def\bbtl@tempa{#1}%
  \@ifundefined{bbtl@@\languagename @@\bbtl@meaning\bbtl@tempa}%
    {#1}%
    {\@nameuse{bbtl@@\languagename @@\bbtl@meaning\bbtl@tempa}}}

% No config
% ~~~~~~~~~
% Make sure an unexpected local config doesn't spoil your document.
% Use of config files is strongly discouraged, but some sites
% use them

\DeclareOption{noconfig}
  {\PassOptionToPackage{babel}{noconfig}}

% Captions
% ~~~~~~~~

% redefining names. Somewhat experimental.

\def\bbtl@captions{%
  \bbtl@elt\prefacename\bbtl@elt\refname\bbtl@elt\abstractname
  \bbtl@elt\bibname\bbtl@elt\chaptername\bbtl@elt\appendixname
  \bbtl@elt\contentsname\bbtl@elt\listfigurename
  \bbtl@elt\listtablename\bbtl@elt\indexname
  \bbtl@elt\figurename\bbtl@elt\tablename\bbtl@elt\partname
  \bbtl@elt\enclname\bbtl@elt\ccname\bbtl@elt\headtoname
  \bbtl@elt\pagename\bbtl@elt\seename\bbtl@elt\alsoname
  \bbtl@elt\proofname\bbtl@elt\glossaryname}

% 1: \captions... expanded #2 repl fun bbtl@f #3 \...name
% \lang...name
\def\bbtl@rep#1\@@\@@#2#3#4{%
  \in@{#3}{#1}%
  \ifin@
    #2#1\@@\@@#3#4%
  \else
    \PackageWarningNoLine{babeltools}%
      {No \string#3 in \bbtl@l}%
  \fi}

% \bbtl@f is a helper macro:
% 1 \...name
% bbtl@f:
% #1 prev, #2 def of \...name, #3 after
% #4 \...name, #5 \lang...name
\DeclareOption{langcaptions}
  {\def\bbtl@repdef#1{%
     \def\bbtl@f##1#1##2##3\@@\@@##4##5{%
       \def##5{##2}%
       \@namedef{captions\bbtl@l}{##1##4{##5}##3}}}%
   \def\bbtl@elt#1{%
     \bbtl@repdef#1%
     \@temptokena\expandafter\expandafter\expandafter{%
       \csname captions\bbtl@l\endcsname}%
     % If \lang...name undefined
     \edef\bbtl@t{%
       \noexpand\bbtl@rep
       \the\@temptokena
       \noexpand\@@\noexpand\@@
       \noexpand\bbtl@f
       \noexpand#1
       \expandafter\noexpand
         \csname\bbtl@l\expandafter\@gobble\string#1\endcsname}%
     \bbtl@t}%
   \def\bbtl@repdo{%
     \@for\bbtl@l:=\bbtl@options\do{%
       \@ifundefined{captions\bbtl@l}{}{%
       \bbtl@captions}}}%
   \AtEndOfBabel{\bbtl@repdo}}

% Key=value package options
% ~~~~~~~~~~~~~~~~~~~~~~~~~

\def\bbtl@process#1=#2\bbtl@process#3{%
  \expandafter\ifx\csname bbtl@o@#1\endcsname\@empty
    \expandafter\edef\csname bbtl@o@#1\endcsname{#2}%
    \DeclareOption{\CurrentOption}{}%
  \fi}

\DeclareOption*{%
  \@expandtwoargs\in@{\string=}{\CurrentOption}%
  \ifin@
    \expandafter\bbtl@process\CurrentOption\bbtl@process\CurrentOption
  \fi}

% Process options
% ~~~~~~~~~~~~~~~~

\ProcessOptions

% shorthands=... option is handled here.

\ifx\bbtl@o@shorthands\@empty\else
  \edef\bbtl@o@shorthands{\bbtl@meaning\bbtl@o@shorthands}%
  \bbtl@ifshorthand{'}%
    {\PassOptionsToPackage{activeacute}{babel}}{}
  \bbtl@ifshorthand{`}%
    {\PassOptionsToPackage{activegrave}{babel}}{}
  \bbtl@ifshorthand{:}{}%
    {\g@addto@macro\bbtl@ignorepackages{,hhline,}}
% After any redefinition, the shorthand mechanism comes.
  \AfterBabel{\bbl@doshorthands}
\fi

% The first \LdfInit loads the babel core (the sty file doesn't!)
% That means babeltools is not compatible with classes loading
% a language:

\@ifundefined{ldf@finish}%
  {\def\LdfInit{%
    \expandafter\let\expandafter\bbtl@options
       \csname opt@babel.sty\endcsname
     \bbtl@beforebabelhook
     \AtBeginDocument{%
       \let\bbtl@ifpackageloaded\@ifpackageloaded
       \def\@ifpackageloaded##1{%
         \@expandtwoargs\in@{,##1,}{\bbtl@ignorepackages}%
         \ifin@
           \expandafter\@gobbletwo
         \else
           \expandafter\bbtl@ifpackageloaded
         \fi
         {##1}}}%
     \chardef\atcatcode =\catcode`\@
     \catcode`\@=11\relax
     \input babel.def\relax
     \catcode`\@ =\atcatcode
     \let\atcatcode\relax
     \bbtl@afterbabelhook
     \AtEndOfPackage{\bbtl@atendofbabelhook}%
     \LdfInit}}
  {\PackageError{babeltools}%
     {Too late -- babel has been loaded}%
     {babeltools can be used only before babel.\MessageBreak
      Very likely a package or the class has loaded it.}}

\AtEndOfBabel{%
  \AtBeginDocument{\let\@ifpackageloaded\bbtl@ifpackageloaded}}

\bbtl@savedcatcodes

\endinput

MIT License
-----------

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.





</pre></body></html>