org.tinyjee.maven.dim.sources
Class VelocityHighlightingTool

java.lang.Object
  extended by org.tinyjee.maven.dim.sources.AbstractParametricVelocityTool<VelocityHighlightingTool>
      extended by org.tinyjee.maven.dim.sources.VelocityHighlightingTool

@DefaultKey(value="highlighter")
public class VelocityHighlightingTool
extends AbstractParametricVelocityTool<VelocityHighlightingTool>

Implements a custom velocity tool that can be used to trigger code highlighting within templates.

Usage within a template:

 Highlighted content: $highlighter.highlight("public class MyClass {...}")
 

Quick Example - Embed the comment of a class with all code blocks (<code><pre>) being highlighted:

 %{include|source-content=$highlighter.highlightCodeBlocks($comment)|source-java=my.package.MyClass}
 

Reference:

Author:
Juergen_Kellerer, 2011-10-09

Constructor Summary
VelocityHighlightingTool()
           
 
Method Summary
 String css(String code)
          Shortcut to highlight("css", code).
 String highlight(String code)
          Highlights the given code and attempts to auto-select the highlighting scheme.
 String highlight(String brush, String code)
          Highlights the given code.
 String highlightCodeBlocks(String contentWithCodeBlocks)
          Highlights code blocks (<code>) in the given XHTML content and attempts to auto-select the highlighting scheme.
 String highlightCodeBlocks(String brush, String contentWithCodeBlocks)
          Highlights code blocks (<code>) in the given XHTML content.
 String java(String code)
          Shortcut to highlight("java", code).
 String js(String code)
          Shortcut to highlight("js", code).
 String jsp(String code)
          Shortcut to highlight("html/jsp", code).
 String xml(String code)
          Shortcut to highlight("xml", code).
 
Methods inherited from class org.tinyjee.maven.dim.sources.AbstractParametricVelocityTool
clear, get, nextInvocationParameters, put, remove, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VelocityHighlightingTool

public VelocityHighlightingTool()
                         throws MalformedURLException
Throws:
MalformedURLException
Method Detail

highlight

public String highlight(String code)
Highlights the given code and attempts to auto-select the highlighting scheme.

Parameters:
code - the code to highlight.
Returns:
the highlighted code block using XHTML markup.

highlight

public String highlight(String brush,
                        String code)
Highlights the given code.

Parameters:
brush - a brush name to use for highlighting (= highlighting scheme)
code - the code to highlight.
Returns:
the highlighted code block using XHTML markup.

highlightCodeBlocks

public String highlightCodeBlocks(String contentWithCodeBlocks)
Highlights code blocks (<code>) in the given XHTML content and attempts to auto-select the highlighting scheme.

Parameters:
contentWithCodeBlocks - the content with code blocks to highlight.
Returns:
the content with code blocks being highlighted.

highlightCodeBlocks

public String highlightCodeBlocks(String brush,
                                  String contentWithCodeBlocks)
Highlights code blocks (<code>) in the given XHTML content.

Parameters:
brush - a brush name to use for highlighting (= highlighting scheme)
contentWithCodeBlocks - the content with code blocks to highlight.
Returns:
the content with code blocks being highlighted.

java

public String java(String code)
Shortcut to highlight("java", code).

Parameters:
code - the code to highlight.
Returns:
the highlighted code.

js

public String js(String code)
Shortcut to highlight("js", code).

Parameters:
code - the code to highlight.
Returns:
the highlighted code.

css

public String css(String code)
Shortcut to highlight("css", code).

Parameters:
code - the code to highlight.
Returns:
the highlighted code.

xml

public String xml(String code)
Shortcut to highlight("xml", code).

Parameters:
code - the code to highlight.
Returns:
the highlighted code.

jsp

public String jsp(String code)
Shortcut to highlight("html/jsp", code).

Parameters:
code - the code to highlight.
Returns:
the highlighted code.