Skip to content

Latest commit

 

History

History
76 lines (66 loc) · 2.19 KB

README.asciidoc

File metadata and controls

76 lines (66 loc) · 2.19 KB

text

This addon provides standalone functionality. The text addon provides functionality to perform text-based transformations like inflection of words or syntax highlighting.

Depends on

Addon Exported Optional

org.jboss.forge.furnace.container:simple

no

no

Setup

This Addon requires the following installation steps.

Add configuration to pom.xml

To use this addon, you must add it as a dependency in the pom.xml of your forge-addon classified artifact:

<dependency>
   <groupId>org.jboss.forge.addon.text</groupId>
   <artifactId>text</artifactId>
   <classifier>forge-addon</classifier>
   <version>${version}</version>
</dependency>

Features

Inflector for performing inflection on words

Allows for camelcasing, capitalization, humanization, pluralization etc. of words.

@Inject private Inflector inflector;
String plural = inflector.pluralize("foo");
Highligher to color code syntax in terminal output

Allows for color coding of the following content types:

  • JAVA

  • JSON

  • JAVASCRIPT

  • CSS

  • HTML (with inline JavaScript/CSS)

When working with files you can rely on the Highlighter to determine the syntax based on the filename.

@Inject private Highlighter highlighter;
highlighter.byFileName(resource.getName(), resource.getContents(), output.out());

When working with pure content you can specify the source syntax via the contentType argument.

@Inject private Highlighter highlighter;
highlighter.byType("JAVA", resource.getContents(), output.out());

You can provide your own resource tokenizer for the Highlighter to use by implementing the interface org.jboss.forge.addon.text.highlight.Scanner, and expose it either as a CDI bean or registered as a simple service via the org.jboss.forge.furnace.container.simple.Service services file.

Tip

If your addon uses a container that does not support "@Inject" annotations, services such as the Inflector may also be accessed via the AddonRegistry:

Imported<Inflector> imported = addonRegistry.getServices(Inflector.class);
Inflector inflector = imported.get();