These are the default JavaScript macros of the application.

Open a file in the editor (or a URL in the default Web browser)

var fileName = app.getSelectedText();
if (fileName==null || fileName.length()==0) {
    javax.swing.JOptionPane.showMessageDialog(app,
            "Couldn't open the file: No selection.\n" +
            "A path (or a URL) must be selected in the active editor to open a file (or a Web site).",
            "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
}
else {
    var isUrl = fileName.startsWith("http://");

    var file = new java.io.File(fileName);

    // If this is a URL, open it in a browser
    if (isUrl) {
        java.awt.Desktop.getDesktop().browse(new java.net.URL(fileName).toURI());
    }
    else if (file.isFile()) {
        app.openFile(file.absolutePath);
    }
    else {
        javax.swing.JOptionPane.showMessageDialog(app,
                "File does not exist:\n" + file.absolutePath, "Error",
                javax.swing.JOptionPane.ERROR_MESSAGE);
    }
}



Order the lines

var removeDuplicates = true; // Change to "false" if you want to keep duplicates

function join(lines) {
    var sb = new java.lang.StringBuffer();
    if (lines!=null && lines.length>0) {
        for (var i=0; i<lines.length; i++) {
            //System.out.println(lines[i]);
            sb.append(lines[i]).append('\n');
        }
    }
    return sb.toString();
}

// Note: You'll want to consider wrapping your scripts inside calls to
// beginAtomicEdit() and endAtomicEdit(), so the actions they perform can
// be undone with a single Undo action.
textArea.beginAtomicEdit();
try {
    var lines = textArea.text.split("\n");

    if (removeDuplicates) {
        var ts = new java.util.TreeSet();
        for (var i=0; i<lines.length; i++) {
            ts.add(lines[i]);
        }
        lines = ts.toArray();
    }

    java.util.Arrays.sort(lines);
    textArea.text = join(lines);

} finally {
    textArea.endAtomicEdit();
}



Escape HTML characters

function replaceMultipleSpaces(text) {
    var p = java.util.regex.Pattern.compile("  +");
    var m = p.matcher(text);
    var sb = new java.lang.StringBuffer();
    while (m.find()) {
        var spaces = m.group();
        m.appendReplacement(sb, spaces.replace(" ", "&nbsp;"));
    }
    m.appendTail(sb);
    return sb.toString();
}

textArea.beginAtomicEdit();
try {
    var text = textArea.selectedText;
    if (text==null || text.length()==0) {
        javax.swing.JOptionPane.showMessageDialog(app,
                "Error:  No selection.\n" +
                "Text must be selected to HTML-ify.",
                "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
    }
    else {
        text = text.replace("&", "&amp;").replace("\"", "&quot;").
                replace("<", "&lt;").replace(">", "&gt;").
                replace("\t", "&#009;").replace("\n", "<br />\n");
        if (text.contains("  ")) { // Replace multiple spaces with &nbsp; sequences
            text = replaceMultipleSpaces(text);
        }
        var start = textArea.getSelectionStart();
        textArea.replaceSelection(text);
        textArea.setSelectionStart(start);
        textArea.setSelectionEnd(start+text.length());
    }
} finally {
    textArea.endAtomicEdit();
}