aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ast.h80
-rw-r--r--src/blocks.c6
-rw-r--r--src/cmark.c6
3 files changed, 50 insertions, 42 deletions
diff --git a/src/ast.h b/src/ast.h
index 263b9cb..6c77c68 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -15,18 +15,20 @@ extern "C" {
#define REFMAP_SIZE 16
#define CMARK_MAX_LINK_LABEL_LENGTH 1000
+typedef enum {
+ CMARK_INL_STRING,
+ CMARK_INL_SOFTBREAK,
+ CMARK_INL_LINEBREAK,
+ CMARK_INL_CODE,
+ CMARK_INL_RAW_HTML,
+ CMARK_INL_EMPH,
+ CMARK_INL_STRONG,
+ CMARK_INL_LINK,
+ CMARK_INL_IMAGE
+} cmark_inl_tag;
+
struct cmark_node_inl {
- enum {
- CMARK_INL_STRING,
- CMARK_INL_SOFTBREAK,
- CMARK_INL_LINEBREAK,
- CMARK_INL_CODE,
- CMARK_INL_RAW_HTML,
- CMARK_INL_EMPH,
- CMARK_INL_STRONG,
- CMARK_INL_LINK,
- CMARK_INL_IMAGE
- } tag;
+ cmark_inl_tag tag;
union {
cmark_chunk literal;
struct cmark_node_inl *inlines;
@@ -55,19 +57,23 @@ struct cmark_reference_map {
typedef struct cmark_reference_map cmark_reference_map;
+typedef enum {
+ bullet,
+ ordered
+} cmark_list_type;
+
+typedef enum {
+ period,
+ parens
+} cmark_delim_type;
+
// Types for blocks
struct cmark_ListData {
- enum {
- bullet,
- ordered
- } list_type;
+ cmark_list_type list_type;
int marker_offset;
int padding;
int start;
- enum {
- period,
- parens
- } delimiter;
+ cmark_delim_type delimiter;
unsigned char bullet_char;
bool tight;
};
@@ -79,21 +85,23 @@ struct cmark_FencedCodeData {
cmark_strbuf info;
};
+typedef enum {
+ CMARK_BLOCK_DOCUMENT,
+ CMARK_BLOCK_BQUOTE,
+ CMARK_BLOCK_LIST,
+ CMARK_BLOCK_LIST_ITEM,
+ CMARK_BLOCK_FENCED_CODE,
+ CMARK_BLOCK_INDENTED_CODE,
+ CMARK_BLOCK_HTML,
+ CMARK_BLOCK_PARAGRAPH,
+ CMARK_BLOCK_ATX_HEADER,
+ CMARK_BLOCK_SETEXT_HEADER,
+ CMARK_BLOCK_HRULE,
+ CMARK_BLOCK_REFERENCE_DEF
+} cmark_block_tag;
+
struct cmark_node_block {
- enum {
- CMARK_BLOCK_DOCUMENT,
- CMARK_BLOCK_BQUOTE,
- CMARK_BLOCK_LIST,
- CMARK_BLOCK_LIST_ITEM,
- CMARK_BLOCK_FENCED_CODE,
- CMARK_BLOCK_INDENTED_CODE,
- CMARK_BLOCK_HTML,
- CMARK_BLOCK_PARAGRAPH,
- CMARK_BLOCK_ATX_HEADER,
- CMARK_BLOCK_SETEXT_HEADER,
- CMARK_BLOCK_HRULE,
- CMARK_BLOCK_REFERENCE_DEF
- } tag;
+ cmark_block_tag tag;
int start_line;
int start_column;
int end_line;
@@ -132,11 +140,11 @@ struct cmark_node_inl *cmark_make_link(struct cmark_node_inl *label, unsigned ch
struct cmark_node_inl* cmark_make_autolink(struct cmark_node_inl* label, cmark_chunk url, int is_email);
-struct cmark_node_inl* cmark_make_inlines(int t, struct cmark_node_inl* contents);
+struct cmark_node_inl* cmark_make_inlines(cmark_inl_tag t, struct cmark_node_inl* contents);
-struct cmark_node_inl* cmark_make_literal(int t, cmark_chunk s);
+struct cmark_node_inl* cmark_make_literal(cmark_inl_tag t, cmark_chunk s);
-struct cmark_node_inl* cmark_make_simple(int t);
+struct cmark_node_inl* cmark_make_simple(cmark_inl_tag t);
// Macros for creating various kinds of simple.
#define cmark_make_str(s) cmark_make_literal(INL_STRING, s)
diff --git a/src/blocks.c b/src/blocks.c
index f0560ad..c0c2342 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -16,7 +16,7 @@
#define peek_at(i, n) (i)->data[n]
-static node_block* make_block(int tag, int start_line, int start_column)
+static node_block* make_block(cmark_block_tag tag, int start_line, int start_column)
{
node_block* e;
@@ -85,7 +85,7 @@ static bool is_blank(strbuf *s, int offset)
return true;
}
-static inline bool can_contain(int parent_type, int child_type)
+static inline bool can_contain(cmark_block_tag parent_type, cmark_block_tag child_type)
{
return ( parent_type == BLOCK_DOCUMENT ||
parent_type == BLOCK_BQUOTE ||
@@ -251,7 +251,7 @@ static void finalize(node_block* b, int line_number)
// Add a node_block as child of another. Return pointer to child.
static node_block* add_child(node_block* parent,
- int block_type, int start_line, int start_column)
+ cmark_block_tag block_type, int start_line, int start_column)
{
assert(parent);
diff --git a/src/cmark.c b/src/cmark.c
index ac0c230..14901af 100644
--- a/src/cmark.c
+++ b/src/cmark.c
@@ -108,7 +108,7 @@ inline cmark_node_inl* cmark_make_autolink(cmark_node_inl* label, chunk url, int
return cmark_make_link(label, clean_autolink(&url, is_email), NULL);
}
-inline cmark_node_inl* cmark_make_inlines(int t, cmark_node_inl* contents)
+inline cmark_node_inl* cmark_make_inlines(cmark_inl_tag t, cmark_node_inl* contents)
{
cmark_node_inl * e = (cmark_node_inl *)calloc(1, sizeof(*e));
if(e != NULL) {
@@ -120,7 +120,7 @@ inline cmark_node_inl* cmark_make_inlines(int t, cmark_node_inl* contents)
}
// Create an inline with a literal string value.
-inline cmark_node_inl* cmark_make_literal(int t, cmark_chunk s)
+inline cmark_node_inl* cmark_make_literal(cmark_inl_tag t, cmark_chunk s)
{
cmark_node_inl * e = (cmark_node_inl *)calloc(1, sizeof(*e));
if(e != NULL) {
@@ -132,7 +132,7 @@ inline cmark_node_inl* cmark_make_literal(int t, cmark_chunk s)
}
// Create an inline with no value.
-inline cmark_node_inl* cmark_make_simple(int t)
+inline cmark_node_inl* cmark_make_simple(cmark_inl_tag t)
{
cmark_node_inl* e = (cmark_node_inl *)calloc(1, sizeof(*e));
if(e != NULL) {