/
Implementing a Dialect

Implementing a Dialect

A Dialect is a way for Greenpepper to know how to convert a syntax into HTML. To implement and use a dialect, you will need to:

  • Implement the SpecificationDialect interface
  • Add your implementation in the classpath when running the specification Test and Add the --dialect option when running the specification.

Implement the SpecificationDialect interface.

The interface defines a method that should take the Specification as a String and convert it to an HTML page (with the <html> tag).

package com.greenpepper.dialect;

/**
 * Define a way to convert an input to the HTML output that will be fed to Greenpepper.
 */
public interface SpecificationDialect {

    /**
     * Converts the content of an input to the HTML output that will be fed to GreenPepper Core
     * @param input The input content to convert.
     * @return The HTML output.
     */
    String convert(InputStream input) throws SpecificationDialectException;
}

You can create a constructor that takes arguments, the arguments being an array of String. See the --dialect option to see how the option can be passed down.

Specify the --dialect option

Use the --dialect to specify the class implementing the Dialect and its arguments

java -cp ... --dialect com.mydomain.MyDialect;Arg1;Arg2 spec.extension out.html 
  • com.mydomain.MyDialect: the dialect class to instantiate
  • Arg1: the first String argument to pass in the constructor
  • Arg2: the second String argument to pass in the constructor


Related content

Writing your specification in MarkDown
Writing your specification in MarkDown
More like this
Java extensions - Markdown Dialect
Java extensions - Markdown Dialect
More like this
Java extensions - Office Documents Dialect
Java extensions - Office Documents Dialect
More like this
GreenPepper 4.2: Supporting Markdown Specifications
GreenPepper 4.2: Supporting Markdown Specifications
More like this
GreenPepper Maven Plugin - Write Specification in Office Documents
GreenPepper Maven Plugin - Write Specification in Office Documents
More like this
4.0 Changelog
4.0 Changelog
More like this