Nyctergatis Markup Engine

Nyctergatis Markup Engine (NME) is a library for parsing text with markup and converting it to other text formats. The markup has the following goals:

The markup is based on Creole. Creole is a collaborative work in progress; only its core features are frozen. This is why the documentation of the markup used by NME is not Creole itself, but the documentation provided with the engine.

NME provides the core cross-platform conversion code and optional extensions which can be embedded in other applications; platform-specific support functions for C++, Windows MFC, OS X (Objective-C), and GTK+ (Linux); and command-line tools for single-file conversion as well as the creation of EPUB files from a set of files.

Overview

The library core is made of two source files in C:

NME.h
header file with all extern declarations and detailed usage information, compatible with C++;
NME.c
function and data definitions.

In addition, the following optional code is provided:

NMEStyle.h and NMEStyle.c
functions to collect style information separately
NMEAutolink.h and NMEAutolink.c
automatic conversion of CamelCase words and URLs to links;
NMEPluginCalendar.h and NMEPluginCalendar.c
plugin to create the calendar corresponding to a given month and year in a table.
NMEPluginRaw.h and NMEPluginRaw.c
plugin to embed raw data copied verbatim to the output stream;
NMEPluginReverse.h and NMEPluginReverse.c
plugin to reverse text;
NMEPluginRot13.h and NMEPluginRot13.c
plugin to apply ROT-13 conversion to text (letters A-M and N-Z are switched);
NMEPluginTOC.h and NMEPluginTOC.c
plugin to create a table of contents;
NMEPluginUppercase.h and NMEPluginUppercase.c
plugin to convert text to uppercase;
NMEPluginWiki.h and NMEPluginWiki.c
plugin to extract metadata and title;
NMETest.h and NMETest.c
implementation test (check the correct use of output markup and hooks);
NMECpp.h, NMEErrorCpp.h and NMEStyleCpp.h
C++ glue;
NMEGtk.h and NMEGtk.c
display of text with NME markup as styled text in GTK+ (Linux and Unix);
NMEMFC.h and NMEMFC.cpp
display of text with NME markup as styled text in MFC (Windows);
NMEObjC.h and NMEObjC.m
display of text with NME markup as styled text in Cocoa (OS X).

These files implement applications:

NMEMain.c
command-line application which filters its input (stdin), which is text with markup, and writes to its output (stdout) the result of the conversion to HTML or several other formats. To build it, cd to the NME distribution directory and type make;
NMERandomGen.c
command-line tool which generates random input to test NME. To build it, cd to the NME distribution directory and type make nmerandom;
NMETest.cpp
simple C++ test application. To build it, cd to the NME distribution directory and type make nmecpp;
NMEGtkTest.c
test application for NMEGtk which displays styled text in a GTK window. It requires GTK+ 2.0, available at http://www.gtk.org. To build it, cd to the NME distribution directory and type make nmegtk.

NME can also be used to create EPUB files. EPUB is a popular format for e-books (see below). Here are the files related to EPUB:

NE.h and NE.c
EPUB file building, with contents provided as XHTML (independent of NME, relies on the library zlib for zip creation);
NMEEPub.h and NMEEPub.c
NME style to convert from NME markup to EPUB XHTML;
NMEEPubMain.c
command-line application which creates EPUB files from a set of text files with NME markup.

EPUB

EPUB is a "distribution and interchange format standard for digital publications and documents". It is a standard designed by the International Digital Publishing Forum (IDPF) and used by many e-book readers, such as iBook on Apple iPad and other IOS devices, and software applications on most platforms.

EPUB are zip files with a .epub extension. They contain a set of content files in xhtml and other formats (jpeg, svg, etc. for images), and additional files for the document structure and information about the title, author, and other metadata.

Command-line tool

The command-line tool nmeepub, whose source code is provided with NME, converts a set of NME files to a single EPUB document. Typically, the book is written as a single NME file or as one NME file per chapter. Chapters start with a title (line starting with =), sections (if any) with a subtitle (line starting with ==), etc. A table of contents is created automatically.

Images can be embedded with {{...}}. In addition, the following extensions are implemented:

Text<< endnote Text of the endnote >>

Notes are collected and linked forward and backward to the text they are related to. The endnote text itself can contain NME markup.

<< title Document title >>
<< author Author name >>
<< identifier Document identifier >>
<< language Language ISO code >>
<< subject Document subject >>
<< description Document description >>
<< publisher Publisher name >>
<< date Publishing date (ISO format) >>
<< source Original source of the document >>
<< rights Copyright notice >>

Metadata information can be placed anywhere in the NME files.

<< cover Cover image file >>

The cover image file (e.g. cover.png) is an image to be used for the book cover. Currently, images are the only reliable way to have the desired cover on all platforms, and must be created outside nmeepub.

Usage

With nmeepub, it is extremely simple to convert a text document to a high-quality, easy-to-read e-book which can be distributed or just copied to your reader for personal use. Starting from the text of a book, for instance, you can open it in a text editor and quickly find titles to mark them with an equal sign, and throw some metadata tags (at least the title and author to identify quickly the document in your virtual library). Then once the conversion is done, the resulting EPUB file can be transferred to your reading device (for the iPad, drag the file to iTunes and synchronize your tablet).

The next step is to add a cover. Use any image editing application, create an image (typical dimension: height of 780 pixels, width of 580 pixels), save it as a PNG file (e.g. cover.png in the same folder as your NME files), and add << cover cover.png >> in your NME file.

A typical NME file could look like this:

<< title My Book >>
<< author My Name >>
<< cover cover.png >>

= Chapter 1
...

= Chapter 2
...

License

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of Yves Piguet nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Release notes

23 March 2013

23 October 2011

4 October 2011

31 March 2010

19 November 2008

25 August 2008

15 October 2007

12 October 2007

9 October 2007

4 October 2007

29 September 2007

23 August 2007

5 July 2007

4 July 2007

19 June 2007

7 June 2007

30 May 2007

24 April 2007

19 April 2007

18 April 2007

16 April 2007

30 March 2007

23 March 2007

20 March 2007


Copyright Yves Piguet, 4 October 2011. May be distributed with NME or cited with proper attribution.