On 30/04/2011 22:01, David wrote:
I'm trying to insert on-screen sequential numbers (in locally saved web documents) to let non-web designers comment on the elements/tags. Additionally, these numbers act as a pseudo-line/reference number. Just to be clear, if I have: <body> <p>Lorem ipsum <b>dolor</b></p> <p>Proin sed sapien</p> </body> I'm trying to generate: <body> <p>1 Lorem ipsum <b>2 dolor</b></p> <p>3 Proin sed sapien</p> </body> I'm familiar with opening/saving files, loops, and regex, however, working with/seamless massaging the text between tags, (and not damaging the nested tag structure) is beyond me. How could I manipulate HTML final rendered, on screen text, but respect the HTML source? (I'm having a lot of trouble forming a regex that honors tags within tags.)
It is a bad idea to try to manipulate HTML using regular expressions: you should parse the HTML into a document object and manipulate that. This looks to me like a job for JavaScript. Just find all the text nodes in the document body and precede them with an incrementing sequence of numbers. Perhaps I have missed something as I don't understand what you mean by
manipulate HTML final rendered, on screen text
as the rendered display is clearly not HTML any longer. Also
respect the HTML source
puzzles me. Are you hoping to annotate the display without modifying the HTML? Anyway, I hope this helps. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/