blob: 56898de066dc9483ee48305850de86cce2527d40 (
plain) (
tree)
|
|
libgemtext
==========
This library implements a decoder (parser) and encoder along with
functions for processing the text/gemini format.
Usage
=====
To get started, refer to the manpages:
gemtext_decode(3) -- for the decoder and its wrappers
gemtext_encode(3) -- for the encoder and its wrappers
gemtext_type(3) -- examining the parsed object type
gemtext_text_new(3) -- creating a new object
gemtext_text_string(3) -- accessing the underlying object string
gemtext_text_strlen(3) -- strlen(3) equivalent for gemtext objects
gemtext_list_append(3) -- adding items to gemtext lists
gemtext_free(3) -- free()'ing struct gemtext* after use
Installation
============
$ make
# make install
Examples
========
Parse text/gemini file
----------------------
#include <stddef.h>
#include <err.h>
#include <gemtext.h>
int
main(int argc, char *argv[])
{
struct gemtext **list;
list = gemtext_list_decode_file("index.gmi");
if (list == NULL)
errx(1, "gemtext_list_decode_file failed");
/* Do your thing */
gemtext_list_free(list);
return 0;
}
Create text/gemini document and print to /dev/stdout
----------------------------------------------------
#include <stdio.h>
#include <err.h>
#include <gemtext.h>
int
main(int argc, char *argv[])
{
struct gemtext *line;
struct gemtext **list;
line = gemtext_h1_new("This is a heading");
if (line == NULL)
errx(1, "gemtext_h1_new failed");
list = gemtext_list_append(NULL, line);
if (list == NULL)
errx(1, "gemtext_list_append failed");
line = gemtext_text_new("This is a paragraph");
if (line == NULL)
errx(1, "gemtext_text_new failed");
list = gemtext_list_append(list, line);
if (list == NULL)
errx(1, "gemtext_list_append failed");
gemtext_list_encode_file(list, "/dev/stdout");
gemtext_list_free(list);
return 0;
}
LICENSE
=======
ISC, see LICENSE
AUTHORS
=======
Ali Fardan <raiz@stellarbound.space>
|