lineno package guide, I found:
Attaching line numbers after TeX has broken the paragraph into lines is already quite a difficult job for TeX. Why? Because TeX does not normally give you any control after line breaking.
lineno.stydoes it by pretending that the current page ends after each and every line. This keeps TeX quite busy, but works.
I know the package
everyshi which offers
Is there a package that provides
Otherwise, I have to improve my knowledge of TeX and dissect the
Addition, an example of usage :
LuaTeXoffers "callback filters" that provide functionality such as you describe, see for example This, but whatever work you want done would need to be coded in lua(/tex).