cmark

My personal build of CMark ✏️

Commit
499970acbdaef4dcd51a2e629edfddee520bba3a
Parent
463d64219b2f47c9bfb50d05a7f4d2b2a4293a97
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Remove old node_block and node_inl

Diffstat

3 files changed, 0 insertions, 187 deletions

Status File Name N° Changes Insertions Deletions
Modified src/ast.h 61 0 61
Modified src/cmark.c 54 0 54
Modified src/cmark.h 72 0 72
diff --git a/src/ast.h b/src/ast.h
@@ -15,20 +15,6 @@ extern "C" {
 #define REFMAP_SIZE 16
 #define MAX_LINK_LABEL_LENGTH 1000
 
-struct cmark_node_inl {
-	cmark_inl_tag tag;
-	union {
-		cmark_chunk literal;
-		struct cmark_node_inl *inlines;
-		struct {
-			struct cmark_node_inl *label;
-			unsigned char *url;
-			unsigned char *title;
-		} linkable;
-	} content;
-	struct cmark_node_inl *next;
-};
-
 struct cmark_reference {
 	struct cmark_reference *next;
 	unsigned char *label;
@@ -45,49 +31,6 @@ struct cmark_reference_map {
 
 typedef struct cmark_reference_map cmark_reference_map;
 
-// Types for blocks
-struct cmark_ListData {
-	cmark_list_type   list_type;
-	int               marker_offset;
-	int               padding;
-	int               start;
-	cmark_delim_type  delimiter;
-	unsigned char     bullet_char;
-	bool              tight;
-};
-
-struct cmark_FencedCodeData {
-	int               fence_length;
-	int               fence_offset;
-	unsigned char     fence_char;
-	cmark_strbuf      info;
-};
-
-struct cmark_node_block {
-	cmark_block_tag tag;
-	int start_line;
-	int start_column;
-	int end_line;
-	bool open;
-	bool last_line_blank;
-	struct cmark_node_block* children;
-	struct cmark_node_block* last_child;
-	struct cmark_node_block* parent;
-	cmark_strbuf string_content;
-	struct cmark_node_inl* inline_content;
-
-	union  {
-		struct cmark_ListData list;
-		struct cmark_FencedCodeData code;
-		struct {
-			int level;
-		} header;
-	} as;
-
-	struct cmark_node_block *next;
-	struct cmark_node_block *prev;
-};
-
 struct cmark_doc_parser {
 	struct cmark_reference_map *refmap;
 	struct cmark_node* root;
@@ -162,10 +105,6 @@ static inline cmark_node* cmark_make_simple(cmark_node_type t)
 
 
 #ifndef CMARK_NO_SHORT_NAMES
-  #define node_inl                  cmark_node_inl
-  #define ListData                  cmark_ListData
-  #define FencedCodeData            cmark_FencedCodeData
-  #define node_block                cmark_node_block
   #define make_link                 cmark_make_link
   #define make_autolink             cmark_make_autolink
   #define make_str                  cmark_make_str
diff --git a/src/cmark.c b/src/cmark.c
@@ -8,60 +8,6 @@
 #include "buffer.h"
 #include "ast.h"
 
-// AST traversal and manipulation functions
-
-cmark_node_block *cmark_block_next(cmark_node_block *current)
-{
-	return current->next;
-}
-
-cmark_node_block *cmark_block_previous(cmark_node_block *current)
-{
-	return current->prev;
-}
-
-cmark_node_block *cmark_block_parent(cmark_node_block *current)
-{
-	return current->parent;
-}
-
-cmark_node_block *cmark_block_children(cmark_node_block *current)
-{
-	return current->children;
-}
-
-void cmark_block_insert_before(cmark_node_block *new, cmark_node_block *current)
-{
-	// Find last node in new:
-	cmark_node_block *new_last = new;
-	while (new_last->next) {
-		new_last = new_last->next;
-	}
-	new_last->next = current;
-	current->prev = new_last;
-	if (current->prev) {
-		current->prev->next = new;
-		new->prev = current->prev;
-	}
-}
-
-void cmark_block_insert_after(cmark_node_block *current, cmark_node_block *new)
-{
-	// Find last node in new:
-	cmark_node_block *new_last = new;
-	while (new_last->next) {
-		new_last = new_last->next;
-	}
-	if (current->next) {
-		new_last->next = current->next;
-		current->next->prev = new_last;
-	}
-	current->next = new;
-	new->prev = current;
-}
-
-/* * */
-
 unsigned char *cmark_markdown_to_html(unsigned char *text, int len)
 {
 	cmark_node *blocks;
diff --git a/src/cmark.h b/src/cmark.h
@@ -11,18 +11,6 @@ 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;
@@ -32,24 +20,7 @@ typedef enum {
 	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 cmark_node;
-typedef struct cmark_node_inl cmark_node_inl;
-typedef struct cmark_node_block cmark_node_block;
 typedef struct cmark_doc_parser cmark_doc_parser;
 
 CMARK_EXPORT
@@ -82,50 +53,7 @@ unsigned char *cmark_markdown_to_html(unsigned char *text, int len);
 CMARK_EXPORT
 void cmark_free_nodes(cmark_node *e);
 
-CMARK_EXPORT
-cmark_node_block *cmark_block_next(cmark_node_block *current);
-
-CMARK_EXPORT
-cmark_node_block *cmark_block_previous(cmark_node_block *current);
-
-CMARK_EXPORT
-cmark_node_block *cmark_block_parent(cmark_node_block *current);
-
-CMARK_EXPORT
-cmark_node_block *cmark_block_children(cmark_node_block *current);
-
-CMARK_EXPORT
-void cmark_block_insert_before(cmark_node_block *new, cmark_node_block *current);
-
-CMARK_EXPORT
-void cmark_block_insert_after(cmark_node_block *current, cmark_node_block *new);
-
 #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 BULLET_LIST               CMARK_BULLET_LIST
   #define ORDERED_LIST              CMARK_ORDERED_LIST
   #define PERIOD_DELIM              CMARK_PERIOD_DELIM