about summary refs log blame commit diff stats
path: root/README
blob: e2981792639c4032ed8a13897bae596d5a4612ea (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) -- examing the parsed object type
gemtext_text_new(3) -- creating a new object
gemtext_text_string(3) -- accessing the underlying object string
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;

		line = gemtext_h1_new("This is a heading");
		if (line == NULL)
			errx(1, "gemtext_h1_new failed");
		if (gemtext_encode_file(line, "/dev/stdout") == -1)
			errx(1, "gemtext_encode_file failed");
		gemtext_free(line);
		printf("\n");

		line = gemtext_text_new("This is a paragraph");
		if (line == NULL)
			errx(1, "gemtext_text_new failed");
		if (gemtext_encode_file(line, "/dev/stdout") == -1)
			errx(1, "gemtext_encode_file failed");
		gemtext_free(line);
		printf("\n");

		return 0;
	}

TODO
====
- write more tests
- add functions allowing for more flexible use of struct gemtext** lists

LICENSE
=======
GPLv3, see LICENSE

AUTHORS
=======
Ali Fardan <raiz@stellarbound.space>