Mark Mark - 7 months ago 38
HTML Question

Simple text to HTML conversion

I have a very simple

with the
attribute enabled. I then accept just text, with no markup, from the textbox. Is there a common method by which line breaks and returns can be converted to

I'm not looking for anything earth shattering, but at the same time I don't just want to do something like:

html.Insert(0, "<p>");
html.Replace(Enviroment.NewLine + Enviroment.NewLine, "</p><p>");
html.Replace(Enviroment.NewLine, "<br/>");

The above code doesn't work right, as in generating correct html, if there are more than 2 line breaks in a row. Having html like
is not good; the
can be removed.


Depending on exactly what you are doing with the content, my typical recommendation is to ONLY use the <br /> syntax, and not to try and handle paragraphs.