Author |
Message |
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16662 Location: On a slope
|
c# version of nl2br that is "html safe"
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Mon Dec 24, 2007 8:06 am |
|
|
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16662 Location: On a slope
|
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Fri Dec 28, 2007 7:37 am |
|
|
RB
Emperor
Joined: Wed Apr 16, 2003 1:25 am Posts: 2560
|
_________________ ++
|
Thu Jan 03, 2008 7:13 am |
|
|
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16662 Location: On a slope
|
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Thu Jan 03, 2008 6:48 pm |
|
|
RB
Emperor
Joined: Wed Apr 16, 2003 1:25 am Posts: 2560
|
_________________ ++
|
Sat Jan 05, 2008 1:44 am |
|
|
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16662 Location: On a slope
|
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Sat Jan 05, 2008 10:55 am |
|
|
RB
Emperor
Joined: Wed Apr 16, 2003 1:25 am Posts: 2560
|
_________________ ++
|
Sat Jan 05, 2008 1:47 pm |
|
|
RB
Emperor
Joined: Wed Apr 16, 2003 1:25 am Posts: 2560
|
You do not have the required permissions to view the files attached to this post.
_________________ ++
|
Sat Jan 05, 2008 2:34 pm |
|
|
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16662 Location: On a slope
|
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Sat Jan 05, 2008 5:50 pm |
|
|
RB
Emperor
Joined: Wed Apr 16, 2003 1:25 am Posts: 2560
|
Look for '<'s in the text. If a '<' is followed by a tag name, then it is (most probably) an opening tag. If '<' is followed by '/' and a tag name, then it is (most probably) an closing tag.
The C++ thing isn't perfect from the point of leaks and speed too. But I thought it would not serve the purpose (showing some basic structure) if it were in full size and shine. So, don't spend much time on it.
Now, sigh, actually I didn't want you to tell me what your code is doing (I could see that barely), but to define the problem. Now, sorry for the ignorance, but I had very few meetups with C# and you may be assuming what someone else (say who knows less or same as me) don't know. So, let me try to define the problem:
You got HTML code, where you should replace LFs with BRs. Yet, some sort of problem occurs when you put BRs on place of each LF, and that is why you don't print it when LF is nested between some tags.
If my guess of what you are trying to make is right, this might be not so luckily approach. Why don't you define as well tags where LF should be replaced with BR in the first place? For example, in <table><tr><td> ... </td></tr></table> you may have text. This text can be formatted with <br />s. So (abstract point) ... every time you want to solve some problem, define it. This topic may need a split so that useful information be separated from talk about it.
_________________ ++
|
Sat Jan 05, 2008 6:06 pm |
|
|
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16662 Location: On a slope
|
Ah, ok. Yes, the point is that line feeds in some html structures (style, table and lists) don't get converted to <br>. That way if you have a prettily-formatted table in html and you run it through the method to convert the LF to <br> you don't end up with 30 line feeds in front due to all the LFs inside the html code.
The reason I need it is because the data input may be by people that don't understand html. Input it via a textarea that then gets saved to a database. When redisplaying the content in html form I don't want it messing up the LFs. How can someone that doesn't know html add html that'll screw up the formatting? Microsoft! They're practically html ignorant but know enough about MS apps to 'save for web' and get html markup to create tables, without actually knowing html.
Hope that helps.
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Sun Jan 06, 2008 9:53 am |
|
|
RB
Emperor
Joined: Wed Apr 16, 2003 1:25 am Posts: 2560
|
Ok, you know best what an user can put into textarea you are expecting input from. The task is pretty abstract without that (and thanks, I don't need to know it), but I think I can cast a suggestion: maybe it is easier to define on which areas of the input conversion should be done, no matter if they are in a table or even list (you can use <br>s in a list).
_________________ ++
|
Sun Jan 06, 2008 12:15 pm |
|
|