R
Rocky Moore
I have a web site called HintsAndTips.com. On this site people post tips
using a very simply webform with a multi line TextBox for inputing the tip
text. This text is encode to HTML so that no tags will remain making the
page safe (I have to convert the linefeeds to <BR>s because the
Server.EncodeHTML does not do that it seems).
The problem is that users can use a special tag when editing the top to
specify an area of the tip that will be blocked into a scrollable div with a
pre tag so that the lines do not wrap, but that it does not spread beyond
the width of the content area of the tip. As an example, here is a tip that
uses this tag which is replaced with the div and pre tags as needed:
http://hintsandtips.com/hat.aspx?P=ShowTip&C=31&F=100&T=10
If the text in that special area is wider than the page it will scroll and
not break the formatting of the page. But as you can see there are no
linefeeds in that special section which do exist in the tip itself (but now
as <BR>s).
So, I need to build a RegEx expression that will replace all linefeeds
except between <pre></pre> tags. Would also be nice if it would only do
that if the <pre></pre> tags are balanced so that it will do nothing if one
is missing.
Is this even possible? Do I need to parse the text line-by-line or maybe it
is just something really simple I am overlooking?
Any help appreciated!
using a very simply webform with a multi line TextBox for inputing the tip
text. This text is encode to HTML so that no tags will remain making the
page safe (I have to convert the linefeeds to <BR>s because the
Server.EncodeHTML does not do that it seems).
The problem is that users can use a special tag when editing the top to
specify an area of the tip that will be blocked into a scrollable div with a
pre tag so that the lines do not wrap, but that it does not spread beyond
the width of the content area of the tip. As an example, here is a tip that
uses this tag which is replaced with the div and pre tags as needed:
http://hintsandtips.com/hat.aspx?P=ShowTip&C=31&F=100&T=10
If the text in that special area is wider than the page it will scroll and
not break the formatting of the page. But as you can see there are no
linefeeds in that special section which do exist in the tip itself (but now
as <BR>s).
So, I need to build a RegEx expression that will replace all linefeeds
except between <pre></pre> tags. Would also be nice if it would only do
that if the <pre></pre> tags are balanced so that it will do nothing if one
is missing.
Is this even possible? Do I need to parse the text line-by-line or maybe it
is just something really simple I am overlooking?
Any help appreciated!