Integrated Data Article

Library

The IDA reference implementations are designed to provide everything by including/importing/loading a single unit—in most cases, a single file. The C++ version has separate header/source files, and JavaScript users should load either the original or the minimised file.

C++

Include the C++ implementation with #include "IDA.cpp" and construct elements with IDA() .

Note that ~IDA() will deallocate a full article including all adjacent elements, parameters and list items recursively. Any detached or copied elements will need an explicit delete call, as if new had been used to create them.

As a usage alternative, we test compilation separately with g++ -std=c++17 -c -o IDA.o IDA.cpp then link it using -include IDA.o to run unit tests.

C#

To-do: Directions for C#, ideally with .NET ahead of Mono.

Java

Add the Java implementation to the classpath, either the IDA.java source file or built as IDA.jar . Import with import com.ida_markup.ida.IDA; and instantiate with new IDA() .

The JAR can be created with javac -d bin IDA.java then jar cfe IDA.jar IDA -C bin . . Cleaning the intermediate class files with rm -r bin will leave IDA.jar available for use.

JS

Load the JavaScript implementation with IDA = require("./IDA"); in Node.js.
In HTML, place <script src="IDA.js"></script> within the head element.

Either will make available the constructor new IDA() .

PHP

Load the PHP implementation with require_once "IDA.php"; and construct elements with new IDA() .

Py

Load the Python implementation with from IDA import IDA and construct elements with IDA() .

Note: This is designed for (and tested with) Python 3.
Conceptually it is functional with Python 2, but at present it only passes most of our tests that way. The main problem is with the test environment and its validation of Python 2 strings when Unicode is involved.

Parser program

In addition to being included as a library, each of the IDA reference implementations can also be run as an independent command-line program for testing the parser response to markup provided via standard input.

C++

The C++ implementation inserts a main function if IDA_MAIN is defined during compilation.

Using GCC, this can be compiled with g++ -std=c++17 -D IDA_MAIN -o IDA IDA.cpp , launched with ./IDA and cleaned with rm IDA .

C#

The IDA class in the C# implementation contains a Main method.

Using Mono, this can be compiled with mcs IDA.cs , launched with ./IDA.exe and cleaned with rm IDA.exe .

To-do: At least a simple .NET equivalent (csc.exe?)

Java

The IDA class in the Java implementation contains a main method, and therefore can be:

  • Compiled with javac IDA.java and launched with java IDA .
    This creates several class files which can be cleaned with rm IDA.class 'IDA$'*.class .
  • Compiled with javac -d bin IDA.java , packed with jar cfe IDA.jar IDA -C bin . , launched with java -jar IDA.jar and cleaned with rm -r bin IDA.jar .
  • Since Java 11, launched directly with java IDA.java .

JS

Using Node.js, the JavaScript implementation will start the parser when launched directly with nodejs IDA.js .

This is designed to operate in exactly the same manner as with the other implementations. It will block until input is complete and will exit after output is written, which is atypical for a JavaScript program.

PHP

The PHP implementation will start the parser when launched directly with php IDA.php .

Additionally, if served directly via HTTP, a POST request body will be parsed and the output will be sent as the response. At present, a GET request is considered equivalent to a POST request with zero body bytes, yielding an anonymous element with null content.

Py

The Python implementation will start the parser when launched directly with python3 IDA.py .

When the standard input is provided interactively from a terminal, sending ASCII ETX (Ctrl+C) will terminate the parser without sending any output.

Various technical differences exist in how each runtime responds to ASCII EOT (Ctrl+D) interactively; some will close the standard input, while others operate in raw-mode and forward the EOT to the parser. Either way, the parser will stop reading input and deliver the output.

PHP users should note that parsing a POST request is also intended only for testing. Most will want to deploy access management which avoids serving IDA (or any other library) directly in a production scenario. Our preferred solution is to instruct the HTTP daemon not to serve any filenames containing .inc. , then rename IDA.php to IDA.inc.php .