1%% CYRILLIC IN NON-CYRILLIC DOCUMENTS (pdflatex only)
2%
3% refs: https://tex.stackexchange.com/q/460271/
4\ProvidesPackage{sphinxpackagecyrillic}%
5  [2018/11/21 v2.0 support for Cyrillic in non-Cyrillic documents]
6\RequirePackage{kvoptions}
7\SetupKeyvalOptions{prefix=spx@cyropt@} % use \spx@cyropt@ prefix
8\DeclareBoolOption[false]{Xtwo}
9\DeclareBoolOption[false]{TtwoA}
10\DeclareDefaultOption{\@unknownoptionerror}
11\ProcessLocalKeyvalOptions* % ignore class options
12
13\ifspx@cyropt@Xtwo
14% original code by tex.sx user egreg (updated 2019/10/28):
15%   https://tex.stackexchange.com/a/460325/
16% 159 Cyrillic glyphs as available in X2 TeX 8bit font encoding
17% This assumes inputenc loaded with utf8 option, or LaTeX release
18% as recent as 2018/04/01 which does it automatically.
19  \@tfor\next:=%
20    {Ё}{Ђ}{Є}{Ѕ}{І}{Ј}{Љ}{Њ}{Ћ}{Ў}{Џ}{А}{Б}{В}{Г}{Д}{Е}{Ж}{З}{И}{Й}%
21    {К}{Л}{М}{Н}{О}{П}{Р}{С}{Т}{У}{Ф}{Х}{Ц}{Ч}{Ш}{Щ}{Ъ}{Ы}{Ь}{Э}{Ю}%
22    {Я}{а}{б}{в}{г}{д}{е}{ж}{з}{и}{й}{к}{л}{м}{н}{о}{п}{р}{с}{т}{у}%
23    {ф}{х}{ц}{ч}{ш}{щ}{ъ}{ы}{ь}{э}{ю}{я}{ё}{ђ}{є}{ѕ}{і}{ј}{љ}{њ}{ћ}%
24    {ў}{џ}{Ѣ}{ѣ}{Ѫ}{ѫ}{Ѵ}{ѵ}{Ґ}{ґ}{Ғ}{ғ}{Ҕ}{ҕ}{Җ}{җ}{Ҙ}{ҙ}{Қ}{қ}{Ҝ}{ҝ}%
25    {Ҟ}{ҟ}{Ҡ}{ҡ}{Ң}{ң}{Ҥ}{ҥ}{Ҧ}{ҧ}{Ҩ}{ҩ}{Ҫ}{ҫ}{Ҭ}{ҭ}{Ү}{ү}{Ұ}{ұ}{Ҳ}{ҳ}%
26    {Ҵ}{ҵ}{Ҷ}{ҷ}{Ҹ}{ҹ}{Һ}{һ}{Ҽ}{ҽ}{Ҿ}{ҿ}{Ӏ}{Ӄ}{ӄ}{Ӆ}{ӆ}{Ӈ}{ӈ}{Ӌ}{ӌ}%
27    {Ӎ}{ӎ}{Ӕ}{ӕ}{Ә}{ә}{Ӡ}{ӡ}{Ө}{ө}\do
28  {%
29    \begingroup\def\IeC{\protect\DeclareTextSymbolDefault}%
30    \protected@edef\@temp{\endgroup
31    \@ifl@t@r{\fmtversion}{2019/10/01}{\csname u8:\next\endcsname}{\next}}%
32    \@temp{X2}%
33  }%
34\else
35\ifspx@cyropt@TtwoA
36% original code by tex.sx user jfbu:
37%   https://tex.stackexchange.com/a/460305/
38% 63*2+1=127 Cyrillic glyphs as found in T2A 8bit TeX font-encoding
39  \@tfor\@tempa:=%
40    {ae}{a}{b}{chrdsc}{chvcrs}{ch}{c}{dje}{dze}{dzhe}{d}{erev}{ery}{e}%
41    {f}{ghcrs}{gup}{g}{hdsc}{hrdsn}{h}{ie}{ii}{ishrt}{i}{je}%
42    {kbeak}{kdsc}{kvcrs}{k}{lje}{l}{m}{ndsc}{ng}{nje}{n}{otld}{o}{p}{r}%
43    {schwa}{sdsc}{sftsn}{shch}{shha}{sh}{s}{tshe}{t}{ushrt}{u}{v}%
44    {ya}{yhcrs}{yi}{yo}{yu}{y}{zdsc}{zhdsc}{zh}{z}\do
45  {%
46    \expandafter\DeclareTextSymbolDefault\expandafter
47               {\csname cyr\@tempa\endcsname}{T2A}%
48    \expandafter\uppercase\expandafter{\expandafter
49                 \def\expandafter\@tempa\expandafter{\@tempa}}%
50    \expandafter\DeclareTextSymbolDefault\expandafter
51      {\csname CYR\@tempa\endcsname}{T2A}%
52  }%
53  \DeclareTextSymbolDefault{\CYRpalochka}{T2A}%
54\fi\fi
55\endinput
56