%%
%% This is file `nevelok.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% nevelok.dtx  (with options: `package')
%% ----------------------------------------------------------------
%% nevelok --- LaTeX package for automatic definite articles for Hungarian
%% Author:  Zalan Bodo
%% E-mail:  zbodo@cs.ubbcluj.ro
%% License: Released under the LaTeX Project Public License v1.3c or later
%% See:     http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{nevelok}
    [2015/09/10 v1.00 LaTeX package for automatic definite articles for Hungarian]
\RequirePackage{xstring}
%%
\newcommand{\aaz}[1]{%
  \z@aaz{#1}{a}{az}{(}{)}%
}
%%
%%
\newcommand{\Aaz}[1]{%
  \z@aaz{#1}{A}{Az}{(}{)}%
}
%%
%%
\newcommand{\z@aaz}[5]{%
  \def\param{#1}% the first (reference) parameter
  \def\kezd{}\relax% the symbols to be put before the output
  \def\veg{}\relax% the symbols to be put after the output
  \IfBeginWith{\param}{#4}{% if starts with round parantheses,
                           % we remove it from both sides;
                           % the parameter changes
    \StrPosition{\param}{#5}[\vegz]%
    \newcount\ind%
    \ind = \vegz%
    \advance \ind by -1%
    \StrMid{\param}{2}{\ind}[\param]%
    \def\kezd{#4}%
    \def\veg{#5}%
  }{}\relax%
  \IfBeginWith{\param}{1}{% if the reference starts with 1,
                          % special care is required
    \StrLen{\param}[\hossz]%
    \newcount\ind%
    \newcount\vege%
    \ind = \hossz%
    \vege = 0%
    \loop% loops while it does not find a digit at the end
         % (in \ref-s, strangely, an \hbox {} appears at the end;
         % this loop was actually written to remove these)
      \StrChar{\param}{\ind}[\kar]%
      \IfSubStr{1234567890}{\kar}{\vege=1}{}\relax%
      \ifnum \vege = 0%
        \advance \ind by -1%
    \repeat%
    \StrLeft{\param}{\ind}[\paramuj]% \paramuj will contain the
                                    % ``cleaned'' parameter
    \StrPosition[1]{\paramuj}{.}[\elsopontpozicioja]%
    \StrLen{\paramuj}[\hossz]%
    \newcount\eppme% position of the first dot minus 1
    \eppme = \elsopontpozicioja%
    \advance \eppme by -1%
    \ifnum \elsopontpozicioja = 0%
      \StrLeft{\paramuj}{\hossz}[\prefix]%
    \else%
      \StrLeft{\paramuj}{\eppme}[\prefix]%
    \fi%
    \StrLen{\prefix}[\elsohossz]%
    \ifnum \elsohossz = 1% 1
      #3%
    \else\ifnum \elsohossz = 2% 10
      #2%
    \else\ifnum \elsohossz = 3% 100
      #2%
    \else\ifnum \elsohossz = 4% 1000
      #3%
    \fi\fi\fi\fi%
  }{%
    \StrChar{\param}{1}[\kar]%
    \newcount\az%
    \az = 0%
    \IfSubStr{2346789}{\kar}{% digits that require ``a'';
                             % this is redundant, but was kept for some reasons
      \az = 0%
    }{%
      \IfSubStr{5AEIOUFLMNRSaeiouflmnrs}{\kar}{% digits and letters
                                               % that require ``az''
        \az = 1%
      }{%
        \az = 0%
      }\relax%
    }\relax%
    \ifnum \az = 1%
      #3%
    \else%
      #2%
    \fi%
  }%
  \ \kezd\param\veg%
}
%%
%% 
%% Copyright (C) 2015 by Zalan Bodo <zbodo@cs.ubbcluj.ro>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in the file:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%% Zalan Bodo.
%% 
%% This work consists of the file nevelok.dtx and a Makefile.
%% Running make generates the derived files README.txt, nevelok.pdf and nevelok.sty.
%% Running make inst installs the files in the user's TeX tree.
%% Running make install installs the files in the local TeX tree.
%% 
%%
%% End of file `nevelok.sty'.
