org.tinyjee.maven.dim.sh
Interface BrushResolver

All Known Implementing Classes:
BundledBrushesResolver

public interface BrushResolver

BrushResolver defines an interface that may be implemented and registered via service loading to register additional javascript brushes (= language support) for the syntax highlighting library.

Implementation:

 package my.package;
 public class MyBrushResolver implements BrushResolver {
      public Collection<URL> resolveBrushes() {
          return Collections.singleton(getClass().getResource("/my/package/my-brush.js"));
      }
      public String detectBrushAlias(URL source, Map<Integer, List<String>> sourceContent) {
          return source.getPath().toLowerCase().endsWith(".my-extension") ? "my-brush-alias" : null;
      }
 }
 

Register the implementation using service loading:

Since:
1.0
Version:
1.0
Author:
Juergen_Kellerer, 2010-09-03

Method Summary
 String detectBrushAlias(URL source, Map<Integer,List<String>> sourceContent)
          Auto Detects the brush alias name from the source URL or content.
 Collection<URL> resolveBrushes()
          Returns a list of URLs that point to ".JS" or ".ZIP" files containing additional brush definitions.
 

Method Detail

resolveBrushes

Collection<URL> resolveBrushes()
Returns a list of URLs that point to ".JS" or ".ZIP" files containing additional brush definitions.

Returns:
a list of URLs that point to ".JS" or ".ZIP" files containing additional brush definitions.

detectBrushAlias

String detectBrushAlias(URL source,
                        Map<Integer,List<String>> sourceContent)
Auto Detects the brush alias name from the source URL or content.

Parameters:
source - the source URL (.. to be used for extension matching).
sourceContent - the extracted content of the source (.. to be used for content based matching, e.g. shebang).
Returns:
a valid alias name of a brush that is defined inside the brushes returned by resolveBrushes() or 'null' if no alias can be resolved. Note: If the content is HTML with a compiled / script language inside tags, the returned value is "html/[brush-alias]" (e.g. JSP would map to "html/java").