% \iffalse meta-comment
% !TEX encoding = UTF-8 Unicode
%
% Copyright 1989-2008 Apostolos Syropoulos, Johannes L. Braams
% and the authors listed elsewhere in this file. All rights reserved.
%
% This file is part of the babel-greek package.
% ---------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is Günter Milde <milde@users.sf.net>.
%
% Babel-greek is a contributed package providing support for the Greek
% language and script via the Babel system (https://ctan.org/pkg/babel).
%
% The list of derived (unpacked) files belonging to this work
% and covered by LPPL is defined by the unpacking script (babel-greek.ins)
% which is part of the package.
% \fi
% \CheckSum{1701}
%
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{babel-greek.dtx}
%</dtx>
%<code>\ProvidesLanguage{greek}
%\fi
%\ProvidesFile{babel-greek.dtx}
        [2023/08/18 1.14 Greek support for the babel system]
%\iffalse
%% File `babel-greek.dtx'
%% Greek language Definition File
%% Copyright © 1997, 2005 Apostolos Syropoulos, Johannes Braams
%% Copyright © 2013 -- 2023 Günter Milde
%
%% Please report errors to: Günter Milde <milde@users.sf.net>
%
%    This file is part of the babel-greek package, it provides the source
%    code for the greek language definition file. The original
%    version of this file was written by Apostolos Syropoulos.
%    It was then enhanced by adding code from kdgreek.sty from David
%    Kastrup <dak@gnu.org> with his consent.
%<*filedriver>
\documentclass{ltxdoc}
\usepackage{lmodern}
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=black}
\newcommand*{\Lopt}[1]{\textsf{#1}}
\newcommand*{\file}[1]{\texttt{#1}}
\newcommand*{\pkg}[1]{\textsf{#1}}
\newcommand*{\pkgref}[1]{\textsf{\href{https://ctan.org/pkg/#1}{#1}}}
\RecordChanges  % Write index file with \changes entries
\begin{document}
 \DocInput{babel-greek.dtx}
\end{document}
%</filedriver>
%\fi
% \GetFileInfo{babel-greek.dtx}
%
% \changes{greek-1.0b}{1996/07/10}{Replaced \cs{undefined} with
%    \cs{@undefined} and \cs{empty} with \cs{@empty} for consistency
%    with \LaTeX}
% \changes{greek-1.0b}{1996/10/10}{Moved the definition of
%    \cs{atcatcode} right to the beginning}
% \changes{greek-1.2}{1997/10/28}{Classical Greek is now a dialect}
% \changes{greek-1.2b}{1997/11/01}{Classical Greek is now called
%   ``Polutoniko'' Greek. The previous name was at least misleading}
% \changes{greek-1.2c}{1998/06/26}{This version conforms to version
%   2.0 of the CB fonts and consequently we added a few new
%   symbol-producing commands}
% \changes{greek-1.3a}{1998/07/04}{polutoniko is now an attribute to
%    Greek, no longer a `dialect'}
% \changes{greek-1.4}{2013/05/17}{new maintainer}
% \changes{greek-1.5}{2013/06/21}{bugfixes,
%    change some symbol macros to aliases,
%    LGR fixes via \cs{DeclareTextCommand} instead of
%    extrasgreek/noextrasgreek definitions,
%    LICR macros in string definitions,
%    LGR font encoding not used with XeTeX/LuaTeX.}
% \changes{greek-1.6}{2013/07/18}{fix \cs{@roman} and \cs{@Roman}
%    redefinition (thanks to Enrico Gregorio and Claudio Beccari),
%    load LICR macro definitions for Xe/LuaTeX.}
% \changes{greek-1.7}{2013/09/09}{Do not load euenc.def with XeTeX/LuaTeX.
%    Prevent re-loading lgrenc.def.}
% \changes{greek-1.7a}{2013/09/13}{Remove spurious ``fi''.}
% \changes{greek-1.7b}{2013/10/01}{Correct upcasing of babel strings
%    with Xe/LuaTeX.}
% \changes{greek-1.8}{2013/11/27}{Renamed to `babel-greek'.}
% \changes{babel-greek-1.08}{2013/11/27}{\file{greek.dtx} renamed to
%    \file{babel-greek.dtx} (but still generates \file{greek.ldf}).}
% \changes{babel-greek-1.08}{2013/11/27}{
%    Restore compatibility with Xe/LuaTeX in 8-bit and Unicode mode.}
% \changes{babel-greek-1.09g}{2016/09/07}{Babel 3.9i deprecated
%    \cs{textlatin} and fixed \cs{latinencoding}.}
% \changes{babel-greek-1.09i}{2020/02/28}{
%   Fix accent in \cs{seename} and \cs{alsoname}.}
%
% \title{Babel support for the Greek language}
% \author{Apostolos Syropoulos, Günter Milde}
% \maketitle
%
% Babel-greek is a contributed package providing support for the Greek
% language and script via the \pkgref{babel} system.
% See \href{babel-greek-doc.html}{babel-greek-doc} for an overwiew of the
% \pkg{babel-greek} package and links to requirements and related packages.
%
% The file \file{\filename}\footnote{
%   The file described in this section has version number \fileversion\
%   and was last revised on \filedate.
%   The original author is Apostolos Syropoulos, code from \file{kdgreek.sty}
%   by David Kastrup was used.}
% is the literate source for the Babel language definition file
% \file{greek.ldf}.
%
% \tableofcontents
%
% \section{Requirements}
%
% Typesetting Greek with Babel requires (of course) the \pkgref{babel}
% package, support for Greek font encodings (\pkgref{greek-fontenc})
% and a \href{README.html#greek-text-fonts}{text font supporting the
% Greek script}.
%
% The \href{https://ctan.org/pkg/cbgreek-complete}{CB Greek fonts}
% created by \textsc{Claudio Beccari}\footnote{Apostolos Syropoulos
%   wishes to thank Claudio Beccari for his
%   patience, collaboration, comments and suggestions.}
% are a complete set of 8-bit \TeX{} fonts matching \textsc{Knuth}'s
% Computer Modern.
% The package \pkgref{cbfonts-fd} sets them up as Greek substitute
% for the Computer Modern and Latin Modern font families.
% The standard |\DeclareFontFamilySubstitution| macro can be used to set up
% Greek supplements for other \TeX{} font families (like Times or Palatino).
%
% Unicode fonts (used with XeTeX or LuaTeX) provide slots for all Unicode
% characters in one font but commonly only a subset of the actual glyphs.
% \textbf{Many Unicode fonts, including the default
% \href{https://ctan.org/pkg/lm}{Latin Modern},
% do not support the Greek script!}
% Authors need to set up an alternative font like CM Unicode, Linux Libertine,
% or DejaVu with \pkgref{fontspec} or the \pkgref{babel} font configuration
% system.
%
% With 8-bit TeX and XeTeX, hyphenation patterns must be
% pre-loaded in the format file.
% This is a limitation by TeX, common to all languages.
% The LuaTeX engine loads hyphenation patterns dynamically.
%
%
% \section{Usage}
%
% To activate Greek language support with babel, specify the option
% \Lopt{greek}, either as global option or as option to the
% \pkg{babel} package. Remember, that the \emph{last} language
% option determines the document language, e.g.
% \begin{verbatim}
% \usepackage[greek,english]{babel}\end{verbatim}
% activates support for Greek text parts in an English document.
%
% \DescribeMacro\selectlanguage
% The Babel core provides two commands to switch the active language:
% The declaration |\selectlanguage{greek}| switches to the Greek language.
% \DescribeMacro\foreignlanguage
% The macro \verb|\foreignlanguage{greek}{<some text>}| sets its second
% argument in the Greek language. This is intended for short text parts.
% For details see the \pkgref{babel} documentation.
%
%
% \subsection{Language attributes}
%
% The attributes \hyperref[sec:polutoniko]{\Lopt{polutoniko}}^^A
%   \footnote{with the alias \Lopt{polytonic}},
% and \hyperref[sec:ancient]{\Lopt{ancient}} allow the specification
% of the used orthography.
% The language variant affects automatic hyphenation, spelling of
% auto-generated strings and support for multi-accented letters.
%
% The default is modern \emph{monotonic} Greek, while
% \begin{verbatim}
%   \usepackage[english,greek]{babel}
%   \languageattribute{greek}{polutoniko}\end{verbatim}
% sets the document language to modern Greek with
% \emph{\href{https://en.wikipedia.org/wiki/Greek_diacritics}{polytonic}}
% spelling and
% \begin{verbatim}
%   \usepackage[english,greek]{babel}
%   \languageattribute{greek}{ancient}\end{verbatim}
% sets the document language to \emph{ancient} Greek.
%
% The \hyperref[sec:keep-semicolon]{\Lopt{keep-semicolon}} language
% attribute (new in babel-greek 1.13) ensures that a SEMICOLON character (;)
% can be used as input for the similar looking Greek question mark
% (\emph{erotimatiko}).
% By default, the LGR font encoding uses the QUESTION MARK (?)
% as input for the \emph{erotimatiko} and maps the SEMICOLON
% to an \emph{ano teleia} (·).
%
% \subsection{Modifiers \label{sec:modifiers}}
%
% \changes{babel-greek-1.12}{2023/03/04}{
%   New modifiers \Lopt{local-LGR-fixes} and \Lopt{no-LGR-fixes}.}
% \changes{babel-greek-1.14}{2023-08-18}{
%   New modifier \Lopt{local-MakeUppercase-fixes}.}
%
% All language attributes may also be used as modifiers, e.g.
% \begin{verbatim}
%   \usepackage[greek.polutoniko,english]{babel}\end{verbatim}
% In addition, there are modifiers that cannot be set with
% |\languageattribute|.
%
% The \hyperref[sec:lgr-redefinitions]{\Lopt{local-LGR-fixes}} modifier
% restricts the re-definitions in section~\ref{sec:lgr-redefinitions}
% to text parts using the Greek language.
% The \hyperref[sec:lgr-redefinitions]{\Lopt{no-LGR-fixes}} modifier
% disables them completely. You may try, e.g.,
%    \begin{verbatim}
%    \usepackage[greek.local-LGR-fixes,english]{babel}\end{verbatim}
% as a last ressort if the workarounds make a document uncompilable
% and using Xe/LuaTeX with Unicode fonts is not an option.
% Check for problems with enumerations in Greek text parts and with
% Roman and Greek numerals everywhere (especially in the ToC).
%
% The \hyperref[sec:MakeUppercase-fixes]{\Lopt{local-MakeUppercase-fixes}}
% modifier skips the mapping of standard accents to ``capital'' accents
% in section~\ref{sec:MakeUppercase-fixes}.
%
% These modifiers are provisional, naming and behaviour may change.
%
%
% \subsection{Language hooks \label{sec:language-hooks}}
%
% \DescribeMacro\extrasgreek
% The macro |\extrasgreek| is called by \pkgref{babel} on every switch
% of the active language to Greek.
% \DescribeMacro\noextrasgreek
% The macro |\noextrasgreek| is called when switching away from Greek.
% Package and document authors can add setup and tear-down code
% to the hooks with the help of the |\addto| command provided by \pkg{babel}.
% The first call of |\addto\<hookname>{<code>}| initializes the hook,
% subsequent calls append |<code>| to its definition.
%
% \pkg{Babel-greek} uses these hooks to, e.g, select correct hyphenation
% patterns (cf.\ section~\ref{sec:hyphenation-patterns}) or ensure a font
% encoding supporting the Greek script is used for Greek text parts
% (cf.\ section~\ref{sec:font-setup}).
%
%
% \subsection{Input of Greek text}
%
% There are several alternatives to write Greek text.
% \begin{itemize}
%  \item Literal input using the UTF-8 encoding is the standard input method.
%    With 8-bit TeX, this requires the package \pkgref{greek-inputenc}
%    and special handling for Latin letters and some symbols
%    (consider using the \hyperref[sec:keep-semicolon]{\Lopt{keep-semicolon}}
%    attribute).
%
%    With the packages \pkgref{inputenc} and \pkgref{greek-inputenc},
%    literal Greek characters can also be input using the legacy encodings
%    \emph{iso-8859-7} and \emph{macgreek}.
%
%  \item The Latin transliteration defined by the LGR font encoding
%    is explained in the file \file{\href{usage.pdf}{usage.pdf}}.
%
%   \item The package \pkgref{greek-fontenc}
%    defines \emph{LaTeX internal character representation} (LICR) macros
%    for Greek letters and text symbols. It is required by \pkg{babel-greek}.
%    The LICR macros |\textAlpha| \ldots |\textomega|
%    are a safe but cumbersome method to input Greek characters.
%
%  \item The \pkg{alphabeta} package, bundled with \pkgref{greek-fontenc},
%    makes the short macro names |\Alpha| \ldots |\omega| available
%    in both, text and math mode.
% \end{itemize}
%
% \subsection{Greek vs. Latin script}
%    When switching the language to Greek, \pkg{babel-greek} ensures that the
%    Greek script is supported.
%    The following macros allow the use of Greek vs.\ Latin script without
%    changing the active language:
%
%  \DescribeMacro\greekscript
%    The \emph{TextCommand}\footnote{For a discussion of TextCommands, see
%    the \emph{LaTeX font guide}.}
%    |\greekscript| switches to a font encoding
%    supporting the Greek script.
%  \DescribeMacro\greektext
%    The declaration |\greektext| always switches the font encoding
%    to LGR. Both declarations do not change the active language.
%
%  \DescribeMacro\latintext
%    |\latintext| (defined by the Babel core, deprecated since March 2014)
%    can be used to switch back to an encoding supporting the Latin script.
%
%  \DescribeMacro\ensuregreek
%    The function |\ensuregreek| takes one argument which
%    is typeset using a font encoding supporting the Greek script.
%    It only switches the font encoding if required (i.e. if the current
%    font encoding does not support Greek letters and symbols).
%
%  \DescribeMacro\lgrfont
%    The function |\lgrfont|^^A
%      \footnote{The legacy name \cs{textgreek} is available as alias.}
%    switches to the non-standard Greek 8-bit font encoding LGR.
%    Hint: Use |\lgrfont|, if you want to use the
%    \emph{Latin transliteration} input method and |\ensuregreek| else.
%
%  \DescribeMacro\ensureascii
%    The Babel core defines |\ensureascii| that typesets its
%    argument using an ASCII-compatible ``standard text font encoding''.
%    It is the recommended way for text parts requiring Latin letters
%    but no language switch.
%
%
% \subsection{Greek numbering \label{sec:greek-numbering}}
%    The \href{https://en.wikipedia.org/wiki/Greek_numerals}
%    {Greek (Milesian) alphabetical numbering system}\footnote{
%      Attic numerals, which predate the Milesian numerals
%      are implemented in package |athnum|.}
%    is still used in everyday life for short enumerations.
%    It was used for dates and numbers in the range of several thousands
%    in official editions up to the beginning of the 20th century and
%    is still used by the Eastern Orthodox Church and certain scholars.
%    Unfortunately, most Greeks don't know how to write Greek numbers
%    bigger than 20 or 30.
%
%  \DescribeMacro{\greeknumeral}
%    The command |\greeknumeral| makes it possible to typeset Greek
%    numerals for numbers up to \hbox{999\,999}.
%  \DescribeMacro{\Greeknumeral}
%    |\Greeknumeral| is the ``uppercase'' version of this macro.
%    Here are the conventions:
%    \begin{itemize}
%    \item There is no Greek numeral for any number less than or equal
%      to $0$.
%    \item Numbers from $1$ to $9$ are denoted by letters
%      \emph{alpha}, \emph{beta}, \emph{gamma}, \emph{delta}, \emph{epsilon},
%      \emph{stigma}\footnote{
%        cf.\ \hyperref[greeknumeralsix]{\cs{greeknumeralsix}}},
%      \emph{zeta}, \emph{eta}, \emph{theta}, followed by a \emph{keraia},
%      a mark similar to the mathematical symbol ``prime''.
%    \item Decades from $10$ to $90$ are denoted by letters \emph{iota},
%      \emph{kappa}, \emph{lambda}, \emph{mu}, \emph{nu}, \emph{xi},
%      \emph{omikron}, \emph{pi}, \emph{koppa}\footnote{
%        cf.\ \hyperref[greeknumeralninety]{\cs{greeknumeralninety}}},
%      again followed by the numeric mark.
%    \item Hundreds from $100$ to $900$ are denoted by letters \emph{rho},
%      \emph{sigma}, \emph{tau}, \emph{upsilon}, \emph{phi}, \emph{chi},
%      \emph{psi}, \emph{omega}, \emph{sampi}, followed by the
%      numeric mark.
%    \item Any number between $1$ and $999$ is obtained by a group of
%      letters denoting the hundreds decades and units, followed by a
%      numeric mark.
%    \item To denote thousands one uses the same method, but this time
%      the mark is an \emph{aristeri keraia}, a prime inverted by 180 degrees
%      and placed in front of the letter, under the baseline.
%      When a group of letters denoting thousands is followed by a group of
%      letters denoting a number under $1000$, both marks are used.
%    \end{itemize}
%    The shape of the obsolete characters used for number 6
%    (\emph{digamma}/\emph{stigma}) and 90 (\emph{koppa}) evolved over time
%    and different characters are in use for them today.
%    The following four macros can be re-defined to configure
%    |\greeknumeral| and |\Greeknumeral| respectively:
%
%  \DescribeMacro\greeknumeralsix
%    \phantomsection\label{greeknumeralsix}
%    Originally, the sixth letter of the alphabet, standing for 6, was the
%    \emph{digamma} -- just as its Latin equivalent F is the sixth letter of
%    the Latin alphabet.
%    As Greek script turned to uncial and then lowercase, digamma changed its
%    shape – it became similar to the ligature for sigma-tau (\emph{stigma}).
%    People started using the stigma or the digraph sigma tau\footnote{
%      Mainly because the letter stigma is not always available, so people
%      opted to write down the first two letters of its name instead.}.
%    The macro |\greeknumeralsix| allows configuring the symbol for the
%    number 6 in |\greeknumeral|,
%  \DescribeMacro\greeknumeralSix
%    the macro |\greeknumeralSix| does the same for |\Greeknumeral|.
%    The default values are |\textstigma| and |\textStigma|.
%
%  \DescribeMacro\greeknumeralninety
%    \phantomsection\label{greeknumeralninety}
%    Three symbols are in use for the number 90:
%    Classicists prefer the q-like ``archaic'' \emph{koppa}
%    and, more rarely, its uncial form\footnote{
%    resembling CYRILLIC LETTER KOPPA or GOTHIC LETTER NINETY},
%    modern Greek uses the zig-zag shaped ``modern'' \emph{koppa}
%    exclusively. The macro |\greeknumeralninety| allows configuring
%    the symbol for the number 90 in |\greeknumeral|,
%  \DescribeMacro\greeknumeralNinety
%    the macro |\greeknumeralNinety| does the same for |\Greeknumeral|.
%    The default values are |\textkoppa| and |\textKoppa| for modern Greek
%    and |\textqoppa| and |\textqoppa| for ancient Greek.
%
%    There is no such variation in the shape of the \emph{sampi}
%    used for the number 900.
%
% \StopEventually{}
%
%
% \section{Implementation}
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
% \changes{greek-1.0b}{1996/11/02}{
%          Use \cs{LdfInit} to perform initial checks.}
%    \begin{macrocode}
%<*code>
\LdfInit\CurrentOption{captions\CurrentOption}
%    \end{macrocode}
%    When the option \Lopt{polutonikogreek} was used, redefine
%    |\CurrentOption| to prevent problems later on.
%    \begin{macrocode}
\gdef\CurrentOption{greek}
%    \end{macrocode}
%    Set up the Babel shorthands feature. It is used later to insert literal
%    |~| characters with polytonic Greek and LGR and to prevent LGR converting
%    a literal semicolon |;| to an \emph{ano teleia} |·|.
% \changes{babel-greek-1.13}{2023/03/15}{
%          Setup \cs{languageshorthands} for all language variants.}
%    \begin{macrocode}
\addto\extrasgreek{\languageshorthands{greek}}
%    \end{macrocode}
%
%
% \subsection{Hyphenation patterns \label{sec:hyphenation-patterns}}
%
%    When this file is read as an option, i.e. by the |\usepackage|
%    command, \texttt{greek} could be an `unknown' language in
%    which case we have to make it known.  So we check for the
%    existence of the three variants of the Greek language
%    |\l@greek|, |\l@monogreek|, and |l@ancientgreek|
%    and set the hyphenation to |\language0| for the missing ones.
% \changes{babel-greek-1.09}{2014/07/20}{
%   Load correct hyphenation patterns (patch by Claudio Beccari).}
% \changes{babel-greek-1.09c}{2014/10/21}{
%   Fix dummy hyphenation language names (patch Ulrike Fischer).}
%    \begin{macrocode}
\ifx\l@greek\@undefined
  \@nopatterns{greek}
  \adddialect\l@greek 0
\fi
\ifx\l@monogreek\@undefined
  \@nopatterns{greek}
  \adddialect\l@monogreek 0
\fi
\ifx\l@ancientgreek\@undefined
  \@nopatterns{greek}
  \adddialect\l@ancientgreek 0
\fi
\newcount\bbl@monogreek \bbl@monogreek=\l@monogreek
\newcount\bbl@polygreek \bbl@polygreek=\l@greek
\newcount\bbl@ancientgreek \bbl@ancientgreek=\l@ancientgreek
%    \end{macrocode}
% Use the \emph{language hooks} (cf.\ section~\ref{sec:language-hooks})
% to set the correct hyphenation patterns.
% (We collect setup code for the language variants \Lopt{polutoniko} and
% \Lopt{ancient} in |\extraspolutonikogreek| and |\extrasancientgreek|;
% \DescribeMacro\extraspolutonikogreek
% their content is added to |\extrasgreek| by the respective language
% attributes, cf.\ section~\ref{sec:language-variants}).
% \DescribeMacro\extrasancientgreek
% ^^A TODO: Move the |\let\l@greek=...| definitions to the language
% ^^A attribute functions (as we only have one language variant per document)
% ^^A or use the hooks to allow more than one language variant?
% \changes{greek-1.5a}{2013/06/27}{provide \cs{extraspolutonikogreek} also
%    for Xe/LuaTeX.}
%    \begin{macrocode}
\addto\extrasgreek{\let\l@greek=\bbl@monogreek}
\addto\extraspolutonikogreek{\l@greek=\bbl@polygreek}
\addto\extrasancientgreek{\l@greek=\bbl@ancientgreek}
%    \end{macrocode}
%
% \begin{macro}{\providehyphenmins}
% \changes{greek-1.3h}{2000/09/22}{Now use \cs{providehyphenmins} to
%                                  provide a default value}
%   The macro |\providehyphenmins| is used to set the correct values of
%   the hyphenation parameters |\lefthyphenmin| and |\righthyphenmin|.
%   Yannis Haralambous has suggested the value 1.
%    \begin{macrocode}
\providehyphenmins{\CurrentOption}{\@ne\@ne}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Language attributes}
%
% The Babel core provides the command |\bbl@declare@ttribute| for the
% declaration of language attributes in language definition files.
% It takes three arguments:
% the name of the language, the attribute to be defined,
% and the code to be executed when the attribute is to be used.
% If the language attribute is selected, the third argument is executed
% after reading the *.ldf file.
%
% \label{sec:language-variants}
% \subsubsection{\Lopt{polutoniko}\label{sec:polutoniko}}
%    The |polutoniko| language attribute selects the ``polytonic'' spelling.
%
%    We use an auxiliary function for the setup part used with several
%    language attributes:
%    Add the expansion of |\extraspolutonikogreek| to |\extrasgreek|
%    to set up support for multi-accented characters and
%    hyphenation patterns for the polytonic orthography
%    and use polytonic spelling for auto-strings (captions and month names).
%    More code is added later (cf. section~\ref{sec:character-codes}).
%    \begin{macrocode}
\def\bbl@greek@setup@polytonic{%
  \expandafter\addto\expandafter\extrasgreek
    \expandafter{\extraspolutonikogreek}%
  \let\captionsgreek\captionspolutonikogreek
  \let\gr@month\gr@polutoniko@month
}
%    \end{macrocode}
%    Now declare the option. For backwards compatibility,
%    modern Greek with ``polytonic'' spelling can also be
%    selected via the dummy language \Lopt{polutonikogreek}.
%    However, it is not possible to use both options,
%    \Lopt{greek} and \Lopt{polutonikogreek} in one document.^^A
%      \footnote{Use of more than one Greek orthograpies in one document
%                is possible with \cs{babelprovide}.
%                However, there are side-effects.
%                See the example in \file{test-greek.tex}.}
%    We also define aliases to allow language switching commands using
%    the language name |polutonikogreek|:
% \changes{greek-1.3f}{1999/09/29}{
%          Added some code to make older documents work.}
% \changes{greek-1.3g}{2000/02/04}{\cs{noextraspolutonikogreek} was missing.}
%    \begin{macrocode}
\bbl@declare@ttribute{greek}{polutoniko}{%
  \bbl@greek@setup@polytonic
  \let\l@polutonikogreek\l@greek
  \let\datepolutonikogreek\dategreek
  \let\extraspolutonikogreek\extrasgreek
  \let\noextraspolutonikogreek\noextrasgreek
}
%    \end{macrocode}
%
% \subsubsection{\Lopt{polytonic}}
%
% \changes{babel-greek-1.12}{2023/03/04}{
%   New language attribute \Lopt{polytonic} (alias for \Lopt{polutoniko}).}
%
% The |polytonic| language attribute is an alias for the
% attribute |polutoniko| matching the spelling for this orthography
% variant in \pkg{polyglossia} and Babel |*.ini| files.
%    \begin{macrocode}
\bbl@declare@ttribute{greek}{polytonic}{%
  \bbl@greek@setup@polytonic
}
%    \end{macrocode}
%
% \subsubsection{\Lopt{ancient}\label{sec:ancient}}
%
% \changes{babel-greek-1.09}{2014/07/20}{Add support for ancient Greek.}
%
% The \Lopt{ancient} language attribute is used for classical Greek.
% This attribute adds the expansion of |\extraspolutonikogreek| and
% |\extrasancientgreek| to |\extrasgreek| to set up support for
% multi-accented characters and ancient hyphenation patterns.
%    \begin{macrocode}
\bbl@declare@ttribute{greek}{ancient}{%
  \bbl@greek@setup@polytonic
  \expandafter\addto\expandafter\extrasgreek
    \expandafter{\extrasancientgreek}%
%    \end{macrocode}
%    Auto-strings (captions) are specific to ancient Greek while |\today|
%    uses modern polytonic month names (as there existed incompatible
%    sets of month names and no common calendar in ancient Greece).
%    \begin{macrocode}
  \let\captionsgreek\captionsancientgreek
%    \end{macrocode}
%    Classicists tend to use the Q-like ``archaic'' koppa for the number 90.
%    Thus, for classical Greek, we set the default to the  ``archaic'' koppa
%    (cf.\ section~\ref{sec:greek-numbering}).
%    \begin{macrocode}
  \renewcommand{\greeknumeralninety}{\textqoppa}%
  \renewcommand{\greeknumeralNinety}{\textQoppa}%
}
%    \end{macrocode}
%
%
% \subsubsection{\Lopt{keep-semicolon}\label{sec:keep-semicolon}}
%
% \changes{babel-greek-1.13}{2023/03/15}{
%    New language attribute \Lopt{keep-semicolon}.}
% \changes{babel-greek-1.13}{2023/03/15}{
%    Don't use text command in math mode.}
% The LGR font encoding uses the Latin question mark as input for
% the Greek question mark (\emph{erotimatiko}) and maps the semicolon
% to a middle dot (\emph{ano teleia}).
% As a result, Unicode-encoded texts that use the semicolon (;) as
% \emph{erotimatiko} end up with an \emph{ano teleia} (·) in its place!
%
% With the \texttt{keep-semicolon} language attribute, 003B SEMICOLON is made
% active and inserts an \emph{erotimatiko} also with LGR encoded fonts:
%    \begin{macrocode}
\bbl@declare@ttribute{greek}{keep-semicolon}{%
  \def\bbl@tempa{LGR}
  \ifx\greekfontencoding\bbl@tempa
    \ProvideTextCommandDefault{\textsemicolon}{;}
    \ProvideTextCommand{\textsemicolon}{LGR}{\texterotimatiko}
    \initiate@active@char{;}
    \addto\extrasgreek{\bbl@activate{;}}
    \addto\noextrasgreek{\bbl@deactivate{;}}
    \declare@shorthand{greek}{;}{\TextOrMath{\textsemicolon}{;}}
  \fi
}
%    \end{macrocode}
%
% \subsection{Report unsupported modifiers}
%
% \changes{babel-greek-1.13.2}{2023-06-01}{Warn of unsupported modifiers.}
%
% Test for unsupported (or misspelled) \hyperref[sec:modifiers]{modifiers}
% (code contributed by Javier Bezos).
%    \begin{macrocode}
\def\bbl@greek@modifiers{,%
  polutoniko,polytonic,ancient,keep-semicolon,%
  local-LGR-fixes,no-LGR-fixes,local-MakeUppercase-fixes,}
\ifx\BabelModifiers\relax\else
  \bbl@foreach\BabelModifiers{%
    \@expandtwoargs\in@{,#1,}{\bbl@greek@modifiers}
    \ifin@\else
      \bbl@warning
        {Unknown/misspelled modifier '#1' in '\CurrentOption'.
         See "babel-greek.pdf" for valid modifiers.}
    \fi}%
\fi

%    \end{macrocode}
%
% \subsection{Font setup \label{sec:font-setup}}
%
% \subsubsection{Greek font encoding \label{sec:greekfontencoding}}
%
% \changes{babel-greek-1.08}{2013/11/27}{
%          Load \file{euenc.def} if EU1 or EU2 font encoding is detected.}
% \changes{greek-1.2a}{1997/10/31}{filename \file{lgrenc.def} now lowercase}
% \changes{greek-1.4}{2013/05/17}{
%          \file{lgrenc.def} moved to the separate package `greek-fontenc'}
% \changes{greek-1.5}{2013/06/21}{LGR setup skipped with XeTeX/LuaTeX}
% \changes{greek-1.7}{2013/09/09}{Do not load euenc.def with XeTeX/LuaTeX
%                     (too complicated to get it right).}
% \changes{babel-greek-1.08}{2013/11/30}{
%          Check for EU1/EU2 font encoding instead of engine}
% \changes{babel-greek-1.09f}{2016/02/04}{Check also for standard
%          Unicode text encoding ``TU'' (new in fontspec v2.5a).}
% \changes{babel-greek-1.09i}{2020/02/27}{Update check for Unicode fonts.}
% \changes{babel-greek-1.10}{2020/11/10}{Use TU with Xe/LuaTeX.}
% \begin{macro}{\greekfontencoding}
%   The macro |\greekfontencoding| holds the name of the font
%   encoding\footnote{cf.\
%     \href{https://mirrors.ctan.org/macros/latex/base/encguide.pdf}
%     {encguide.pdf}}
%   used to ensure support of the Greek script.
%   The default is LGR for 8-bit TeX and TU for Xe/LuaTeX.\footnote{
%     Document authors must ensure that the selected font actually contains
%     the required glyphs.
%
%     LGR-encoded fonts can be used alongside Unicode fonts with
%     XeTeX/LuaTeX to enable the input of Greek letters via the Latin
%     transliteration (with some limitations, see \file{test-greek.tex}).}
%   It can be overridden defining |\greekfontencoding| with a custom value
%   before loading \pkg{babel}.
%
% Also store the name of the \emph{encoding definition file}\footnote{
%   see \href{https://www.latex-project.org/help/documentation/fntguide.pdf}
%   {fntguide.pdf}}
% with the extended Greek setup for the Greek font encoding.
%    \begin{macrocode}
\ifdefined\UnicodeEncodingName % set by XeTeX/LuaTeX
  \providecommand*{\greekfontencoding}{\UnicodeEncodingName}
  \providecommand*{\bbl@greek@fontencdef}{tuenc-greek}
\else
  \providecommand*{\greekfontencoding}{LGR}
  \providecommand*{\bbl@greek@fontencdef}{lgrenc}
  % TODO the more generic version fails :(
  % \edef\bbl@greek@fontencdef{\lowercase{\greekfontencoding}enc}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Ensure loading of Greek font encoding definitions.
%                \label{load-greek-font-encoding-definitions}}
%
% If the \emph{encoding definition file} for |\greekfontencoding| is not yet
% loaded, do this now:
%    \begin{macrocode}
\@ifl@aded{def}{\bbl@greek@fontencdef}{}
{% else
  \InputIfFileExists{\bbl@greek@fontencdef .def}{}
  {% else
    \bbl@error{Font support for the Greek script missing.\\
               babel-greek can't typeset Greek.\\
               Install the "greek-fontenc" package\\
               or use XeTeX/LuaTeX with polyglossia.}
              {I can't find the \bbl@greek@fontencdef .def file
               for the Greek fonts (encoding \greekfontencoding)}
    \@@end
  }
}
%    \end{macrocode}
% If the PU font encoding is defined (by \pkgref{hyperref}), load extended
% Greek support for it. Do this in the |\AtBeginDocument| hook because
% documents may load \pkg{hyperref} after \pkg{babel}.
% We cannot rely on |@| being a letter when the hook is called and we must
% not use |\makeatother| in the hook
% (\href{https://tex.stackexchange.com/questions/62583/is-it-really-bad-to-use-makeatletter-and-makeatother-in-a-package-or-class-fil}
% {explanation at stackexchange}).
% We use a temporary function to save and restore the previous catcode.
% \changes{babel-greek-1.10}{2020/11/10}{Load \file{puenc-greek.def}
%          from \pkg{greek-fontenc} if used with hyperref.}
% \changes{babel-greek-1.12}{2023/03/04}{
%          Don't use \cs{makeatother} in \cs{AtBeginDocument}.}
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifl@aded{def}{puenc}%
    {\@ifl@aded{def}{puenc-greek}
       {}%
       {\edef\RestoreAtCatcode{\catcode`@=\the\catcode`@\relax}%
        \makeatletter
        \InputIfFileExists{puenc-greek.def}%
          {}%
          {\bbl@warning{I cannot find the "puenc" Greek fixes
                        from "greek-fontenc".}%
          }%
        \RestoreAtCatcode
       }%
    }% end "puenc.def loaded" branch
    {}% empty "puenc.def not loaded" branch
}
%    \end{macrocode}
%
% \subsubsection{Font encoding switches \label{sec:font-encoding-switches}}
% \begin{macro}{\greekscript}
%   The TextCommand\footnote{See
%      \href{https://www.latex-project.org/help/documentation/fntguide.pdf}
%      {fntguide.pdf} for more info about \emph{TextCommands}.}
%   |\greekscript| is a declaration that switches the font
%   encoding to |\greekfontencoding|.
%   The extended Greek font encoding definitions from \pkgref{greek-fontenc}
%   define empty local variants for TU, LGR, and PU, so that the declaration
%   does nothing if the active font encoding supports the Greek script.
% \changes{babel-greek-1.08}{2013/11/27}{
%    New TextCommands ``greekscript'' and ``ensuregreek''.}
% \changes{babel-greek-1.08a}{2013/12/03}{Set `encodingdefault'
%   to fix Greek in footnotes etc. with document language Greek.}
%    \begin{macrocode}
\ProvideTextCommandDefault{\greekscript}{%
  \fontencoding{\greekfontencoding}\selectfont
  \def\encodingdefault{\greekfontencoding}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ensuregreek}
%   The TextCommand |\ensuregreek| sets its argument in |\greekfontencoding|
%   if the current font encoding does not provide a (typically empty) local
%   variant.
%    \begin{macrocode}
\ProvideTextCommandDefault{\ensuregreek}[1]{%
  \leavevmode {\greekscript #1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\BabelGreekRestoreFontEncoding}
%   The declaration |\BabelGreekRestoreFontEncoding| changes the font encoding
%   to the value it had before the switch to the Greek language. It does
%   nothing, if the language switch did not trigger a font encoding switch.
% \changes{babel-greek-1.12}{2023/03/04}{New macro.}
%    \begin{macrocode}
\def\BabelGreekRestoreFontEncoding{%
  \ifx\cf@encoding\BabelGreekPreviousFontEncoding
  \else
    \let\encodingdefault\BabelGreekPreviousFontEncoding
    \fontencoding{\encodingdefault}\selectfont
  \fi
}
%    \end{macrocode}
% \end{macro}
% Add font encoding switches to the language hooks
% (cf.\ section~\ref{sec:language-hooks}) to ensure a font encoding
% supporting the Greek script is used in Greek text parts:
% \changes{greek-1.5}{2013/06/21}{LGR not used with XeTeX/LuaTeX.}
% \changes{babel-greek-1.08}{2013/11/27}{
%          Use EU1 or EU2 for Latin script if available}
% \changes{babel-greek-1.11}{2020/11/20}{Save/restore previous font encoding
%          instead of switching to \cs{latinencoding} when leaving Greek.}
% \changes{babel-greek-1.12}{2023/03/04}{Save previous font encoding
%          in \cs{BabelGreekPreviousFontEncoding}.}
%    \begin{macrocode}
\addto\extrasgreek{%
  \let\BabelGreekPreviousFontEncoding\cf@encoding
  \greekscript}
\addto\noextrasgreek{\BabelGreekRestoreFontEncoding}
%    \end{macrocode}
%
% \subsubsection{Additional commands for the LGR font encoding}
%
% The actions in this section add ``harmless'' setup steps for the LGR
% font encoding that cannot be done in the \file{lgrenc.def}
% encoding definition file.
%
% We do this only, if the LGR font encoding is defined (either by \pkg{fontenc}
% or \pkg{babel-greek}), but also if it is not the |\greekfontencoding|:
%    \begin{macrocode}
\@ifl@aded{def}{lgrenc}{%
%    \end{macrocode}
%
%  \begin{macro}{\greektext}
%    The declaration |\greektext| switches to LGR. Use this if you explicitly
%    require LGR (e.g. to use the Latin transliteration or special fonts).
%    Use |\greekscript| instead, if you want to avoid a font encoding change
%    if the current font encoding already supports the Greek script (e.g. TU).
%    For shorter pieces of text, the |\lgrfont| (see below) or |\ensuregreek|
%    commands should be used. Cf.\ section~\ref{sec:font-encoding-switches}.
%    \begin{macrocode}
  \DeclareRobustCommand{\greektext}{%
    \fontencoding{LGR}\selectfont
    \def\encodingdefault{LGR}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\lgrfont}
%    This command takes an argument which is typeset using the
%    LGR font encoding.
%
%    The original name |\textgreek| is deprecated because of its ambiguitiy:
%    The command does not change the text \emph{language} but only the
%    font encoding, which allows the use of the Greek \emph{script}
%    but does not activate Greek hyphenation and case-changing rules.
% \changes{greek-1.0b}{1996/09/23}{Added a level of braces to keep
%                                  encoding change local}
% \changes{greek-1.3k}{2003/03/19}{Added \cs{leavevmode} as was done
%                                  with \cs{latintext}}
% \changes{babel-greek-1.12}{2023/03/04}{
%   Simplified implementation using \cs{\DeclareTextFontCommand}.
%   Name changed from \cs{textgreek} to \cs{lgrfont}.}
%    \begin{macrocode}
  \DeclareTextFontCommand{\lgrfont}{\greektext}
  \let\textgreek\lgrfont
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\textol}
%    The \href{https://ctan.org/pkg/cbgreek-complete}{CB Greek fonts}
%    contain an outline family. In order to make it available,
%    we define the command |\textol|. (This font-specific macro does not
%    fit in a language definition file and is only kept for backwards
%    compatibility.)
%    \begin{macrocode}
  \def\outlfamily{\usefont{LGR}{cmro}{m}{n}}
  \DeclareTextFontCommand{\textol}{\outlfamily}
%    \end{macrocode}
%  \end{macro}
%  Add LGR-specific variants to some \emph{TextCommands}
%  that use Latin characters in their default definition.
%  These definitions cannot be done in \file{lgrenc.def} because they rely
%  on |\ensureascii| (defined by \pkg{babel}).
% \changes{greekfdd-2.2c}{1999/04/05}{Fixed typos, \cs{textrademark}
%          misses a `t', \cs{copyright} should be \cs{textcopyright}}
% \changes{greekfdd-2.2d}{1999/04/25}{removed redefinition of \cs{\&}}
% \changes{greek-1.4}{2013/05/17}{moved here from \file{lgrenc.def} because
%          the definitions require the \cs{latintext} macro defined by Babel.}
% \changes{greek-1.5}{2013/05/27}{enable use of "textcomp" characters
%          for "textcopyright" and "textregistered" macros}
% \changes{babel-greek-1.08}{2013/11/27}{
%          Use font-encoding specific TextCommands.}
% \changes{babel-greek-1.12}{2023/03/04}{Drop definition for \cs{\SS}.}
%    \begin{macrocode}
  \ProvideTextCommand{\textcopyright}{LGR}{\ensureascii{\textcopyright}}
  \ProvideTextCommand{\textregistered}{LGR}{\ensureascii{%
                                                       \textregistered}}
  \ProvideTextCommand{\texttrademark}{LGR}{\ensureascii{\texttrademark}}
%    \end{macrocode}
%
%  \begin{macro}{\textampersand}
%    LGR has a ``middle dot'' glyph at the place of the ampersand.
%    Provide the \emph{TextCommand} |\textampersand| and an LGR-specific
%    version. It is used in the next section to define a version of |\&|
%    that also works in LGR.
% \changes{greek-1.5}{2013/06/15}{Make \cs{\&} a TextCommand}
% \changes{babel-greek-1.09j}{2020/03/17}{Fix ampersand in math.}
%    \begin{macrocode}
  \let\bbl@greek@original@amp\&
  \ProvideTextCommandDefault{\textampersand}{\bbl@greek@original@amp}
  \ProvideTextCommand{\textampersand}{LGR}{%
    \ensureascii{\bbl@greek@original@amp}}
%    \end{macrocode}
%  \end{macro}
% \begin{macro}{\EnsureStandardFontEncoding}
%   The TextCommand |\EnsureStandardFontEncoding| can be used to make
%   existing commands ``LGR-proof''. It makes sure its argument is typeset
%   using a \href{https://mirrors.ctan.org/macros/latex/base/encguide.pdf}
%   {standard text font encoding}.
%   The default is an empty command: almost all commonly used font encodings
%   are standard text encodings -- LGR is the notable exception.
%   The local LGR variant uses |\ensureascii| from the Babel core that comes
%   with elaborate heuristics to select a suitable standard font encoding.
%   A special clause for \pkg{hyperref} avoids warnings from this package.
% \changes{babel-greek-1.12}{2023/03/04}{New TextCommand.}
%    \begin{macrocode}
  \ProvideTextCommandDefault{\EnsureStandardFontEncoding}{\@firstofone}
  \ProvideTextCommand{\EnsureStandardFontEncoding}{LGR}[1]{%
                                                      \ensureascii{#1}}
  \AtBeginDocument{\@ifpackageloaded{hyperref}
                     {\pdfstringdefDisableCommands{%
                         \let\EnsureStandardFontEncoding\@firstofone}}
                     {}}
%    \end{macrocode}
% \end{macro}
% End the LGR additions block:
%    \begin{macrocode}
}{}
%    \end{macrocode}

% \subsubsection{LGR workarounds \label{sec:lgr-redefinitions}}
%
% The following redefinitions work around problems with the
% non-standard LGR font encoding.
% As they may have serious side-effects, they are only done if LGR is the
% default Greek font encoding (cf.\ section~\ref{sec:greekfontencoding}).
%
% As an emergency measure, the \Lopt{local-LGR-fixes} or \Lopt{no-LGR-fixes}
% \hyperref[sec:modifiers]{modifiers} can be used to restrict
% the ``roman'' redefinitions to text parts using the Greek language or skip
% them completely.
%
% To prevent Roman numerals being typeset with Greek letters in text parts
% using the LGR font encoding, they must be wrapped in |\ensureascii|.
% However, Roman numerals are also auto generated by LaTeX and
% used  in moving arguments.\footnote{
%   For example, Roman page numbers are generated at ``unpredictable''
%   positions and can move to the ToC, (hyper)references, or an index.}
% These ``moving'' Roman numbers must be LGR-proofed also if they originate
% from a text part using a standard font encoding. This can only be ensured by
% a global re-definition of the generating functions |\@roman| and |\@Roman|.
% On the other hand, the re-definition breaks the assumption by
% MakeIndex, that page numbers are plain character sequences.
% \pkg{Hyperref} assumes that |\thepage| is expandable and doesn't
% contain formatting instructions (cf.\
% \href{https://github.com/latex3/babel/issues/170}{Babel issue \#170}).
% \changes{greek-1.2e}{1999/04/16}{Moved redefinition of \cs{@roman}
%                                  back to the language specific file}
% \changes{greek-1.3d}{1999/08/27}{\cs{@roman} and \cs{@Roman} need to
%          be added to \cs{extraspolutonikogreek}}
% \changes{greek-1.3e}{1999/09/24}{\cs{@roman} and \cs{@Roman} need
%          \emph{not} be in \cs{extraspolutonikogreek} when they are
%          already in \cs{extrasgreek}}
% \changes{greek-1.5}{2013/06/15}{\cs{@roman} and \cs{@Roman} as TextCommands
%          (BUG: this extended the expansion problem to all languages!)}
% \changes{greek-1.6}{2013/07/19}{Apply a patch by Enrico Gregorio.
%          Thanks to Claudio Beccari for testing and reporting.}
%
% The ampersand macro |\&| is used in both, text and math mode.
% Let it use the new defined \emph{TextCommand} |\textampersand|
% in text mode.
%    \begin{macrocode}
\def\bbl@tempa{LGR}
\ifx\greekfontencoding\bbl@tempa
  \def\bbl@greek@roman#1{\expandafter\EnsureStandardFontEncoding%
                         \expandafter{\romannumeral#1}}
  \def\bbl@greek@Roman#1{\expandafter\EnsureStandardFontEncoding%
           \expandafter{\expandafter\@slowromancap\romannumeral#1@}}
  \DeclareRobustCommand{\bbl@greek@ampersand}{%
           \ifmmode\bbl@greek@original@amp\else\textampersand\fi}
  \bbl@xin@{,no-LGR-fixes,}{,\BabelModifiers,}%
  \ifin@
    % skip re-definitions
  \else
    \bbl@xin@{,local-LGR-fixes,}{,\BabelModifiers,}%
    \ifin@
      \addto\extrasgreek{%
        \babel@save\@roman
        \babel@save\@Roman
        \let\@roman\bbl@greek@roman
        \let\@Roman\bbl@greek@Roman
        \babel@save\&%
        \let\&\bbl@greek@ampersand%
        }
    \else
      \let\@roman\bbl@greek@roman
      \let\@Roman\bbl@greek@Roman
      \let\&\bbl@greek@ampersand
    \fi
  \fi
\fi
%    \end{macrocode}
%
%
% \subsection{Definitions for the Greek language}
%
% The next step consists in defining macros for the requirements of Greek
% typesetting which will later be added to the language switch hooks.
%
% \subsubsection{Auto-strings for Greek}
% \changes{greek-1.1e}{1997/10/12}{Added caption name for proof}
% \changes{greek-1.3d}{1999/08/28}{Fixed typo, \texttt{bl'epe ep'ishc}
%                                  instead of \texttt{bl'pe ep'ishc}}
%
%  \begin{macro}{\captionsgreek}
%    The macro |\captionsgreek| defines all strings used in the
%    four standard document classes provided with \LaTeX.
% \changes{greek-1.3h}{2000/09/20}{Added \cs{glossaryname}}
% \changes{greek-1.3i}{2000/10/02}{The final sigma in all names appears
%                                  as `s' instead of `c'.}
% \changes{babel-greek-1.09i}{2020/02/27}{Fix accent in seename and alsoname.}
%    \begin{macrocode}
\addto\captionsgreek{%
  \def\prefacename{\textPi\textrho\acctonos\textomicron\textlambda
    \textomicron\textgamma\textomicron\textfinalsigma}%
  \def\refname{\textAlpha\textnu\textalpha
    \textphi\textomicron\textrho\acctonos\textepsilon\textfinalsigma}%
  \def\abstractname{\textPi\textepsilon\textrho\acctonos\textiota
    \textlambda\texteta\textpsi\texteta}%
  \def\bibname{\textBeta\textiota\textbeta\textlambda\textiota
    \textomicron\textgamma\textrho\textalpha\textphi\acctonos
    \textiota\textalpha}%
  \def\chaptername{\textKappa\textepsilon\textphi\acctonos\textalpha
    \textlambda\textalpha\textiota\textomicron}%
  \def\appendixname{\textPi\textalpha\textrho\acctonos\textalpha\textrho
    \texttau\texteta\textmu\textalpha}%
  \def\contentsname{\textPi\textepsilon\textrho\textiota
    \textepsilon\textchi\acctonos\textomicron\textmu\textepsilon
    \textnu\textalpha}%
  \def\listfigurename{\textKappa\textalpha\texttau\acctonos\textalpha
    \textlambda\textomicron\textgamma\textomicron\textfinalsigma{}
    \textSigma\textchi\texteta\textmu\acctonos\textalpha\texttau
    \textomega\textnu}%
  \def\listtablename{\textKappa\textalpha\texttau\acctonos\textalpha
    \textlambda\textomicron\textgamma\textomicron\textfinalsigma{}
    \textPi\textiota\textnu\acctonos\textalpha\textkappa\textomega
    \textnu}%
  \def\indexname{\textEpsilon\textupsilon\textrho\textepsilon
    \texttau\acctonos\texteta\textrho\textiota\textomicron}%
  \def\figurename{\textSigma\textchi\acctonos\texteta\textmu\textalpha}%
  \def\tablename{\textPi\acctonos\textiota\textnu\textalpha
    \textkappa\textalpha\textfinalsigma}%
  \def\partname{\textMu\acctonos\textepsilon\textrho\textomicron
    \textfinalsigma}%
  \def\enclname{\textSigma\textupsilon\textnu\texteta\textmu
    \textmu\acctonos\textepsilon\textnu\textalpha}%
  \def\ccname{\textKappa\textomicron\textiota\textnu\textomicron
    \textpi\textomicron\acctonos\textiota\texteta\textsigma\texteta}%
  \def\headtoname{\textPi\textrho\textomicron\textfinalsigma}%
  \def\pagename{\textSigma\textepsilon\textlambda\acctonos\textiota
    \textdelta\textalpha}%
  \def\seename{\textbeta\textlambda\acctonos\textepsilon\textpi
    \textepsilon}%
  \def\alsoname{\textbeta\textlambda\acctonos\textepsilon\textpi
    \textepsilon{} \textepsilon\textpi\acctonos\textiota\textsigma
    \texteta\textfinalsigma}%
  \def\proofname{\textAlpha\textpi\acctonos\textomicron
    \textdelta\textepsilon\textiota\textxi\texteta}%
  \def\glossaryname{\textGamma\textlambda\textomega\textsigma
    \textsigma\acctonos\textalpha\textrho\textiota}%
}
%    \end{macrocode}
%  \end{macro}
%
% \subsubsection{Auto-strings for polytonic Greek}
% \changes{greek-1.2}{1997/10/28}{Added caption names for
%                                 \cs{polutonikogreek}}
% \changes{greek-1.3d}{1999/08/28}{Fixed typo, \texttt{bl'epe >ep'ishc}
%                                  instead of \texttt{bl'pe >ep'ishc}}
%  \begin{macro}{\captionspolutonikogreek}
%    For texts written in polytonic greek, the translations are
%    the same as above, but some words are spelled differently. For
%    now we just add extra definitions to |\captionsgreek| in order to
%    override the earlier definitions.
% \changes{babel-greek-1.09b}{2014/09/18}{Use named macros instead of
%          non-standard short accent macros for psili and dasia.}
%    \begin{macrocode}
\let\captionspolutonikogreek\captionsgreek
\addto\captionspolutonikogreek{%
  \def\refname{\accpsili\textAlpha\textnu\textalpha
    \textphi\textomicron\textrho\accvaria\textepsilon\textfinalsigma}%
  \def\indexname{\textEpsilon\accdasia\textupsilon\textrho\textepsilon
    \texttau\acctonos\texteta\textrho\textiota\textomicron}%
  \def\figurename{\textSigma\textchi\accperispomeni\texteta\textmu
    \textalpha}%
  \def\headtoname{\textPi\textrho\accvaria\textomicron\textfinalsigma}%
  \def\alsoname{\textbeta\textlambda\acctonos\textepsilon\textpi
    \textepsilon{} \accpsili\textepsilon\textpi\acctonos\textiota
    \textsigma\texteta\textfinalsigma}%
  \def\proofname{\accpsili\textAlpha\textpi\acctonos\textomicron
    \textdelta\textepsilon\textiota\textxi\texteta}%
}
%    \end{macrocode}
%  \end{macro}
%
% \subsubsection{Auto-strings for ancient Greek}
% \changes{babel-greek-1.09}{2014/07/20}{Added caption names for
%                                       \cs{ancientgreek}}
%  \begin{macro}{\captionsancientgreek}
%    For texts written in ancient Greek, we took the translations
%    from Apostolos Syropoulos' \pkgref{xgreek} package.
%    For now we just add extra definitions to |\captionsgreek|
%    in order to override the earlier definitions.
%    \begin{macrocode}
\let\captionsancientgreek\captionsgreek
\addto\captionsancientgreek{%
  \def\prefacename{\textPi\textrho\textomicron\textomicron
    \acctonos\textiota\textmu\textiota\textomicron\textnu}%
  \def\refname{\accpsili\textAlpha\textnu\textalpha\textphi\textomicron
    \textrho\textalpha\accvaria\textiota}%
  \def\abstractname{\textPi\textepsilon\textrho\acctonos\textiota
    \textlambda\texteta\textpsi\textiota\textvarsigma}%
  \def\bibname{\textBeta\textiota\textbeta\textlambda\textiota
    \textomicron\textgamma\textrho\textalpha\textphi
    \acctonos\textiota\textalpha}%
  \def\chaptername{\textKappa\textepsilon\textphi\acctonos\textalpha
    \textlambda\textalpha\textiota\textomicron\textnu}%
  \def\appendixname{\textPi\textalpha\textrho\acctonos\textalpha
    \textrho\texttau\texteta\textmu\textalpha}%
  \def\contentsname{\textPi\textepsilon\textrho\textiota\textepsilon
    \textchi\acctonos\textomicron\textmu\textepsilon\textnu\textalpha}%
  \def\listfigurename{\textKappa\textalpha\texttau\acctonos\textalpha
    \textlambda\textomicron\textgamma\textomicron\textvarsigma{}
    \textsigma\textchi\texteta\textmu\acctonos\textalpha\texttau
    \textomega\textnu}%
  \def\listtablename{\textKappa\textalpha\texttau\acctonos\textalpha
    \textlambda\textomicron\textgamma\textomicron\textvarsigma{}
    \textpi\textiota\textnu\acctonos\textalpha\textkappa
    \textomega\textnu}%
  \def\indexname{\textEpsilon\accdasia\textupsilon\textrho\textepsilon
    \texttau\acctonos\texteta\textrho\textiota\textomicron\textnu}%
  \def\figurename{\textSigma\textchi\accperispomeni\texteta\textmu
    \textalpha}%
  \def\tablename{\textPi\acctonos\textiota\textnu\textalpha\textxi}%
  \def\partname{\textMu\acctonos\textepsilon\textrho\textomicron
    \textvarsigma}%
  \def\enclname{\textSigma\textupsilon\textnu\texteta\textmu\textmu
    \acctonos\textepsilon\textnu\textomega\textvarsigma}%
  \def\ccname{\textKappa\textomicron\textiota\textnu\textomicron\textpi
    \textomicron\acctonos\textiota\texteta\textsigma\textiota
    \textvarsigma}%
  \def\headtoname{\textPi\textrho\accvaria\textomicron\textvarsigma}%
  \def\pagename{\textSigma\textepsilon\textlambda\accvaria\textiota
    \textvarsigma}%
  \def\seename{\accdasiaoxia\textomicron\textrho\textalpha}%
  \def\alsoname{\accdasiaoxia\textomicron\textrho\textalpha{}
    \accdasia\textomega\textsigma\textalpha\acctonos\textupsilon
    \texttau\textomega\textvarsigma}%
  \def\proofname{\accpsili\textAlpha\textpi\acctonos\textomicron
    \textdelta\textepsilon\textiota\textxi\textiota\textvarsigma}%
  \def\glossaryname{\textGamma\textlambda\textomega\textsigma\textsigma
    \acctonos\textalpha\textrho\textiota\textomicron\textnu}%
}
%    \end{macrocode}
%  \end{macro}
%
% \subsubsection{Date specification}
%
%  \begin{macro}{\gr@month}
%    The auxiliary macro |\gr@month| returns Greek month names in
%    monotonic spelling.
% \changes{greek-1.1e}{1997/10/12}{Macro added}
%    \begin{macrocode}
\def\gr@month{%
  \ifcase\month\or
    \textIota\textalpha\textnu\textomicron\textupsilon\textalpha
      \textrho\acctonos\textiota\textomicron\textupsilon \or
    \textPhi\textepsilon\textbeta\textrho\textomicron\textupsilon
      \textalpha\textrho\acctonos\textiota\textomicron\textupsilon \or
    \textMu\textalpha\textrho\texttau\acctonos\textiota\textomicron
      \textupsilon \or
    \textAlpha\textpi\textrho\textiota\textlambda\acctonos\textiota
      \textomicron\textupsilon \or
    \textMu\textalpha\'"\textiota\textomicron\textupsilon \or
    \textIota\textomicron\textupsilon\textnu\acctonos\textiota
      \textomicron\textupsilon \or
    \textIota\textomicron\textupsilon\textlambda\acctonos\textiota
      \textomicron\textupsilon \or
    \textAlpha\textupsilon\textgamma\textomicron\acctonos\textupsilon
      \textsigma\texttau\textomicron\textupsilon \or
    \textSigma\textepsilon\textpi\texttau\textepsilon\textmu
      \textbeta\textrho\acctonos\textiota\textomicron\textupsilon \or
    \textOmicron\textkappa\texttau\textomega\textbeta
      \textrho\acctonos\textiota\textomicron\textupsilon \or
    \textNu\textomicron\textepsilon\textmu\textbeta
      \textrho\acctonos\textiota\textomicron\textupsilon \or
    \textDelta\textepsilon\textkappa\textepsilon\textmu\textbeta
      \textrho\acctonos\textiota\textomicron\textupsilon
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\gr@polutoniko@month}
%   The auxiliary macro |\gr@polutoniko@month| returns Greek month names in
%   polytonic spelling. It is activated by the |polutoniko| language option.
% \changes{greek-1.2}{1997/10/28}{Added macro \cs{gr@cl@month}}
% \changes{greek-1.2}{1997/10/28}{Added macro \cs{datepolutonikogreek}}
% \changes{greek-1.3a}{1997/10/28}{removed macro \cs{datepolutonikogreek}}
%    \begin{macrocode}
\def\gr@polutoniko@month{%
  \ifcase\month\or
    \accpsili\textIota\textalpha\textnu\textomicron\textupsilon
      \textalpha\textrho\acctonos\textiota\textomicron\textupsilon \or
    \textPhi\textepsilon\textbeta\textrho\textomicron\textupsilon
      \textalpha\textrho\acctonos\textiota\textomicron\textupsilon \or
    \textMu\textalpha\textrho\texttau\acctonos\textiota\textomicron
      \textupsilon \or
    \accpsili\textAlpha\textpi\textrho\textiota\textlambda
      \acctonos\textiota\textomicron\textupsilon \or
    \textMu\textalpha\accdialytikatonos\textiota\textomicron
      \textupsilon \or
    \accpsili\textIota\textomicron\textupsilon\textnu
      \acctonos\textiota\textomicron\textupsilon \or
    \accpsili\textIota\textomicron\textupsilon\textlambda
      \acctonos\textiota\textomicron\textupsilon \or
    \textAlpha\accpsili\textupsilon\textgamma\textomicron\acctonos
      \textupsilon\textsigma\texttau\textomicron\textupsilon \or
    \textSigma\textepsilon\textpi\texttau\textepsilon\textmu\textbeta
      \textrho\acctonos\textiota\textomicron\textupsilon \or
    \accpsili\textOmicron\textkappa\texttau\textomega\textbeta
      \textrho\acctonos\textiota\textomicron\textupsilon \or
    \textNu\textomicron\textepsilon\textmu\textbeta
      \textrho\acctonos\textiota\textomicron\textupsilon \or
    \textDelta\textepsilon\textkappa\textepsilon\textmu
      \textbeta\textrho\acctonos\textiota\textomicron\textupsilon
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\dategreek}
%    The macro |\dategreek| redefines the command |\today| to
%    produce Greek dates. The name of the month is produced
%    by the macro |\gr@month| since it is also needed in the definition
%    of the macro |\Grtoday|.
% \changes{greek-1.1a}{1997/03/03}{Fixed typo, \texttt{Oktwbr'iou}
%                                  instead of \texttt{Oktobr'iou}}
% \changes{greek-1.1d}{1997/10/12}{Macro \cs{gr@month} now produces
%                                  the  name of the month}
% \changes{greek-1.2a}{1997/10/31}{Use \cs{edef} to define \cs{today}}
% \changes{greek-1.2b}{1998/03/28}{use \cs{def} instead of \cs{edef}}
%    \begin{macrocode}
\def\dategreek{%
  \def\today{\number\day \space \gr@month\space \number\year}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\Grtoday}
% \changes{greek-1.1}{1996/10/28}{Added macro \cs{Grtoday}}
%    The macro |\Grtoday| produces the current date, only that the
%    month and the day are shown as greek numerals instead of arabic
%    as it is usually the case. (The \pkgref{teubner} package defines
%    a matching lowercase version \cs{grtoday}.)
%    \begin{macrocode}
\def\Grtoday{%
  \expandafter\Greeknumeral\expandafter{\the\day}\space
  \gr@polutoniko@month \space
  \expandafter\Greeknumeral\expandafter{\the\year}}
%    \end{macrocode}
%  \end{macro}
%
% \subsubsection{Greek numerals \label{sec:Greek numerals}}
%
%  \begin{macro}{\greeknumeralsix}
%  \begin{macro}{\greeknumeralSix}
%  \begin{macro}{\greeknumeralninety}
%  \begin{macro}{\greeknumeralNinety}
%    The shape of the obsolete characters used for number 6 (digamma/stigma)
%    and 90 (koppa) evolved over time and different characters are in use
%    for them today. We define placeholders that allow configuration by
%    the user or a package.
% \changes{babel-greek-1.10}{2020/11/10}{
%   Use zig-zagy \cs{textkoppa}.
%   This is what it looks in current Greek typography.}
%    \begin{macrocode}
\providecommand*{\greeknumeralsix}{\textstigma}
\providecommand*{\greeknumeralSix}{\textStigma}
\providecommand*{\greeknumeralninety}{\textkoppa}
\providecommand*{\greeknumeralNinety}{\textKoppa}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\greeknumeral}
%    The commands |\greeknumeral| and |\Greeknumeral| produce the lowercase
%    and uppercase \href{https://en.wikipedia.org/wiki/Greek_numerals}{Greek
%    numerals} respectively.
%
%    The command |\greeknumeral| needs to be \emph{fully} expandable
%    in order to get the right information in auxiliary
%    files. It should also be usable in PDF-strings.
%    Therefore we use the implementation from the \cs{HyPsd@GreekPatch}
%    in \pkgref{hyperref} (version 7.00e 2020-05-15).
%
% \changes{babel-greek-1.10}{2020/11/10}{PDF-string secure implementation
%    taken from ``hyperref'' (thanks to Ulrike Fischer).}
% \changes{babel-greek-1.11}{2020/11/20}{Configurable shapes for 6 and 90.
%   90 defaults to \cs{textqoppa} for ancient Greek.}
%    \begin{macrocode}
\def\greeknumeral#1{%
  {\greekscript
   \bbl@greek@GreekNum\@firstoftwo{#1}}%
}
%    \end{macrocode}
%  \end{macro}
%  \begin{macro}{\Greeknumeral}
%    The command |\Greeknumeral| prints uppercase greek numerals.
%    \begin{macrocode}
\def\Greeknumeral#1{%
  {\greekscript
   \bbl@greek@GreekNum\@secondoftwo{#1}}%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\bbl@greek@ill@value}
%    When the argument of |\greeknumeral| has a value outside of the
%    acceptable bounds ($0 < x < 999999$) a warning will be issued
%    (and the argument be printed).
%    \begin{macrocode}
\def\bbl@greek@ill@value#1{%
  \PackageWarningNoLine{babel}{Illegal value (#1) for greeknumeral}%
  \@arabic{#1}%
}
%    \end{macrocode}
%  \end{macro}
%  \begin{macro}{\bbl@greek@GreekNum}
%  \begin{macro}{\bbl@greek@@GreekNum}
%  \begin{macro}{\bbl@greek@GreekNumI}
%  \begin{macro}{\bbl@greek@GreekNumII}
%  \begin{macro}{\bbl@greek@GreekNumIII}
%  \begin{macro}{\bbl@greek@GreekNumIV}
%  \begin{macro}{\bbl@greek@GreekNumV}
%  \begin{macro}{\bbl@greek@GreekNumVI}
%    The auxiliary macros provide the actual conversion.
%    They are taken from hyperref as well.
%    \begin{macrocode}
\def\bbl@greek@GreekNum#1#2{%
    \ifnum#2<\@ne
      \bbl@greek@ill@value{#2}%
    \else
      \ifnum#2<1000000 %
        \bbl@greek@@GreekNum#1{#2}%
      \else
        \bbl@greek@ill@value{#2}%
      \fi
    \fi
}
\def\bbl@greek@@GreekNum#1#2{%
  \ifnum#2<\@m
    \ifnum#2<10 %
      \expandafter\bbl@greek@GreekNumI
          \expandafter\@gobble\expandafter#1\number#2%
    \else
      \ifnum#2<100 %
        \expandafter\bbl@greek@GreekNumII
            \expandafter\@gobble\expandafter#1\number#2%
      \else
        \expandafter\bbl@greek@GreekNumIII
            \expandafter\@gobble\expandafter#1\number#2%
      \fi
    \fi
    \ifnum#2>\z@
      \textnumeralsigngreek
    \fi
  \else
    \ifnum#2<\@M
      \expandafter\bbl@greek@GreekNumIV\expandafter#1\number#2%
    \else
      \ifnum#2<100000 %
        \expandafter\bbl@greek@GreekNumV\expandafter#1\number#2%
      \else
        \expandafter\bbl@greek@GreekNumVI\expandafter#1\number#2%
      \fi
    \fi
  \fi
}
\def\bbl@greek@GreekNumI#1#2#3{%
  #1{%
    \ifnum#3>\z@
      \textnumeralsignlowergreek
    \fi
  }%
  \expandafter#2%
  \ifcase#3 %
    {}{}%
  \or\textalpha\textAlpha
  \or\textbeta\textBeta
  \or\textgamma\textGamma
  \or\textdelta\textDelta
  \or\textepsilon\textEpsilon
  \or\greeknumeralsix\greeknumeralSix % stigma or digamma
  \or\textzeta\textZeta
  \or\texteta\textEta
  \or\texttheta\textTheta
  \else
    {}{}%
  \fi
}
\def\bbl@greek@GreekNumII#1#2#3#4{%
  #1{%
    \ifnum#3>\z@
      \textnumeralsignlowergreek
    \fi
  }%
  \expandafter#2%
  \ifcase#3 %
    {}{}%
  \or\textiota\textIota
  \or\textkappa\textKappa
  \or\textlambda\textLambda
  \or\textmugreek\textMu
  \or\textnu\textNu
  \or\textxi\textXi
  \or\textomicron\textOmicron
  \or\textpi\textPi
  \or\greeknumeralninety\greeknumeralNinety % koppa or qoppa
  \else
    {}{}%
  \fi
  \bbl@greek@GreekNumI#1#2#4%
}
\def\bbl@greek@GreekNumIII#1#2#3#4#5{%
  #1{%
    \ifnum#3>\z@
      \textnumeralsignlowergreek
    \fi
  }%
  \expandafter#2%
  \ifcase#3 %
    {}{}%
  \or\textrho\textRho
  \or\textsigma\textSigma
  \or\texttau\textTau
  \or\textupsilon\textUpsilon
  \or\textphi\textPhi
  \or\textchi\textChi
  \or\textpsi\textPsi
  \or\textomega\textOmega
  \or\textsampigreek\textSampigreek
  \else
    {}{}%
  \fi
  \bbl@greek@GreekNumII#1#2#4#5%
}
\def\bbl@greek@GreekNumIV#1#2#3#4#5{%
  \bbl@greek@GreekNumI\@firstofone#1#2%
  \bbl@greek@@GreekNum#1{#3#4#5}%
}
\def\bbl@greek@GreekNumV#1#2#3#4#5#6{%
  \bbl@greek@GreekNumII\@firstofone#1#2#3%
  \bbl@greek@@GreekNum#1{#4#5#6}%
}
\def\bbl@greek@GreekNumVI#1#2#3#4#5#6#7{%
  \bbl@greek@GreekNumIII\@firstofone#1#2#3#4%
  \bbl@greek@@GreekNum#1{#5#6#7}%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\greek@alph}
%  \begin{macro}{\greek@Alph}
%    In the previous release of this language definition file the
%    commands |\greek@aplh| and |\greek@Alph| were kept just for
%    reasons of compatibility. Here again they become meaningful macros.
%    They are defined in a way that even page numbering with greek
%    numerals is possible.
%
%    We define the Greek versions; the additional |\expandafter|s
%    are needed in order to make sure the table of contents will be
%    correct, e.g., when we have appendixes.
%    \begin{macrocode}
\def\greek@alph#1{\expandafter\greeknumeral\expandafter{\the#1}}
\def\greek@Alph#1{\expandafter\Greeknumeral\expandafter{\the#1}}
%    \end{macrocode}
%
%    Redefine the internal macros |\@alph| and |\@Alph| in the
%    language hook, so that we use Greek numerals\footnote{
%      cf.\ section \ref{sec:Greek numerals}}
%    instead of the Latin alphabet\footnote{
%      Eventually interpreted as Latin transliteration and converted
%      to Greek letters in a ``strange'' order.}
%    in Greek text parts.
% \changes{greek-1.1a}{1997/03/03}{
%          removed two superfluous @'s which made \cs{@alph} undefined}
% \changes{babel-greek-1.12}{2023/03/04}{
%          Save/restore expansion of \cs{\@alph} and \cs{\@Alph}
%          with every switch to/from Greek.}
%    \begin{macrocode}
\addto\extrasgreek{%
  \babel@save\@alph
  \babel@save\@Alph
  \let\@alph\greek@alph
  \let\@Alph\greek@Alph
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
% \subsection{Character codes \label{sec:character-codes}}
%
% \changes{greek-1.1c}{1997/04/30}{fixed two typos}
% \changes{greek-1.1e}{1997/10/12}{Added lowercase code for v}
% \changes{greek-1.2}{1997/10/28}{Definitions for ``modern'' Greek are
%    now the definitions of ``polutoniko'' Greek}
% \changes{greek-1.2}{1997/10/28}{Added lowercase codes for ``modern''
%    greek}
% \changes{greek-1.3e}{1999/09/24}{\cs{extrasgreek} and
%    \cs{extraspolutonikogreek} should be complementary}
% \changes{babel-greek-1.09}{2014/07/20}{Added lc codes for chars 128 to 255}
% \changes{babel-greek-1.09b}{2014/09/18}{Remove spurious whitespace from
%    `extrasgreek'  definition (report Eike Schmidt).}
% \changes{babel-greek-1.09e}{2015/11/27}{Fix bug in lccode-setting loop
%   (patch by Enrico Gregorio).}
% \changes{babel-greek-1.12}{2023/03/04}{
%    Only change uc/lccodes if \cs{greekfontencoding} is LGR.}
%
% In order to get correct hyphenation we need to set the lower case
% code for all characters that can be part of a word.
%
% In LGR encoded fonts, diacritics can be obtained using Knuth's
% ligature mechanism (see usage.pdf). This means that the characters
% |<|, |>|, |~|, |`|, |'|, |"|, and \verb=|= may be part of a word.
% Therefore, their |\lccode| is changed when polytonic Greek is in
% effect. For monotonic Greek, we only need |'| and |"|.
%
% The `v' character has a special usage in LGR-encoded fonts:
% The LGR ligature mechanism detects the end of a word and assures that
% a final sigma ($\varsigma$) is used. The `v' after  an `s' overrides this
% ligature mechanism so that it is possible to typeset an isolated $\sigma$
% without it becoming a $\varsigma$.
% Because of this we make sure its lowercase code is not changed.
%    \begin{macrocode}
\def\bbl@tempa{LGR}
\ifx\greekfontencoding\bbl@tempa
  \addto\extrasgreek{%
    \babel@savevariable{\lccode`v}\lccode`v=`v%
    \babel@savevariable{\lccode`\'}\lccode`\'=`\'%
    \babel@savevariable{\lccode`\"}\lccode`\"=`\"%
  }
  \addto\extraspolutonikogreek{%
    % \l@greek=\bbl@polygreek
    \babel@savevariable{\lccode`\<}\lccode`\<=`\<%
    \babel@savevariable{\lccode`\>}\lccode`\>=`\>%
    \babel@savevariable{\lccode`\~}\lccode`\~=`\~%
    \babel@savevariable{\lccode`\|}\lccode`\|=`\|%
    \babel@savevariable{\lccode`\`}\lccode`\`=`\`%
  }
%    \end{macrocode}
% Also set the lc code for the precomposed characters in the upper half
% of the code table.
%    We do this in |\extrasgreek| because this is a feature of
%    the LGR font encoding (used in all language variants).
%    This means that multi-accented characters are regarded parts of a word
%    also in monotonic spelling.
%    \begin{macrocode}
  \addto\extrasgreek{%
    % ``high bit characters'': set in a loop and correct exceptions
    \@tempcnta=128%
    \@whilenum\@tempcnta<253\do{%
      \expandafter\babel@savevariable\expandafter{%
                         \expandafter\lccode\the\@tempcnta}%
      \lccode\@tempcnta=\@tempcnta
      \advance\@tempcnta\@ne
    }%
    % Fix non-word characters:
    \lccode151=0%
    \lccode155=0%
    \lccode159=0%
    \lccode199=0%
    % Fix capital letters:
    \lccode195=147% GREEK LETTER DIGAMMA
    \lccode219=240% GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
    \lccode223=244% GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
  }
%    \end{macrocode}
%
% \begin{macro}{\bbl@greek@tilde}
%   \changes{greek-1.0c}{1997/02/19}{Added command}
%   \changes{greek-1.1b}{1997/03/06}{Made tilde expand to a tilde with
%     \cs{catcode 12}.}
%   \changes{greek-1.3k}{2003/04/10}{Make sure the character `!' is not
%     active during the definition of \cs{greek@tilde}}
%   \changes{greek-1.4}{2013/05/17}{Do not re-define the tilde accent macro:
%     it works as expected with \file{lgrenc.def} from \pkg{greek-fontenc}.}
%   \changes{babel-greek-1.13}{2023/03/15}{
%     Renamed from \cs{greek@tilde}. Simplified definition.}
%
%   By default, the tilde produces an unbreakable space in text mode.
%   For the variants ``polutoniko'' and ``ancient'', we change its meaning
%   to allow using |~| in the Latin transliteration of characters with
%   perispomeni and in composite diacritics.
%    \begin{macrocode}
  \DeclareTextSymbol{\bbl@greek@tilde}{LGR}{126}
  \addto\bbl@greek@setup@polytonic{
    \declare@shorthand{greek}{~}{\bbl@greek@tilde}
  }
\fi % End of LGR-specific code.
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{MakeUppercase fixes \label{sec:MakeUppercase-fixes}}
%
% \changes{greek-1.1b}{1997/03/06}{Added setting of \cs{uccode}s
%   (after \file{kdgreek.sty})}
% \changes{greek-1.1e}{1997/10/12}{Added uppercase code for special
%   letter ``v''. Uppercase code for accents is now \texttt{9f},
%   instead of \texttt{ff}}
% \changes{greek-1.2}{1997/10/28}{Added uppercase codes for ``modern''
%   Greek. The old codes are now for ``Polutoniko'' Greek}
% \changes{greek-1.3e}{1999/09/24}{\cs{extrasgreek} and
%   \cs{extraspolutonikogreek} should be complementary}
% {\catcode`|=12\relax\gdef\indexbar{\cs{|}}}
% \changes{greek-1.3g}{1999/11/17}{uc code of \indexbar{} is now just
%   \indexbar{} to reflect recent changes in the cb fonts}
% \changes{greek-1.3i}{2000/10/02}{uc code of `v' is switched to V
%   so that mixed text appears correctly in headers.}
% \changes{greek-1.3j}{2001/02/03}{Don't use the double caret notation here,
%   because other languages might make the caret active.}
% \changes{greek-1.5}{2013/06/21}{Support XeTeX/LuaTeX.}
% \changes{babel-greek-1.09d}{2015/07/06}{uc-/lccode corrections from xgreek
%   are now in greek-euenc.def (the polyglossia version has bugs).}
% \changes{babel-greek-1.12}{2023/03/04}{
%   Only change uccodes if LaTeX is older than 2022/06/01.}
% \changes{babel-greek-1.13.2}{2023-06-01}{
%   \cs{MakeUppercase} fix for transliteration input.}
% \changes{babel-greek-1.14}{2023-08-18}{
%   \cs{MakeUppercase} fix for standard accent macros.}
% In Greek typographical praxis,
% letters drop accents (eccept dialytika) and breathings in
% UPPERCASE. This is not cared for by the Unicode standard.
% For Unicode literals, |\MakeUppercase| implements locale-specific
% corrections.\footnote{
%   The pre-2022 implementation is corrected by character code definitions
%   in \file{tuenc-greek.def} from \pkgref{greek-fontenc},
%   cf. section~\ref{load-greek-font-encoding-definitions}.}
%
% To fix the behaviour of the 2022 |\MakeUppercase| implementation with
% standard accent macros, we define and use ``capital'' accent
% macros.
% Font-encoding specific definitions for the ``capital'' accent macros
% in \pkgref{greek-fontenc}~$\ge 2.4$ suppress them on Greek letters.
% The \Lopt{local-MakeUppercase-fixes} modifier can be used to skip this step
% (cf. section~\ref{sec:modifiers}).
%    \begin{macrocode}
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} % new in 2020
\bbl@xin@{,local-MakeUppercase-fixes,}{,\BabelModifiers,}%
\ifin@
\else
  \IfFormatAtLeastTF{2022/06/01}
    {\ProvideTextCommandDefault{\accACUTE}{\@tabacckludge'}
     \ProvideTextCommandDefault{\accGRAVE}{\@tabacckludge`}
     \ProvideTextCommandDefault{\accTILDE}{\@tabacckludge~}
     \ProvideTextCommandDefault{\accDIAERESIS}{\@tabacckludge"}
     \addto\@uclclist{\'\accACUTE \`\accGRAVE \~\accTILDE \"\accDIAERESIS}%
    }
    {}
\fi
%    \end{macrocode}
% Drop diacritics also with ``input ligatures'' defined in LGR fonts:
%
% Since 2023/06, we can set up character mappings to be used on the argument
% of |\MakeUppercase|.\footnote{cf.
%  \href{https://www.latex-project.org/news/latex2e-news/ltnews37.pdf}
%  {LaTeX News~37}}
% The optional ``locale'' argument |[el]| restricts the mapping to Greek
% text parts.
%    \begin{macrocode}
\def\bbl@tempa{LGR}
\ifx\greekfontencoding\bbl@tempa
  \ifdefined\DeclareUppercaseMapping % new in 2023
    % \DeclareUppercaseMapping[el]{"1FBE}{\prosgegrammeni}%
    \DeclareUppercaseMapping[el]{"0027}{}% '
    \addto\bbl@greek@setup@polytonic{
      \DeclareUppercaseMapping[el]{"003C}{}% <
      \DeclareUppercaseMapping[el]{"003E}{}% >
      \DeclareUppercaseMapping[el]{"0060}{}% `
      \DeclareUppercaseMapping[el]{"007E}{}% ~
    }
  \fi
%    \end{macrocode}
% If LaTeX is older than 2022/06,
% we set the |\uccode| of the relevant characters to a dummy character
% (|\uccode| changes are ignored by |\MakeUppercase| since 2022).
% To minimize side-effects, the re-definition is limited to Greek text parts.
%    \begin{macrocode}
  \IfFormatAtLeastTF{2022/06/01}{}
    {% else (LaTeX format older than 2022/06/01)
     \addto\extrasgreek{%
       \babel@savevariable{\uccode`\"}\uccode`\"=`\"%
       \babel@savevariable{\uccode`\'}\uccode`\'=159% 159 == ^^9f
     }
     \addto\extraspolutonikogreek{%
       \babel@savevariable{\uccode`\~}\uccode`\~=159%
       \babel@savevariable{\uccode`\>}\uccode`\>=159%
       \babel@savevariable{\uccode`\<}\uccode`\<=159%
       \babel@savevariable{\uccode`\`}\uccode`\`=159%
     }
%    \end{macrocode}
% To avoid errors if the tilde is used as perispomeni
% (in polytonic or ancient Greek), we need to declare an expansion for
% the ``dummy'' character~0x9f = 159.\footnote{
%   Since UTF-8 became the default encoding (cf.\
%   \href{https://www.latex-project.org/news/latex2e-news/ltnews28.pdf}
%   {LaTeX News~28}), an ``inputenc'' error is also thrown
%   if the \pkg{inputenc} package is not loaded.}
% To be independent of \pkg{inputenc}, we do not use |\DeclareInputText|
% but code modelled after its definition to declare an empty expansion.
% \changes{greek-1.1b}{1997/03/06}{
%          Added shorthand for \cs{char255}}
% \changes{greek-1.1e}{1997/10/12}{
%          Shorthand is changed. Active character is now \cs{char159}}
% \changes{greek-1.2a}{1997/10/31}{
%          Need shorthand to exist for monotonic Greek, not polytonik Greek}
% \changes{greek-1.3j}{2001/02/03}{
%          Use the tilde as an alias for character 159}
% \changes{babel-greek-1.12}{2023/03/04}{
%          Declare char 159 expansion similar to
%          \pkg{inputenc} to avoid ``inputenc error''.}
%    \begin{macrocode}
     \bgroup
        \uccode`\~159%
        \uppercase{%
     \egroup
        \def~{}%
     }
%    \end{macrocode}
% Add composite commands, so that the dialytika is kept or put on the
% following character of a diphthong with |\MakeUppercase| (see
% \file{lgrdef.enc} from the \pkgref{greek-fontenc} package for details).
% \changes{greek-1.4}{2013/05/17}{
%   Add TextCompositeCommands for ``uppercase diacritics''.}
% \changes{greek-1.5}{2013/05/27}{Bugfix: @hiatus->LGR@hiatus}
% \changes{greek-1.5a}{2013/07/02}{Replaced non-printable literal character
%   with \textasciicircum-notation (tip by Heiko Oberdiek).}
% \changes{babel-greek-1.09}{2014/07/20}{The \textasciicircum-notation seems
%   to require lower case letters.}
% \changes{babel-greek-1.09h}{2019/07/11}{Move breathing composite commands
%   to textalpha.}
%    \begin{macrocode}
     \DeclareTextCompositeCommand{\"}{LGR}{^^9f}{\accdialytika}
     \DeclareTextCompositeCommand{\'}{LGR}{^^9f}{\LGR@hiatus}
     \DeclareTextCompositeCommand{\`}{LGR}{^^9f}{\LGR@accdropped}
%    \end{macrocode}
% If Unicode fonts are loaded together with LGR, we must also care for
% |\"'| and |\"`| in TU, because the |\"| is kept when upcasing.
%    \begin{macrocode}
     \ifdefined\UnicodeEncodingName % set by XeTeX/LuaTeX
       \DeclareTextCompositeCommand{\"}{TU}{^^9f}{\accdialytika}
     \fi
    }% end of the \IfFormatAtLeastTF else block
\fi % End of LGR-specific code.
%    \end{macrocode}
%
% \subsection{Symbol name aliases}
%    For backwards compatibility, we keep aliases for a few symbols.
% \changes{greek-1.1c}{1997/03/10}{Added a couple of symbols, needed
%    for \cs{greeknumeral}}
% \changes{greek-1.1e}{1997/10/12}{Most symbols are removed and are
%    now defined in package grsymb}
% \changes{greek-1.2c}{1998/06/26}{Package grsymb has been eliminated
%   because the CB fonts v2.0 do not inlcude certain symbols and so
%   the remaining symbol definitions have been moved here}
% \changes{greek-1.5}{2013/06/11}{change symbol macros to aliases}
% \changes{greek-1.10}{2020/11/10}{Fix: \cs{qoppa} is the legacy name of
%   \cs{textkoppa} not \cs{textqoppa}!}
% \changes{babel-greek-1.12}{2023/03/04}{Remove \cs{textKoppa} and
%   \cs{textmu} (in greek-fontenc since version 1.0).}
%    \begin{macrocode}
\providecommand*{\anwtonos}{\textdexiakeraia}
\providecommand*{\katwtonos}{\textaristerikeraia}
\providecommand*{\qoppa}{\textkoppa}
\providecommand*{\varqoppa}{\textqoppa}
\providecommand*{\stigma}{\textstigma}
\providecommand*{\sampi}{\textsampi}
\providecommand*{\Digamma}{\textDigamma}
\providecommand*{\ddigamma}{\textdigamma}
\providecommand*{\vardigamma}{\textvardigamma}
\providecommand*{\euro}{\texteuro}
\providecommand*{\permill}{\textperthousand}
\ProvideTextCommand{\textmugreek}{\greekfontencoding}{\textmu}
%    \end{macrocode}
%
% \changes{babel-greek-1.08}{2013/11/27}{Remove redefinition of
%    \cs{fnum@figure} and \cs{fnum@table}.}
%
%    The macro |\ldf@finish| takes care of looking for a
%    configuration file, setting the main language to be switched on
%    at |\begin{document}| and resetting the category code of
%    \texttt{@} to its original value.
% \changes{greek-1.0b}{1996/11/02}{Now use \cs{ldf@finish} to wrap up}
%    \begin{macrocode}
\ldf@finish{\CurrentOption}
%</code>
%    \end{macrocode}
%
% \PrintChanges
%
% \Finale
%\endinput
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
