Skip to end of metadata
Go to start of metadata

This document provides:

  • How to use the juneau-code.css stylesheet to produce highlighted text for Java, XML, HTML, manifest file, and config file code.

 

These styles can be used in any of the javadocs or web page content.

For example, the following highlighted text is shown on the Juneau website:

All we're doing here is defining our own extended tags in the stylesheet to provide highlights.  

<p class='bcode'>
<jc>// A simple POJO class</jc>
<jk>public class</jk> Person {
<jk>public</jk> String name = <js>"John Smith"</js>;
<jk>public int</jk> age = 21;
}
...
</p> 

Two classes to apply to block elements (typically <p> tags):

  • class='code' - Unbordered code block.

  • class='bcode' - Bordered code block.

The following elements are defined:

  • <jc> - Java comment
  • <jd> - Javadoc comment
  • <jt> - Javadoc tag
  • <jk> - Java keyword
  • <js> - Java string
  • <jf> - Java field
  • <jsf> - Java static field
  • <jsm> - Java static method
  • <ja> - Java annotation
  • <xt> - XML tag
  • <xa> - XML attribute
  • <xc> - XML comment
  • <xs> - XML string
  • <mk> - Manifest file key
  • <mv> - Manifest file value
  • <cc> - Config file comment 
  • <cs> - Config file section
  • <ck> - Config file key
  • <ce> - Config file entry

 

If marking up the language is too tedious, the sample REST app also includes a code formatter resource:

The formatter resource is not perfect.  For example, it can't detect static methods and fields.  But it's will provide a good starting point, especially for XML.