In 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.sty
does 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 \EveryShipout
, \AtNextShipout
and \AtBeginDocument
.
Is there a package that provides \EveryShipoutLine
, \AtNextShipoutLine
and \AtBeginParagrapheLine
?
Otherwise, I have to improve my knowledge of TeX and dissect the lineno
package.
Addition, an example of usage :
LuaTeX
offers "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).