Extendable Text Processor (Extexp)
Previous
Next

Executor Commands

Executors are the set of commands which undertake the text transformations.

Whilst Extexp is designed as an extendable text processor and can have additional executors added, there are a standard set of executor commands present in the extexp plug-in.

All executors commands have a parameter with the key Do and a value which is the executor name.

An example of this part of the executor command is:

    {
        "Do": "copy";
        ...
    }

 Copy

The Copy command copies text to the target file.

Example:

    {
        "Do": "copy";
        "from": "example.md";
        "to": "!example";
    }

 Copy resources

The Copy Resources command copies contents of resource folder to the target folder.

It has two optional parameters to and foldername.

The folder structure for resource input will allow optional child folder structures within the resources folder, but the resulting created resources folder will be flat structure.

The folder structure between the project source folder and the input resources folder will be replicated between the source folder and the output resources folder.

Examples:

    {
        "Do": "copyresources";
    }
or
    {
        "Do": "copyresources";
        "to": "cache";
        "foldername": "images";
    }

 List

The List command copies the source to the output window. The title parameter defines the displayed title and from parameter defines the source.

Example:

    {
        "Do": "list";
        "from": "example.md";
        "title": "Example ONE";
    }

which displays:

======================================
Example ONE
======================================
file content 
....
======================================

 Message

The Message command writes a message to the output window. The text parameter defines the displayed message.

Example:

    {
        "Do": "message";
        "text": "Processing page ${page}";
    }

displays (where parameter page has the value “index”):

Processing page index

 Substitute

The substitute command processes a template (usually a file) performing parameter substitution on all ${<key>} markers. The substitutions can be parameter values, in-memory file content, files content (from the input and shared input contexts). All insertions have parameter substitution performed on their content (i.e. the substitution process is fully recursive).

The command has two parameters:

Additional parameters may be defined in the command which will be available for use in the substitute process (as well as all parameters defined in parent controls).

Example:

    {
        "Do": "substitute";
        "from": "simple-template.txt",
        "to": "+generated-text";
    }

 FOP

XSL-FO is a W3C standard describing a XML vocabulary which defined printed pages. Tools exist which can process these documents and create PDF output. There is an Apache open source tool (FOP) which can be used for this purpose. This commands runs the FOP tool.

The command has two parameters:

This commands requires that the FOP software is installed on your machine and the any necessary configuration is undertaken via the NetBeans Preference screen. For more details about this please see Configuring Extexp.

Example:

    {
        "Do": "fop";
        "xsl-fo": "book",
        "to": "Book.pdf";
    }

 External

This command will run any simple text processing program that is available on your workstation. It required addition parameters:

The error stream from the external program will be written to the netbeans output window.

If using Linux or MacOS, programs such as grep, sed and awk are text processing programs which could be executed by this command to access additional specialist text processing capabilities.

Example:

    {
        "Do": "external";
        "command": "wc",
        "parameters": "-w",
        "from": "chapter2.md",
        "to": "wc-param"
    }

 Markdown

Markdown is a lightweight markup language with plain text formatting syntax. This command processes the markdown document and process html output (which is probably a html fragment for later insertion into a full html document).

There are a range of markdown processors available, and whilst it is technically possible to use any such software, the extexp project recommends use of the kramdown processor.

The command requires up to three parameters:

At its simplest, the ERB template file provides a wrapper around the generated source. The point in the template where the processed markdown is to be inserted is marked with a tag <%=@body%>.

However it is more normal practise within Extexp to use the markdown command to generate a html fragment, and then combine all the fragments into a final html document using either the Substitute or FreeMarker commands (i.e. not using the markdown template parameter), but the software can support either styles.

This commands requires that the kramdown software is installed on your machine and the any necessary configuration is undertaken via the NetBeans Preference screen. For more details about this please see Configuring Extexp.

Example:

    {
        "Do": "markdown";
        "from": "chapter2.md",
        "to": "!chapter2"
    }

 Markdown and Substitute

The Markdown And Substitute command (markdown-substitute) is a convenience command combining the Markdown and Substitute commands. It has the same parameters as the markdown command, first processing the markdown text, after which it runs the substitution process on the generated output before saving it (the to parameter).

Additional parameters may be defined in the command which will be available foe use in the substitute process (as well as all parameters defined in parent controls).

Example:

    {
        "Do": "markdown-substitute";
        "from": "chapter2.md",
        "to": "!chapter2",
        "title": "ABC ... XYZ"
    }

 FreeMarker

FreeMarker provides a more fully featured templating language for building complex documents. All parameters and in-memory filestore is made available to the FreeMarker engine, and files can be made available, by declaration as a parameter value.

Two parameters are required:

Additional parameters may be defined in the command which will be available for use by FreeMarker (as well as all parameters defined in parent controls).

While the FreeMarker software is already installed on your workstation, there is a small amount of necessary configuration to be undertaken via the NetBeans Preference screen. For more details about this please see Configuring Extexp.

Example:

    {
        "Do": "freemarker";
        "template": "main.ftl",
        "to": "!chapter2",
        "title": "Chapter 2 - Getting to know your Software",
        "content": "content-fragment-ch2"
    }

 Imageset

The Imageset command (create-imageset) collects together information about a set of like images (each being a different image size) and creates a suitable <IMG> html tag. Such a tag would be used to display an image in a responsive design and would be inserted into an html document or fragment (using a templating or substitution method provided within Extexp).

The command has 5 required parameters:

Example:

    {
        "Do": "create-imageset",
        "to": "!swimming-3",
        "class": "img-responsive",
        "image": "Swimming-3.png",
        "width": "500",
        "height": "300"
    }

which creates content:

    <img
        width="500"
        height="300"
        src="resources/Swimming-3.jpg"
        class="img-responsive" alt=""
        srcset="resources/Swimming-3.jpg 500w,
            resources/Swimming-3-300x180.jpg 300w,
            resources/Swimming-3-200x120.jpg 200w,
            resources/Swimming-3-60x36.jpg 60w"
            sizes="(max-width: 500px) 100vw, 500px"
    />

 XSLT

XLST is a W3C standard describing a language for defining transforms that can be applied to a XML document to produce an output (normally another XML document). As HTML5 is an XML subset, it can be used to transform html documents or fragments.

The command requires 3 parameters:

Example of use: to transform a html document (probably generated from markdown sources) into an xsl-fo document for passing to FOP to build a pdf document.

Example:

    {
        "Do": "xslt",
        "from": "fullbook",
        "stylesheet": "bookbuilder.xsl",
        "to": "!fo"
    }

Previous
Next