blob: 070b996412ca7e1a62cc4be2791d2d399fe85055 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
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
=======
GPLv3, see LICENSE
AUTHORS
=======
Ali Fardan <raiz@stellarbound.space>
|