summaryrefslogtreecommitdiff
path: root/src/node.h
blob: 2d7f0a19bcccf3e308f7f478e1f688789553111c (plain)
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
#ifndef CMARK_NODE_H
#define CMARK_NODE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "cmark.h"
#include "buffer.h"
#include "chunk.h"

typedef struct {
	cmark_list_type   list_type;
	int               marker_offset;
	int               padding;
	int               start;
	cmark_delim_type  delimiter;
	unsigned char     bullet_char;
	bool              tight;
} cmark_list;

typedef struct {
	int               fence_length;
	int               fence_offset;
	unsigned char     fence_char;
	cmark_strbuf      info;
} cmark_fenced_code;

typedef struct {
	int level;
} cmark_header;

typedef struct {
	unsigned char *url;
	unsigned char *title;
} cmark_link;

struct cmark_node {
	cmark_node_type type;

	struct cmark_node *next;
	struct cmark_node *prev;
	struct cmark_node *parent;
	struct cmark_node *first_child;
	struct cmark_node *last_child;

	int start_line;
	int start_column;
	int end_line;
	bool open;
	bool last_line_blank;

	cmark_strbuf string_content;

	union {
		cmark_chunk       literal;
		cmark_list        list;
		cmark_fenced_code code;
		cmark_header      header;
		cmark_link        link;
	} as;
};

CMARK_EXPORT int
cmark_node_check(cmark_node *node);

#ifdef __cplusplus
}
#endif

#endif