Continuous or per page, every nth line, empty lines counted or not — LibreOffice's Tools ▸ Line Numbering, round-tripping as its text:linenumbering-configuration and Word's w:lnNumType. CSS exposes no line boxes, so the layer Range-selects each block and takes the distinct tops of its client rects as its lines; LibreOffice renders the exported file with the numbers in the same places.