You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tex-compiler/texmf-dist/tex/latex/polyglossia/babelsh.def

595 lines
19 KiB

\ifx\initiate@active@char\@undefined
\else
\bbl@afterfi\endinput
\fi
\ProvidesFile{babelsh.def}
[2019/09/30 %
Babel common definitions for shorthands^^J
Taken verbatim from babel files (2019/09/27 v3.34)]
%
% ------------------------------------------------------------------------------
%
% lines 52 to 56 from babel.sty
%
% ------------------------------------------------------------------------------
%
\def\bbl@stripslash{\expandafter\@gobble\string}
\def\bbl@add#1#2{%
\bbl@ifunset{\bbl@stripslash#1}%
{\def#1{#2}}%
{\expandafter\def\expandafter#1\expandafter{#1#2}}}
%
% ------------------------------------------------------------------------------
%
% line 73 to 74 from babel.sty
%
% ------------------------------------------------------------------------------
%
\long\def\bbl@afterelse#1\else#2\fi{\fi#1}
\long\def\bbl@afterfi#1\fi{\fi#1}
%
% ------------------------------------------------------------------------------
%
% line 399 from babel.sty
%
% ------------------------------------------------------------------------------
%
\let\bbl@opt@shorthands\@nnil
%
% ------------------------------------------------------------------------------
%
% lines 432 to 445 from babel.sty
%
% ------------------------------------------------------------------------------
%
\ifx\bbl@opt@shorthands\@nnil
\def\bbl@ifshorthand#1#2#3{#2}%
\else\ifx\bbl@opt@shorthands\@empty
\def\bbl@ifshorthand#1#2#3{#3}%
\else
\def\bbl@ifshorthand#1{%
\bbl@xin@{\string#1}{\bbl@opt@shorthands}%
\ifin@
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\edef\bbl@opt@shorthands{%
\expandafter\bbl@sh@string\bbl@opt@shorthands\@empty}%
%
% ------------------------------------------------------------------------------
%
% line 450 from babel.sty
%
% ------------------------------------------------------------------------------
%
\fi\fi
%
% ------------------------------------------------------------------------------
%
% lines 389 to 424 from switch.def
%
% ------------------------------------------------------------------------------
%
\ifx\PackageError\@undefined
\def\bbl@error#1#2{%
\begingroup
\newlinechar=`\^^J
\def\\{^^J(babel) }%
\errhelp{#2}\errmessage{\\#1}%
\endgroup}
\def\bbl@warning#1{%
\begingroup
\newlinechar=`\^^J
\def\\{^^J(polyglossia) }%
\message{\\#1}%
\endgroup}
\def\bbl@info#1{%
\begingroup
\newlinechar=`\^^J
\def\\{^^J}%
\wlog{#1}%
\endgroup}
\else
\def\bbl@error#1#2{%
\begingroup
\def\\{\MessageBreak}%
\PackageError{polyglossia}{#1}{#2}%
\endgroup}
\def\bbl@warning#1{%
\begingroup
\def\\{\MessageBreak}%
\PackageWarning{polyglossia}{#1}%
\endgroup}
\def\bbl@info#1{%
\begingroup
\def\\{\MessageBreak}%
\PackageInfo{polyglossia}{#1}%
\endgroup}
\fi
%
% ------------------------------------------------------------------------------
%
% lines 48 to 69 from babel.def
%
% ------------------------------------------------------------------------------
%
\ifx\bbl@ifshorthand\@undefined
\let\bbl@opt@shorthands\@nnil
\def\bbl@ifshorthand#1#2#3{#2}%
\let\bbl@language@opts\@empty
\ifx\babeloptionstrings\@undefined
\let\bbl@opt@strings\@nnil
\else
\let\bbl@opt@strings\babeloptionstrings
\fi
\def\BabelStringsDefault{generic}
\def\bbl@tempa{normal}
\ifx\babeloptionmath\bbl@tempa
\def\bbl@mathnormal{\noexpand\textormath}
\fi
\def\AfterBabelLanguage#1#2{}
\ifx\BabelModifiers\@undefined\let\BabelModifiers\relax\fi
\let\bbl@afterlang\relax
\def\bbl@opt@safe{BR}
\ifx\@uclclist\@undefined\let\@uclclist\@empty\fi
\ifx\bbl@trace\@undefined\def\bbl@trace#1{}\fi
\expandafter\newif\csname ifbbl@single\endcsname
\fi
%
% ------------------------------------------------------------------------------
%
% line 108 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
% ------------------------------------------------------------------------------
%
% lines 110 to 116 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
\ifx\@nnil#3\relax\else
\def#1{#3}#2\bbl@afterfi\bbl@@loop#1{#2}%
\fi}
\def\bbl@for#1#2#3{\bbl@loopx#1{#2}{\ifx#1\@empty\else#3\fi}}
% ------------------------------------------------------------------------------
%
% lines 125 to 130 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@exp#1{%
\begingroup
\let\\\noexpand
\def\<##1>{\expandafter\noexpand\csname##1\endcsname}%
\edef\bbl@exp@aux{\endgroup#1}%
\bbl@exp@aux}
%
% ------------------------------------------------------------------------------
%
% lines 144 to 149 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@ifunset#1{%
\expandafter\ifx\csname#1\endcsname\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
%
% ------------------------------------------------------------------------------
%
% lines 234 to 243 from babel.def
%
% ------------------------------------------------------------------------------
%
\chardef\bbl@engine=%
\ifx\directlua\@undefined
\ifx\XeTeXinputencoding\@undefined
\z@
\else
\tw@
\fi
\else
\@ne
\fi
%
% ------------------------------------------------------------------------------
%
% lines 255 to 258 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@withactive#1#2{%
\begingroup
\lccode`~=`#2\relax
\lowercase{\endgroup#1~}}
%
% ------------------------------------------------------------------------------
%
% lines 443 to 558 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@add@special#1{% 1:a macro like \", \?, etc.
\bbl@add\dospecials{\do#1}% test @sanitize = \relax, for back. compat.
\bbl@ifunset{@sanitize}{}{\bbl@add\@sanitize{\@makeother#1}}%
\ifx\nfss@catcodes\@undefined\else % TODO - same for above
\begingroup
\catcode`#1\active
\nfss@catcodes
\ifnum\catcode`#1=\active
\endgroup
\bbl@add\nfss@catcodes{\@makeother#1}%
\else
\endgroup
\fi
\fi}
\def\bbl@remove@special#1{%
\begingroup
\def\x##1##2{\ifnum`#1=`##2\noexpand\@empty
\else\noexpand##1\noexpand##2\fi}%
\def\do{\x\do}%
\def\@makeother{\x\@makeother}%
\edef\x{\endgroup
\def\noexpand\dospecials{\dospecials}%
\expandafter\ifx\csname @sanitize\endcsname\relax\else
\def\noexpand\@sanitize{\@sanitize}%
\fi}%
\x}
\def\bbl@active@def#1#2#3#4{%
\@namedef{#3#1}{%
\expandafter\ifx\csname#2@sh@#1@\endcsname\relax
\bbl@afterelse\bbl@sh@select#2#1{#3@arg#1}{#4#1}%
\else
\bbl@afterfi\csname#2@sh@#1@\endcsname
\fi}%
\long\@namedef{#3@arg#1}##1{%
\expandafter\ifx\csname#2@sh@#1@\string##1@\endcsname\relax
\bbl@afterelse\csname#4#1\endcsname##1%
\else
\bbl@afterfi\csname#2@sh@#1@\string##1@\endcsname
\fi}}%
\def\initiate@active@char#1{%
\bbl@ifunset{active@char\string#1}%
{\bbl@withactive
{\expandafter\@initiate@active@char\expandafter}#1\string#1#1}%
{}}
\def\@initiate@active@char#1#2#3{%
\bbl@csarg\edef{oricat@#2}{\catcode`#2=\the\catcode`#2\relax}%
\ifx#1\@undefined
\bbl@csarg\edef{oridef@#2}{\let\noexpand#1\noexpand\@undefined}%
\else
\bbl@csarg\let{oridef@@#2}#1%
\bbl@csarg\edef{oridef@#2}{%
\let\noexpand#1%
\expandafter\noexpand\csname bbl@oridef@@#2\endcsname}%
\fi
\ifx#1#3\relax
\expandafter\let\csname normal@char#2\endcsname#3%
\else
\bbl@info{Making #2 an active character}%
\ifnum\mathcode`#2=\ifodd\bbl@engine"1000000 \else"8000 \fi
\@namedef{normal@char#2}{%
\textormath{#3}{\csname bbl@oridef@@#2\endcsname}}%
\else
\@namedef{normal@char#2}{#3}%
\fi
\bbl@restoreactive{#2}%
\AtBeginDocument{%
\catcode`#2\active
\if@filesw
\immediate\write\@mainaux{\catcode`\string#2\active}%
\fi}%
\expandafter\bbl@add@special\csname#2\endcsname
\catcode`#2\active
\fi
\let\bbl@tempa\@firstoftwo
\if\string^#2%
\def\bbl@tempa{\noexpand\textormath}%
\else
\ifx\bbl@mathnormal\@undefined\else
\let\bbl@tempa\bbl@mathnormal
\fi
\fi
\expandafter\edef\csname active@char#2\endcsname{%
\bbl@tempa
{\noexpand\if@safe@actives
\noexpand\expandafter
\expandafter\noexpand\csname normal@char#2\endcsname
\noexpand\else
\noexpand\expandafter
\expandafter\noexpand\csname bbl@doactive#2\endcsname
\noexpand\fi}%
{\expandafter\noexpand\csname normal@char#2\endcsname}}%
\bbl@csarg\edef{doactive#2}{%
\expandafter\noexpand\csname user@active#2\endcsname}%
\bbl@csarg\edef{active@#2}{%
\noexpand\active@prefix\noexpand#1%
\expandafter\noexpand\csname active@char#2\endcsname}%
\bbl@csarg\edef{normal@#2}{%
\noexpand\active@prefix\noexpand#1%
\expandafter\noexpand\csname normal@char#2\endcsname}%
\expandafter\let\expandafter#1\csname bbl@normal@#2\endcsname
\bbl@active@def#2\user@group{user@active}{language@active}%
\bbl@active@def#2\language@group{language@active}{system@active}%
\bbl@active@def#2\system@group{system@active}{normal@char}%
\expandafter\edef\csname\user@group @sh@#2@@\endcsname
{\expandafter\noexpand\csname normal@char#2\endcsname}%
\expandafter\edef\csname\user@group @sh@#2@\string\protect@\endcsname
{\expandafter\noexpand\csname user@active#2\endcsname}%
\if\string'#2%
\let\prim@s\bbl@prim@s
\let\active@math@prime#1%
\fi
\bbl@usehooks{initiateactive}{{#1}{#2}{#3}}}
\@ifpackagewith{babel}{KeepShorthandsActive}%
{\let\bbl@restoreactive\@gobble}%
{\def\bbl@restoreactive#1{%
\bbl@exp{%
%
% ------------------------------------------------------------------------------
%
% lines 561 to 755 from babel.def
%
% ------------------------------------------------------------------------------
%
\\\AtEndOfPackage
{\catcode`#1=\the\catcode`#1\relax}}}%
\AtEndOfPackage{\let\bbl@restoreactive\@gobble}}
\def\bbl@sh@select#1#2{%
\expandafter\ifx\csname#1@sh@#2@sel\endcsname\relax
\bbl@afterelse\bbl@scndcs
\else
\bbl@afterfi\csname#1@sh@#2@sel\endcsname
\fi}
\def\active@prefix#1{%
\ifx\protect\@typeset@protect
\else
\ifx\protect\@unexpandable@protect
\noexpand#1%
\else
\protect#1%
\fi
\expandafter\@gobble
\fi}
\newif\if@safe@actives
\@safe@activesfalse
\def\bbl@restore@actives{\if@safe@actives\@safe@activesfalse\fi}
\def\bbl@activate#1{%
\bbl@withactive{\expandafter\let\expandafter}#1%
\csname bbl@active@\string#1\endcsname}
\def\bbl@deactivate#1{%
\bbl@withactive{\expandafter\let\expandafter}#1%
\csname bbl@normal@\string#1\endcsname}
\def\bbl@firstcs#1#2{\csname#1\endcsname}
\def\bbl@scndcs#1#2{\csname#2\endcsname}
\def\declare@shorthand#1#2{\@decl@short{#1}#2\@nil}
\def\@decl@short#1#2#3\@nil#4{%
\def\bbl@tempa{#3}%
\ifx\bbl@tempa\@empty
\expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@scndcs
\bbl@ifunset{#1@sh@\string#2@}{}%
{\def\bbl@tempa{#4}%
\expandafter\ifx\csname#1@sh@\string#2@\endcsname\bbl@tempa
\else
\bbl@info
{Redefining #1 shorthand \string#2\\%
in language \CurrentOption}%
\fi}%
\@namedef{#1@sh@\string#2@}{#4}%
\else
\expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@firstcs
\bbl@ifunset{#1@sh@\string#2@\string#3@}{}%
{\def\bbl@tempa{#4}%
\expandafter\ifx\csname#1@sh@\string#2@\string#3@\endcsname\bbl@tempa
\else
\bbl@info
{Redefining #1 shorthand \string#2\string#3\\%
in language \CurrentOption}%
\fi}%
\@namedef{#1@sh@\string#2@\string#3@}{#4}%
\fi}
\def\textormath{%
\ifmmode
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi}
\def\user@group{user}
\def\language@group{english}
\def\system@group{system}
\def\useshorthands{%
\@ifstar\bbl@usesh@s{\bbl@usesh@x{}}}
\def\bbl@usesh@s#1{%
\bbl@usesh@x
{\AddBabelHook{babel-sh-\string#1}{afterextras}{\bbl@activate{#1}}}%
{#1}}
\def\bbl@usesh@x#1#2{%
\bbl@ifshorthand{#2}%
{\def\user@group{user}%
\initiate@active@char{#2}%
#1%
\bbl@activate{#2}}%
{\bbl@error
{Cannot declare a shorthand turned off (\string#2)}
{Sorry, but you cannot use shorthands which have been\\%
turned off in the package options}}}
\def\user@language@group{user@\language@group}
\def\bbl@set@user@generic#1#2{%
\bbl@ifunset{user@generic@active#1}%
{\bbl@active@def#1\user@language@group{user@active}{user@generic@active}%
\bbl@active@def#1\user@group{user@generic@active}{language@active}%
\expandafter\edef\csname#2@sh@#1@@\endcsname{%
\expandafter\noexpand\csname normal@char#1\endcsname}%
\expandafter\edef\csname#2@sh@#1@\string\protect@\endcsname{%
\expandafter\noexpand\csname user@active#1\endcsname}}%
\@empty}
\newcommand\defineshorthand[3][user]{%
\edef\bbl@tempa{\zap@space#1 \@empty}%
\bbl@for\bbl@tempb\bbl@tempa{%
\if*\expandafter\@car\bbl@tempb\@nil
\edef\bbl@tempb{user@\expandafter\@gobble\bbl@tempb}%
\@expandtwoargs
\bbl@set@user@generic{\expandafter\string\@car#2\@nil}\bbl@tempb
\fi
\declare@shorthand{\bbl@tempb}{#2}{#3}}}
\def\languageshorthands#1{\def\language@group{#1}}
\def\aliasshorthand#1#2{%
\bbl@ifshorthand{#2}%
{\expandafter\ifx\csname active@char\string#2\endcsname\relax
\ifx\document\@notprerr
\@notshorthand{#2}%
\else
\initiate@active@char{#2}%
\expandafter\let\csname active@char\string#2\expandafter\endcsname
\csname active@char\string#1\endcsname
\expandafter\let\csname normal@char\string#2\expandafter\endcsname
\csname normal@char\string#1\endcsname
\bbl@activate{#2}%
\fi
\fi}%
{\bbl@error
{Cannot declare a shorthand turned off (\string#2)}
{Sorry, but you cannot use shorthands which have been\\%
turned off in the package options}}}
\def\@notshorthand#1{%
\bbl@error{%
The character `\string #1' should be made a shorthand character;\\%
add the command \string\useshorthands\string{#1\string} to
the preamble.\\%
I will ignore your instruction}%
{You may proceed, but expect unexpected results}}
\newcommand*\shorthandon[1]{\bbl@switch@sh\@ne#1\@nnil}
\DeclareRobustCommand*\shorthandoff{%
\@ifstar{\bbl@shorthandoff\tw@}{\bbl@shorthandoff\z@}}
\def\bbl@shorthandoff#1#2{\bbl@switch@sh#1#2\@nnil}
\def\bbl@switch@sh#1#2{%
\ifx#2\@nnil\else
\bbl@ifunset{bbl@active@\string#2}%
{\bbl@error
{I cannot switch `\string#2' on or off--not a shorthand}%
{This character is not a shorthand. Maybe you made\\%
a typing mistake? I will ignore your instruction}}%
{\ifcase#1%
\catcode`#212\relax
\or
\catcode`#2\active
\or
\csname bbl@oricat@\string#2\endcsname
\csname bbl@oridef@\string#2\endcsname
\fi}%
\bbl@afterfi\bbl@switch@sh#1%
\fi}
\def\babelshorthand{\active@prefix\babelshorthand\bbl@putsh}
\def\bbl@putsh#1{%
\bbl@ifunset{bbl@active@\string#1}%
{\bbl@putsh@i#1\@empty\@nnil}%
{\csname bbl@active@\string#1\endcsname}}
\def\bbl@putsh@i#1#2\@nnil{%
\csname\languagename @sh@\string#1@%
\ifx\@empty#2\else\string#2@\fi\endcsname}
\ifx\bbl@opt@shorthands\@nnil\else
\let\bbl@s@initiate@active@char\initiate@active@char
\def\initiate@active@char#1{%
\bbl@ifshorthand{#1}{\bbl@s@initiate@active@char{#1}}{}}
\let\bbl@s@switch@sh\bbl@switch@sh
\def\bbl@switch@sh#1#2{%
\ifx#2\@nnil\else
\bbl@afterfi
\bbl@ifshorthand{#2}{\bbl@s@switch@sh#1{#2}}{\bbl@switch@sh#1}%
\fi}
\let\bbl@s@activate\bbl@activate
\def\bbl@activate#1{%
\bbl@ifshorthand{#1}{\bbl@s@activate{#1}}{}}
\let\bbl@s@deactivate\bbl@deactivate
\def\bbl@deactivate#1{%
\bbl@ifshorthand{#1}{\bbl@s@deactivate{#1}}{}}
\fi
\newcommand\ifbabelshorthand[3]{\bbl@ifunset{bbl@active@\string#1}{#3}{#2}}
\def\bbl@prim@s{%
\prime\futurelet\@let@token\bbl@pr@m@s}
\def\bbl@if@primes#1#2{%
\ifx#1\@let@token
\expandafter\@firstoftwo
\else\ifx#2\@let@token
\bbl@afterelse\expandafter\@firstoftwo
\else
\bbl@afterfi\expandafter\@secondoftwo
\fi\fi}
\begingroup
\catcode`\^=7 \catcode`\*=\active \lccode`\*=`\^
\catcode`\'=12 \catcode`\"=\active \lccode`\"=`\'
\lowercase{%
\gdef\bbl@pr@m@s{%
\bbl@if@primes"'%
\pr@@@s
{\bbl@if@primes*^\pr@@@t\egroup}}}
\endgroup
\initiate@active@char{~}
\declare@shorthand{system}{~}{\leavevmode\nobreak\ }
\bbl@activate{~}
%
% ------------------------------------------------------------------------------
%
% lines 890 to 927 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@allowhyphens{\ifvmode\else\nobreak\hskip\z@skip\fi}
\def\bbl@t@one{T1}
\def\allowhyphens{\ifx\cf@encoding\bbl@t@one\else\bbl@allowhyphens\fi}
\newcommand\babelnullhyphen{\char\hyphenchar\font}
\def\babelhyphen{\active@prefix\babelhyphen\bbl@hyphen}
\def\bbl@hyphen{%
\@ifstar{\bbl@hyphen@i @}{\bbl@hyphen@i\@empty}}
\def\bbl@hyphen@i#1#2{%
\bbl@ifunset{bbl@hy@#1#2\@empty}%
{\csname bbl@#1usehyphen\endcsname{\discretionary{#2}{}{#2}}}%
{\csname bbl@hy@#1#2\@empty\endcsname}}
\def\bbl@usehyphen#1{%
\leavevmode
\ifdim\lastskip>\z@\mbox{#1}\else\nobreak#1\fi
\nobreak\hskip\z@skip}
\def\bbl@@usehyphen#1{%
\leavevmode\ifdim\lastskip>\z@\mbox{#1}\else#1\fi}
\def\bbl@hyphenchar{%
\ifnum\hyphenchar\font=\m@ne
\babelnullhyphen
\else
\char\hyphenchar\font
\fi}
\def\bbl@hy@soft{\bbl@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}}
\def\bbl@hy@@soft{\bbl@@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}}
\def\bbl@hy@hard{\bbl@usehyphen\bbl@hyphenchar}
\def\bbl@hy@@hard{\bbl@@usehyphen\bbl@hyphenchar}
\def\bbl@hy@nobreak{\bbl@usehyphen{\mbox{\bbl@hyphenchar}}}
\def\bbl@hy@@nobreak{\mbox{\bbl@hyphenchar}}
\def\bbl@hy@repeat{%
\bbl@usehyphen{%
\discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
\def\bbl@hy@@repeat{%
\bbl@@usehyphen{%
\discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
\def\bbl@hy@empty{\hskip\z@skip}
\def\bbl@hy@@empty{\discretionary{}{}{}}
\def\bbl@disc#1#2{\nobreak\discretionary{#2-}{}{#1}\bbl@allowhyphens}
%
% ------------------------------------------------------------------------------
%
% end of the code copied from babel files
%
% ------------------------------------------------------------------------------
%
\def\bbl@disc@german#1#2{%
\nobreak\discretionary{#2-}{}{#1}}
\endinput