% see lua file for copyright information (MIT License)

\def\lvdebugpkgdate{2016/05/30}
\def\lvdebugpkgversion{0.5}

\expandafter\ifx\csname ProvidesPackage\endcsname\relax
  \input ifluatex.sty\relax
\else
  \NeedsTeXFormat{LaTeX2e}
  \ProvidesPackage{lua-visual-debug}[\lvdebugpkgdate\space v\lvdebugpkgversion\space Visual debugging in LuaLaTeX (PGU)]
  \RequirePackage{ifluatex}
\fi

\def\luavisualdebug@dothings{%
  \directlua{ lvd = require("lua-visual-debug")}%
  \AtBeginShipout {\directlua{lvd.show_page_elements(tex.box["AtBeginShipoutBox"])}}%
}

\expandafter\ifx\csname ProvidesPackage\endcsname\relax
  \ifluatex
   \input atbegshi.sty\relax
   \luavisualdebug@dothings
   \AtBeginShipoutInit
  \else
    \message{Warning: lua-visual-debug only works with LuaTeX (plain and LaTeX format)}
  \fi
\else
  \ifluatex
    \RequirePackage{atbegshi}
    \luavisualdebug@dothings
  \else
    \PackageWarning{lua-visual-debug}{You are using this package without LuaTeX. This is not supported, so you don't get any visual debugging.}
  \fi
\fi



