%% parstat.opm
%% Copyright 2025-2026 Petr Krajník
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   https://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008 or later.
%%
%% This work has the LPPL maintenance status 'maintained'.
%%
%% The Current Maintainer of this work is Petr Krajník.
%%
%% This work consists of the files parstat.opm and parstat.lua.
%%

\_codedecl \parstat {Paragraph statistic macro <v1.1>}

\_namespace{parstat}

\_newcount\.enabled
\.enabled=0 %% Parstat is disabled at default

\_def\.enable {\.enabled=1 \_relax}
\_def\.disable{\.enabled=0 \_relax}

\_newcount\.verbose
\.verbose=1 %% Simple outputs at default

\_def\.parstat{\_directlua{parstat.summary()}}

\_def\.reset{\_directlua{parstat.reset()}}

\_newpublic \_let\parstatenable=\.enable
\_newpublic \_let\parstatdisable=\.disable
\_newpublic \_let\parstatverbose=\.verbose
\_newpublic \_let\parstat=\.parstat
\_newpublic \_let\parstatreset=\.reset

\_newcount\.fskip
\.fskip=1 %% Skipped lines at par front

\_newcount\.bskip
\.bskip=1 %% Skipped lines at par back

\_newpublic \_let\parstatfskip=\.fskip
\_newpublic \_let\parstatbskip=\.bskip

\_directlua{%
   require("parstat")
   callback.add_to_callback("post_linebreak_filter", parstat.run, "parstat")
}

\_endcode

For more infornation, see the project repository:
https://github.com/petrk23/parstat
