text between tag manipulation (HTML)

text between tag manipulation (HTML)

am 30.04.2011 23:01:00 von david

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:

Lorem ipsum dolor


Proin sed sapien




I'm trying to generate:

1 Lorem ipsum 2 dolor


3 Proin sed sapien




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@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: text between tag manipulation (HTML)

am 01.05.2011 04:08:42 von David Christensen

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

Lorem ipsum dolor


>

Proin sed sapien


>
>
> I'm trying to generate:
>
>

1 Lorem ipsum 2 dolor


>

3 Proin sed sapien


>
>
> 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@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: text between tag manipulation (HTML)

am 01.05.2011 13:56:29 von Rob Dixon

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

Lorem ipsum dolor


>

Proin sed sapien


>
>
> I'm trying to generate:
>
>

1 Lorem ipsum 2 dolor


>

3 Proin sed sapien


>
>
> 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@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: text between tag manipulation (HTML)

am 01.05.2011 17:40:00 von david

>
>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@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/