summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ast.h58
-rw-r--r--src/blocks.c8
-rw-r--r--src/cmark.h41
-rw-r--r--src/html/html.c6
-rw-r--r--src/print.c4
5 files changed, 50 insertions, 67 deletions
diff --git a/src/ast.h b/src/ast.h
index 0370175..d97d7c7 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -14,18 +14,6 @@ extern "C" {
#define REFMAP_SIZE 16
#define 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 {
cmark_inl_tag tag;
union {
@@ -56,16 +44,6 @@ 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 {
cmark_list_type list_type;
@@ -84,21 +62,6 @@ 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 {
cmark_block_tag tag;
int start_line;
@@ -202,30 +165,9 @@ static inline cmark_node_inl* cmark_make_simple(cmark_inl_tag t)
#ifndef CMARK_NO_SHORT_NAMES
#define node_inl cmark_node_inl
- #define INL_STRING CMARK_INL_STRING
- #define INL_SOFTBREAK CMARK_INL_SOFTBREAK
- #define INL_LINEBREAK CMARK_INL_LINEBREAK
- #define INL_CODE CMARK_INL_CODE
- #define INL_RAW_HTML CMARK_INL_RAW_HTML
- #define INL_EMPH CMARK_INL_EMPH
- #define INL_STRONG CMARK_INL_STRONG
- #define INL_LINK CMARK_INL_LINK
- #define INL_IMAGE CMARK_INL_IMAGE
#define ListData cmark_ListData
#define FencedCodeData cmark_FencedCodeData
#define node_block cmark_node_block
- #define BLOCK_DOCUMENT CMARK_BLOCK_DOCUMENT
- #define BLOCK_BQUOTE CMARK_BLOCK_BQUOTE
- #define BLOCK_LIST CMARK_BLOCK_LIST
- #define BLOCK_LIST_ITEM CMARK_BLOCK_LIST_ITEM
- #define BLOCK_FENCED_CODE CMARK_BLOCK_FENCED_CODE
- #define BLOCK_INDENTED_CODE CMARK_BLOCK_INDENTED_CODE
- #define BLOCK_HTML CMARK_BLOCK_HTML
- #define BLOCK_PARAGRAPH CMARK_BLOCK_PARAGRAPH
- #define BLOCK_ATX_HEADER CMARK_BLOCK_ATX_HEADER
- #define BLOCK_SETEXT_HEADER CMARK_BLOCK_SETEXT_HEADER
- #define BLOCK_HRULE CMARK_BLOCK_HRULE
- #define BLOCK_REFERENCE_DEF CMARK_BLOCK_REFERENCE_DEF
#define make_link cmark_make_link
#define make_autolink cmark_make_autolink
#define make_str cmark_make_str
diff --git a/src/blocks.c b/src/blocks.c
index 22545b5..1b20945 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -350,10 +350,10 @@ static int parse_list_marker(chunk *input, int pos, struct ListData ** dataptr)
return 0;
} else {
data->marker_offset = 0; // will be adjusted later
- data->list_type = bullet;
+ data->list_type = CMARK_BULLET_LIST;
data->bullet_char = c;
data->start = 1;
- data->delimiter = period;
+ data->delimiter = CMARK_PERIOD_DELIM;
data->tight = false;
}
} else if (isdigit(c)) {
@@ -375,10 +375,10 @@ static int parse_list_marker(chunk *input, int pos, struct ListData ** dataptr)
return 0;
} else {
data->marker_offset = 0; // will be adjusted later
- data->list_type = ordered;
+ data->list_type = CMARK_ORDERED_LIST;
data->bullet_char = 0;
data->start = start;
- data->delimiter = (c == '.' ? period : parens);
+ data->delimiter = (c == '.' ? CMARK_PERIOD_DELIM : CMARK_PAREN_DELIM);
data->tight = false;
}
} else {
diff --git a/src/cmark.h b/src/cmark.h
index 4c2e261..0b0196a 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -10,6 +10,43 @@ extern "C" {
#define CMARK_VERSION "0.1"
+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;
+
+typedef enum {
+ CMARK_BULLET_LIST,
+ CMARK_ORDERED_LIST
+} cmark_list_type;
+
+typedef enum {
+ CMARK_PERIOD_DELIM,
+ CMARK_PAREN_DELIM
+} cmark_delim_type;
+
+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;
+
typedef struct cmark_node_inl cmark_node_inl;
typedef struct cmark_node_block cmark_node_block;
typedef struct cmark_doc_parser cmark_doc_parser;
@@ -76,6 +113,10 @@ void cmark_free_inlines(cmark_node_inl* e);
#define BLOCK_SETEXT_HEADER CMARK_BLOCK_SETEXT_HEADER
#define BLOCK_HRULE CMARK_BLOCK_HRULE
#define BLOCK_REFERENCE_DEF CMARK_BLOCK_REFERENCE_DEF
+ #define BULLET_LIST CMARK_BULLET_LIST
+ #define ORDERED_LIST CMARK_ORDERED_LIST
+ #define PERIOD_DELIM CMARK_PERIOD_DELIM
+ #define PAREN_DELIM CMARK_PAREN_DELIM
#define free_simple cmark_free_simple
#define free_blocks cmark_free_blocks
#define doc_parser cmark_doc_parser
diff --git a/src/html/html.c b/src/html/html.c
index a0be6f2..1969490 100644
--- a/src/html/html.c
+++ b/src/html/html.c
@@ -295,14 +295,14 @@ static void blocks_to_html(strbuf *html, node_block *b)
if (data->start > 1) {
strbuf_printf(html, "<%s start=\"%d\">\n",
- data->list_type == bullet ? "ul" : "ol",
+ data->list_type == CMARK_BULLET_LIST ? "ul" : "ol",
data->start);
} else {
- strbuf_puts(html, data->list_type == bullet ? "<ul>\n" : "<ol>\n");
+ strbuf_puts(html, data->list_type == CMARK_BULLET_LIST ? "<ul>\n" : "<ol>\n");
}
rstack = push_block(rstack, b->next,
- data->list_type == bullet ?
+ data->list_type == CMARK_BULLET_LIST ?
"\n</ul>\n" : "\n</ol>\n", tight, false);
tight = data->tight;
visit_children = true;
diff --git a/src/print.c b/src/print.c
index ce387b4..28a173e 100644
--- a/src/print.c
+++ b/src/print.c
@@ -118,11 +118,11 @@ static void print_blocks(node_block* b, int indent)
break;
case BLOCK_LIST:
data = &(b->as.list);
- if (data->list_type == ordered) {
+ if (data->list_type == CMARK_ORDERED_LIST) {
printf("list (type=ordered tight=%s start=%d delim=%s)\n",
(data->tight ? "true" : "false"),
data->start,
- (data->delimiter == parens ? "parens" : "period"));
+ (data->delimiter == CMARK_PAREN_DELIM ? "parens" : "period"));
} else {
printf("list (type=bullet tight=%s bullet_char=%c)\n",
(data->tight ? "true" : "false"),