Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

[JSPWiki] Sweet Java/HTML/XML syntax coloring

I found a very nice plugin for JSPWiki this morning: the Java to HTML converter.

This tool converts Java source code (files and snipplets) to HTML, RTF, TeX and XHTML with syntax highlighting. It is Open source under the GPL.

I've found that it works for Java, XML and HTML. Here's a couple of examples (I've hooked it into Roller's JSPWiki support):

Java


/**
@return Returns the id.
* @hibernate.id column="id"
*  generator-class="native" unsaved-value="null"
*/

public Long getId() {
    return this.id;
}

HTML


<html>
  <head>
    <title>HTML Test</title>
  </head>
  <body></body>
</html>

XML



<?xml version="1.0"?>

<!DOCENGINE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN" 
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="org.appfuse.persistence.User"
        table="app_user">

        <id
            name="id"
            column="id"
            type="java.lang.Long"
            unsaved-value="null"
        >
            <generator class="native">
            </generator>
        </id>

    </class>

</hibernate-mapping>

The one thing I don't like is that it centers the code using <center>, adding "center table {width: 100%}" to your stylesheet fixes the issue. I also tried to upgrade Roller's JSPWiki.jar to 2.1.86-alpha (to get XHTML support), but I was getting all kinds of stacktraces from OSCache and it just didn't work. Java2Html also has an Ant Task to convert Java source to HTML. Java2HTML has the same thing, but this new one supports different styles.

NOTE: The above syntax coloring produces invalid XHTML, so this site won't validate for awhile.

Posted in Java at Dec 05 2003, 01:02:08 PM MST 4 Comments
Comments:

I tried this out too recently and found the same problem with the center tag. Thanks for the tip on how to effectively get rid of that - Cheers Simon.

Posted by Simon Harris on December 05, 2003 at 08:10 PM MST #

I have released a new Version 3.5 on my website, that does no longer require the fix for the center tag. Also its output should now be XHTML compliant.

Posted by Markus Gebhard on December 07, 2003 at 04:15 PM MST #

Very nice Markus! I dig that it validates now too. Thanks. ;-)

Posted by Matt Raible on December 07, 2003 at 11:02 PM MST #

Markus, I like that you've switched from using a <center> tag to <div align="left"> - however, it was easier to write CSS when the <center> tag existed. Here's what I used in 3.4:

/* for the java2html plugin - so everything is not centered */
center table {
    width: 100%; 
    border: 1px solid #c0c0c0;
}

center table td {
    padding: 10px;
    padding-bottom: 0;
}

center table code {position: relative; top: -10px}
With 3.5, I can do the same thing with the following:

div table {
    width: 100%; 
    border: 1px solid #c0c0c0;
}

div table td {
    padding: 10px;
    padding-bottom: 0;
}

div table code {position: relative; top: -10px}
But any <table>'s inside of <div&gt's will get this rule applied to it. Would it be possible to put a class on the java2html <div>? For example <div align="left" class="java">. Just a suggestion, luckily, I don't have any table's in my div's and my altered CSS above works fine with 3.5.

Posted by Matt Raible on December 08, 2003 at 05:45 PM MST #

Post a Comment:
Comments are closed for this entry.