nyctergatis.com

Contact

Projects
Sysquake Remote Live
NME
PDF
Hike
Sudoku
GifBuilder
jpeglib for Palm OS
MySQL Client
Cross-GCC for Mac OS
NME Usage

Nyctergatis Markup Engine (NME) - Simple text markup formatting based on Creole.

Author:
Yves Piguet
See also:
http://www.nyctergatis.com (home of NME project) and http://www.wikicreole.org (Creole site).

Markup

The following markup is recognized:

  • =main title=
  • ==section title==
  • ===subsection title=== etc.
  • empty-line-separated paragraphs
  • * (asterisk) for lists (multiple lines allowed, merged)
  • # for numbered lists (multiple lines allowed, merged)
  • ; : for definition lists (sublists are obtained by repeating *#;)
  • : for indented paragraphs
  • lines between {{{ and }}} alone in lines: preformatted (tabs are replaced with spaces with 4-char alignment)
  • **bold**
  • //italic//
  • __underline__
  • ## monospace ##
  • ^^superscript^^
  • ,,subscript,,
  • {{{verbatim}}}
  • ~x (escaped character, where x is nonblank)
  • ---- alone in a line for a horizontal rule
  • [[link]] or [[link|text]]
  • {{image}} or {{image|alt text}}
  • <<plugins>>, or block plugins where << and >> are alone in lines
  • <<<placeholder>>>

File overview

  • NME.c, NME.h: main source code of NME; everything else is optional
  • NMEAutolink.c, NMEAutolink.h: optional support for automatic conversion of CamelCase words (aka wiki words, i.e. words with mixed lowercase and uppercase letters used in some wikis as page names) and/or URL to links without requiring the double-bracket markup
  • NMEMain.c: source code of a command-line application which filters input text with NME markup, with support for many options

Usage

To convert text with NME markup to another format, such as HTML or RTF, only NME.c and NME.h are required. The code below shows how to convert markup to HTML.

    #include "NME.h"

    NMEText input;
    NMEInt inputLength;
    (read source of length inputLength into input)
    NMEInt size = ...; // buffer size, typically initialized to 2x inputLength
    NMEText buf;
    buf = malloc(size);
    NMEText output;
    NMEInt outputLength;
    NMEErr err;
    for (;;)
    {
        err = NMEProcess(input, inputLength,
            buf, size,
            kNMEProcessOptDefault, "\n", &NMEOutputFormatHTML, 0,
            &output, &outputLength, NULL);
        if (err == kNMEErrNotEnoughMemory) // unlikely
        {
            (increase size)
            (realloc buf)
        }
        else
            break;
    }
    if (err == kNMEErrOk)
        (write outputLength first bytes of output[])
    else
        (handle error)
    free(buf); // after output has been used or copied

Security

Inline images are subject to cross site scripting if links to arbitrary sources are supported. Hypertext links are less dangerous, because they must be clicked by the user and they are loaded in separate pages.

Generated by Doxygen.
Copyright 2007-2013, Yves Piguet.
All rights reserved.