Log in with your MaiOtaku account.
Home Forum Anime Members Help

No tabs or returns in my description

sephiroth
I could probably detect by a regexp, but if your Regexp takes me more than 10 minutes to understand, there's no chance of implementing. :P<br> <br> Maybe a </ combination would be enough.
sephiroth
def replace_html_text (text)<br>   if text =~ /<br|<p/<br>    do_things_with_the text<br>   elsif text =~ /<\//<br>    do_things_with_the text.gsub("\n","<br>")<br>   else<br>    t = remove_html_stuff_of_the text<br>    return t.gsub("\n","<br>")<br>   end<br> end<br> <br> Here's the end result
danielfriesen
There's no need to test for specific text and parse posts in different ways. Frankly that's a very counter-intuitive way to do things. Just parse everything the same way. Convert some types of newline segments into br elements (and ideally paragraphs too). And then filter it either escaping everything then turning stuff that looks safe back to html or matching stuff that looks like html, checking it's safe, and then escaping every other run of text. You could even use markdown for the pre-filter syntax.
Please login to post.