Navigation C API Pages Python bindings Applications

Markup

Markup is an abstraction for formatted text as well as parsers for a few formats.

Markup
enum gp_markup_fmt_flags {
        GP_MARKUP_BOLD = 0x01,
        GP_MARKUP_LARGE = 0x02,
        GP_MARKUP_MONO = 0x04,
        GP_MARKUP_SUB = 0x08,
        GP_MARKUP_SUP = 0x10,
        GP_MARKUP_UNDERLINE = 0x20,
        GP_MARKUP_STRIKE = 0x40,
};

typedef struct gp_markup_glyph {
        /* unicode glyph */
        uint32_t glyph;
        /* text format, bold, monospace, .... */
        uint16_t fmt;
} gp_markup_glyph;

typedef struct gp_markup {
        uint32_t glyph_cnt;
        gp_markup_glyph glyphs[];
} gp_markup;

void gp_markup_dump(gp_markup *self);
Markup parsers
enum gp_markup_fmt {
        GP_MARKUP_PLAINTEXT,
        GP_MARKUP_GFXPRIM,
        GP_MARKUP_HTML,
};

gp_markup *gp_markup_parse(enum gp_markup_fmt fmt, const char *markup,
                           enum gp_markup_flags flags);

Plaintext Markup

Plaintext markup is simple utf8 text with newlines. Any of \r, \n, \r\n and \n\r are considered to be newlines and any sequence of whitespaces such as ' ' or \t are considered to be a single space.

Gfxprim Markup

Gfxprim markup is similar to markdown or asciidoc text format. Special characters are escaped with \ as \*.

Table 1. Supported format attributes

{init_val}

A variable, value is set by the get() function

*bold*

Bold text

`monospace`

Monospace text

_subcript_

Subscript

^superscript^

Superscript

~underline~

Underline

#large#

Large text

HTML Markup

HTML markup is able to parse basic tags. Unsupported tags are ignored.

Table 2. Supported tags

<b>

Bold text

<br> or <br />

Line break

<big>

Large text

<hr> or <hr />

Horizontal line

<s>

Strike through

<sub>

Subscript

<sup>

Superscript

<span>

See below the supported span attributes.

<tt>

Monospace font

<u>

Underline

WARN: Only one level of sub and sup is supported.

Table 3. Supported span attributes

font_weight

bold or normal

strikethrough

true or false

color

fg_color

See colors table.

foreground

Table 4. Colors

text (Default text color)

red

bright-red

green

bright-green

yellow

bright-yellow

blue

bright-blue

magenta

bright-magenta

cyan

bright-cyan

gray

white

Table 5. Supported escapes

&amp;

&

&lt;

<

&gt;

>

&nbsp;

Non breakable space

&copy;

©

&reg;

®

&deg;

°

&plusmn;

±

&micro;

µ