DenVdmj / htmlcompressor

Automatically exported from code.google.com/p/htmlcompressor
Apache License 2.0
0 stars 0 forks source link

Allow for simple compression of jsp templates #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am working on a project that runs on an embedded platform and uses jsp pages 
for the web interface. These jsp pages are precompiled into servlets as part of 
the build process. I would like to use htmlcompressor to compress these jsp 
pages before compiling them into servlets. I know that the recommended practice 
is to instead compress the resulting html "on the fly", but this not feasible 
due to resource constrains on the target platform.

I believe this could easily be achieved by just having htmlcompressor preserve 
<% ... %> and <jsp: ... > blocks. This would be more than enough, at least for 
simple use cases such as the one described.

Original issue reported on code.google.com by guille.r...@gmail.com on 25 Aug 2010 at 9:13

GoogleCodeExporter commented 8 years ago
Even if it was a good idea, on the technical side there is no good solution for 
cases like:

<jsp:include name="html" value="<br/>" /> 

as "/>" is not unique enough sequence to assume it won't be used anywhere 
inside jsp tag. I am currently just using regular expressions for parsing, this 
would require full scale jsp grammar parser to get it right.

If you need extra features you can always just download the sources and modify 
them to your needs. 

Original comment by serg472@gmail.com on 27 Aug 2010 at 5:58

GoogleCodeExporter commented 8 years ago
You are right, however the same is also happening here:

<script type="text/javascript">
<!--
// Don't forget to add </script> at the end!
document.write('bla bla bla');
[...]
-->
</script>

The regexp you're using would not realize the first </script> should be ignored.

Isn't this the same case?

Original comment by guille.r...@gmail.com on 27 Aug 2010 at 6:17

GoogleCodeExporter commented 8 years ago
You are not allowed to have </script> tag anywhere inside, it should be always 
masked: <\/script>.

Maybe I can add support for custom skip rules, so you can manually add any 
regexp you like. I will try to look into it on the weekend and see how it fits 
into the picture, can't promise anything though.

Original comment by serg472@gmail.com on 27 Aug 2010 at 3:20

GoogleCodeExporter commented 8 years ago
Well, that would certainly be very interesting!

Original comment by guille.r...@gmail.com on 27 Aug 2010 at 7:25

GoogleCodeExporter commented 8 years ago
Custom rules were added in 0.9.2 (see the front page for examples). Hopefully 
this solves it.

Original comment by serg472@gmail.com on 28 Aug 2010 at 2:25