% Copyright 2012–2017 Patrick Gundlach (patrick@gundla.ch)
% Public repository: https://github.com/pgundlach/lua-check-hyphen
% Licensed under the MIT license. See the file 'mit-license.txt' for exact terms.

% Don't change these two lines, they are updated automatically
\def\luachekchyphenpkgdate{2018/04/19}
\def\luachekchyphenversion{0.7a}


\RequirePackage{ifluatex}
\RequirePackage{luatexbase}
\RequirePackage{keyval}

\DeclareOption{final}{\setkeys{luacheckhyphen}{final}}
\DeclareOption{nofile}{\setkeys{luacheckhyphen}{nofile}}

\DeclareOption*{\setkeys{luacheckhyphen}{\CurrentOption}}

\ProvidesPackage{lua-check-hyphen}[\luachekchyphenpkgdate\space v\luachekchyphenversion\space Hyphenation checking for LuaTeX (PGU)]



\def\luachekchyphendothings{\directlua{luachekchyphen.enable() }}

\define@key{luacheckhyphen}{nofile}[true]{\directlua{luachekchyphen.nofile  = "\luaescapestring{#1}"}}
\define@key{luacheckhyphen}{compact}[true]{\directlua{luachekchyphen.compact  = "\luaescapestring{#1}"}}
\define@key{luacheckhyphen}{final}[true]{\directlua{luachekchyphen.final  = "\luaescapestring{#1}"}}
\define@key{luacheckhyphen}{mark}[true]{\directlua{luachekchyphen.mark     = "\luaescapestring{#1}"}}
\define@key{luacheckhyphen}{whitelist}{\directlua{luachekchyphen.whitelist = "\luaescapestring{#1}"}}


\ifluatex
  \AtBeginDocument{\luachekchyphendothings}
  \directlua{luachekchyphen = require('lua-check-hyphen')}
  \def\LuaCheckHyphen#1{\setkeys{luacheckhyphen}{#1}}
  \AtEndDocument{\directlua{luachekchyphen.listhyphenatedwords()}}
\else
  \def\LuaCheckHyphen#1{}
  \message{Warning: lua-check-hyphen only works with LuaTeX (LaTeX format for now)}
\fi

\ProcessOptions


