text between tag manipulation (HTML)

Hi.

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.)


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
david [ Sa, 30 April 2011 23:01 ] [ ID #2058976 ]

Re: text between tag manipulation (HTML)

On 04/30/2011 02:01 PM, 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.)

http://search.cpan.org/~jfearn/HTML-Tree-4.2/lib/HTML/TreeBu ilder.pm


HTH,

David

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
David Christensen [ So, 01 Mai 2011 04:08 ] [ ID #2058990 ]

Re: text between tag manipulation (HTML)

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-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Rob Dixon [ So, 01 Mai 2011 13:56 ] [ ID #2058991 ]

Re: text between tag manipulation (HTML)

>
>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?


Sorry, that wasn't worded clearly.

I'm trying to manipulate the source code, but I don't want to destroy
the tags or the structure of the document.




-David

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
david [ So, 01 Mai 2011 17:40 ] [ ID #2059023 ]
Perl » gmane.comp.lang.perl.beginners » text between tag manipulation (HTML)

Vorheriges Thema: How to Generate An Expression to A LOL?
Nächstes Thema: Efficient way to compare 2 data structures particularly hash