Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » HTML/JSP Formatting(HTML and JSP formatting doesn't work as I expect in eclipse with WTP)
icon5.gif  HTML/JSP Formatting [message #510871] Thu, 28 January 2010 21:53 Go to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: January 2010
Junior Member
Eclipse isn't formatting/indenting HTML/JSP files as I expect. I will illustrate with a simple HTML.

If I create a file 1.xml, with the content:

<html><body><h1>This is a test</h1></body></html>

And the press Ctrl-f to format the code, it formats it as I expect:

<html>
     <body>
          <h1>This is a test</h1>
     </body>
</html>


However, if I do the same thing with a file 1.html, after hitting Ctrl-f, I am left with:

<html>
<body>
<h1>This is a test</h1>
</body>
</html>


No indentation. This makes large HTML files difficult to read. This situation is often worst with JSP files, where after formatting parts of tags get merged onto the same line. Sometimes the above code gets in a .jsp file gets formatted as:

<html>
<body><h1>This is a 
test</h1></body>
</html>


Does anyone know why this is happening? Why does XML formatting behave the way I expect, but HTML/JSP not?

Thanks,
John.
Re: HTML/JSP Formatting [message #510990 is a reply to message #510871] Fri, 29 January 2010 13:17 Go to previous messageGo to next message
Ian Tewksbury is currently offline Ian TewksburyFriend
Messages: 48
Registered: July 2009
Location: RTP, NC, USA
Member
The behavior you are seeing in the HTML/JSP formatting is the expected behavior. I am a little fuzzy on the details but I know a few years back the community was telling the developers that is how they wanted HTML/JSP pages formatted with only some tags automatically indented (I think block tags?, but I know table tags are) . I do know presently that the sentiment from the community has changed and there have been more requests to see HTML/JSP formatting like that of XML.

There are already many bugs open in Bugzilla, see search here, that are requests for improving the JSP/HTML formatting experience. The team has not yet decided the best course of action for this issue but it is certainly one that is not being ignored. I suggest if you want to show your support for a fix in this area that you cast your vote on one of the bugs/enhancements that seems most like what you are looking for.

Blue Skies,

~Ian


Ian Tewksbury
WTP JavaScript Tools
IBM Rational
-----
“When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return.” ~Leonardo da Vinci
Re: HTML/JSP Formatting [message #511049 is a reply to message #510871] Fri, 29 January 2010 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nowhere.a.com

farrelly.john@gmail.com wrote :
> Eclipse isn't formatting/indenting HTML/JSP files as I expect. I will
> illustrate with a simple HTML.
>
> If I create a file 1.xml, with the content:
>
> <html><body><h1>This is a test</h1></body></html>
>
> And the press Ctrl-f to format the code, it formats it as I expect:
>
>
> <html>
> <body>
> <h1>This is a test</h1>
> </body>
> </html>
>
>
> However, if I do the same thing with a file 1.html, after hitting Ctrl-f, I
> am left with:
>
>
> <html>
> <body>
> <h1>This is a test</h1>
> </body>
> </html>
>
>
> No indentation. This makes large HTML files difficult to read. This
> situation is often worst with JSP files, where after formatting parts of tags
> get merged onto the same line. Sometimes the above code gets in a .jsp file
> gets formatted as:
>
>
> <html>
> <body><h1>This is a test</h1></body>
> </html>

I do not use auto-formatting in JSP files at all. Because of the way
some browsers interpret HTML, having extra white space could cause an
un-planned line break in the rendered page.

<soan><%= value1 %>&bnsp;<%= value2 %></span>

looks quite different than

<span>
<%= value1 %>
&bnsp;
<%= value2 %>
</span>

For the auto-formatter to determine when it is ok to break up lines
approaches AI capabilities.

And it is worse when you have code snippets interspersed.

--
Wojtek :-)
Re: HTML/JSP Formatting [message #512098 is a reply to message #510871] Wed, 03 February 2010 21:58 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: January 2010
Junior Member
Thanks for the replies.

I just find it a bit frustrating that other IDEs (like NetBeans) format the JSP/HTML exactly as I expect, but eclipse doesn't. Eclipse is a much better IDE, and it's a pain to swap back and forth between then just to format some files ...
Re: HTML/JSP Formatting [message #646904 is a reply to message #511049] Mon, 03 January 2011 00:53 Go to previous messageGo to next message
Jeff Mounce is currently offline Jeff MounceFriend
Messages: 1
Registered: January 2011
Junior Member
Wojtek -

This is what the <jsp:text> tg and the XSLT <xsl:text> tag are built for!

Using:

<jsp:text> </jsp:text>

is preferable to:

&nbsp;

In general, free-form text is a no-no.

Anyhow, to the original poster. YES! Eclipse sucks at this.
Join the bugzilla faction and complain!!

-Jeff
Re: HTML/JSP Formatting [message #647071 is a reply to message #510871] Tue, 04 January 2011 13:18 Go to previous message
Ian Tewksbury is currently offline Ian TewksburyFriend
Messages: 48
Registered: July 2009
Location: RTP, NC, USA
Member
I can't seem to find the bug number but the formatting was recently revamped in WTP 3.2.x and 3.3 streams to work the way you would expect along with more options for controlling what gets indented.

The one thing I know the changes do not do is indent <body> or <head> under <html> but all other indenting happens as you describe it now.

~Ian


Ian Tewksbury
WTP JavaScript Tools
IBM Rational
-----
“When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return.” ~Leonardo da Vinci
Previous Topic:InputStream in the WebPageEditor
Next Topic:[jsdt] possible bug in ASTParser parsing FunctionExpression
Goto Forum:
  


Current Time: Thu Apr 25 05:21:03 GMT 2024

Powered by FUDForum. Page generated in 0.03189 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top