[NTG-context] Word and character count excluding TeX-directives

Dr. Thomas Möbius moebius at medinfo.uni-kiel.de
Tue Jan 16 15:26:22 CET 2018

To meet some formal guidelines, I need to provide a word count of my
abstract and a character count of the main text, and a character count
of all the text appearing in figure captions.

Is this possible (maybe using some lua-magic)?

Thank you!
Thomas

Minimal example:

\definestartstop
[abstract]
[style=bold,
after={\blank[big]}]

\starttext
\title{My title: example of a word and character count}

{\strut\tfx Formal guidelines: word count of abstract: $x$, character
count of main text: $x$, character count of figure captions: $x$.}
\blank

\startabstract
This is the abstract. Read this and that.
\stopabstract

% start of the main text
Some random text with formulas

\startformula
y = α + βx + ε, \quad ε \sim N(0,σ^2)
\stopformula

And there are also figures with captions.

\startplacefigure[
location=bottom,
title={Residual plot with time $t$ on the x-axis and
residuals $e_{jt}$ on the y-axis},
reference={fig:subject-residual}]
\externalfigure[residuals][height=.242\textheight]
\stopplacefigure

And some more text with $x$ and $y$ and $z$, and \placeformula

\startformula \startalign
\NC a =\NC b \NR
\NC c =\NC d \NR
\stopalign \stopformula

And stop.
\stoptext