  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Struts - A MVC web framework | | Tomcat - JSP/Servlet container | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | | JSP - A mailing list about Java Server Pages specification and reference | |
Struts & Hibernate
|
|
|
  | | | Carriage return and html | Carriage return and html 2004-01-16 - By Vidar Langberget
Back I know how to parse carriage returns and replace it with <br>, but I need a bit more advanced logic. The problem is that the text I need to parse contains both carriage returns and some basic html. For example headings use <h2>Heading</h2> and there are a few html tables as well. The tables are the biggest problem. The replace method I've written puts <br> several places inside the table html code, so it looks horrible in a browser. This is a small example:
<table cellpadding="2" align="Center"><br/> <tbody><br/> <tr valign="Top"><br/> <td valign="Top"><br/> <div align="Left"> <h6> Architecture:</h6><br/> </div><br/> </td><br/> <td valign="Top"><h6> K7</h6><br/> </td><br/> <td valign="Top"><h6> P6</h6><br/> </td><br/> </tr><br/> <tr valign="Top"><br/> <td valign="Top"><p><b> Cache block size:</b></p><br/> </td><br/> <td valign="Top"><p> 64 Bytes<br/> </td><br/> <td valign="Top"><p> 32 Bytes<br/> </td><br/> </tr><br>
As you can imagine I need to improve my parsing method to skip adding <br> inside <table and </table>.
Any idea how I can do this?
Also, the heading is a problem. The whole text is put inside <p></p> and it works as long as there is no html in the text. But after a heading using <h2> for example, the rest of the text is rendered using standard text as defined in the browser, and not as <p> is defined in my stylesheet. What I need to do is add a <p> tag to the text after a blank line UNLESS the next line is a heading. Suggestions on how to handle this?
Any help appreciated!
Vidar
=========================================================================== To unsubscribe: mailto listserv@(protected) with body: "signoff JSP-INTEREST". For digest: mailto listserv@(protected) with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com
|
|
 |