Commit 1f78c867ff59e2dfe3eea34fa96bfac47eb2b36c

Martin Mitas 2019-08-09T10:29:55

Rename HTML renderer public identifier names. This is to reflect we make it a public API.

diff --git a/src/entity.h b/src/entity.h
index 9e8e54a..36395fe 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -2,7 +2,7 @@
  * MD4C: Markdown parser for C
  * (http://github.com/mity/md4c)
  *
- * Copyright (c) 2016-2017 Martin Mitas
+ * Copyright (c) 2016-2019 Martin Mitas
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -23,8 +23,8 @@
  * IN THE SOFTWARE.
  */
 
-#ifndef MD2HTML_ENTITY_H
-#define MD2HTML_ENTITY_H
+#ifndef MD4C_ENTITY_H
+#define MD4C_ENTITY_H
 
 #include <stdlib.h>
 
@@ -39,4 +39,4 @@ struct entity {
 const struct entity* entity_lookup(const char* name, size_t name_size);
 
 
-#endif  /* MD2HTML_ENTITY_H */
+#endif  /* MD4C_ENTITY_H */
diff --git a/src/md2html.c b/src/md2html.c
index 866a1a7..eb6022c 100644
--- a/src/md2html.c
+++ b/src/md2html.c
@@ -140,8 +140,8 @@ process_file(FILE* in, FILE* out)
      * md_renderer_t structure. */
     t0 = clock();
 
-    ret = md_render_html(buf_in.data, buf_in.size, process_output,
-                (void*) &buf_out, parser_flags, renderer_flags);
+    ret = md_html(buf_in.data, buf_in.size, process_output, (void*) &buf_out,
+                    parser_flags, renderer_flags);
 
     t1 = clock();
     if(ret != 0) {
@@ -306,7 +306,7 @@ cmdline_callback(int opt, char const* value, void* data)
         case 'c':   parser_flags = MD_DIALECT_COMMONMARK; break;
         case 'g':   parser_flags = MD_DIALECT_GITHUB; break;
 
-        case 'E':   renderer_flags |= MD_RENDER_FLAG_VERBATIM_ENTITIES; break;
+        case 'E':   renderer_flags |= MD_HTML_FLAG_VERBATIM_ENTITIES; break;
         case 'A':   parser_flags |= MD_FLAG_PERMISSIVEATXHEADERS; break;
         case 'I':   parser_flags |= MD_FLAG_NOINDENTEDCODEBLOCKS; break;
         case 'F':   parser_flags |= MD_FLAG_NOHTMLBLOCKS; break;
diff --git a/src/md4c-html.c b/src/md4c-html.c
index a54f2ff..7a69b75 100644
--- a/src/md4c-html.c
+++ b/src/md4c-html.c
@@ -47,8 +47,8 @@
 
 
 
-typedef struct MD_RENDER_HTML_tag MD_RENDER_HTML;
-struct MD_RENDER_HTML_tag {
+typedef struct MD_HTML_tag MD_HTML;
+struct MD_HTML_tag {
     void (*process_output)(const MD_CHAR*, MD_SIZE, void*);
     void* userdata;
     unsigned flags;
@@ -71,7 +71,7 @@ struct MD_RENDER_HTML_tag {
 
 
 static inline void
-render_verbatim(MD_RENDER_HTML* r, const MD_CHAR* text, MD_SIZE size)
+render_verbatim(MD_HTML* r, const MD_CHAR* text, MD_SIZE size)
 {
     r->process_output(text, size, r->userdata);
 }
@@ -83,7 +83,7 @@ render_verbatim(MD_RENDER_HTML* r, const MD_CHAR* text, MD_SIZE size)
 
 
 static void
-render_html_escaped(MD_RENDER_HTML* r, const MD_CHAR* data, MD_SIZE size)
+render_html_escaped(MD_HTML* r, const MD_CHAR* data, MD_SIZE size)
 {
     MD_OFFSET beg = 0;
     MD_OFFSET off = 0;
@@ -118,7 +118,7 @@ render_html_escaped(MD_RENDER_HTML* r, const MD_CHAR* data, MD_SIZE size)
 }
 
 static void
-render_url_escaped(MD_RENDER_HTML* r, const MD_CHAR* data, MD_SIZE size)
+render_url_escaped(MD_HTML* r, const MD_CHAR* data, MD_SIZE size)
 {
     static const MD_CHAR hex_chars[] = "0123456789ABCDEF";
     MD_OFFSET beg = 0;
@@ -166,8 +166,8 @@ hex_val(char ch)
 }
 
 static void
-render_utf8_codepoint(MD_RENDER_HTML* r, unsigned codepoint,
-                      void (*fn_append)(MD_RENDER_HTML*, const MD_CHAR*, MD_SIZE))
+render_utf8_codepoint(MD_HTML* r, unsigned codepoint,
+                      void (*fn_append)(MD_HTML*, const MD_CHAR*, MD_SIZE))
 {
     static const MD_CHAR utf8_replacement_char[] = { 0xef, 0xbf, 0xbd };
 
@@ -203,10 +203,10 @@ render_utf8_codepoint(MD_RENDER_HTML* r, unsigned codepoint,
 /* Translate entity to its UTF-8 equivalent, or output the verbatim one
  * if such entity is unknown (or if the translation is disabled). */
 static void
-render_entity(MD_RENDER_HTML* r, const MD_CHAR* text, MD_SIZE size,
-              void (*fn_append)(MD_RENDER_HTML*, const MD_CHAR*, MD_SIZE))
+render_entity(MD_HTML* r, const MD_CHAR* text, MD_SIZE size,
+              void (*fn_append)(MD_HTML*, const MD_CHAR*, MD_SIZE))
 {
-    if(r->flags & MD_RENDER_FLAG_VERBATIM_ENTITIES) {
+    if(r->flags & MD_HTML_FLAG_VERBATIM_ENTITIES) {
         fn_append(r, text, size);
         return;
     }
@@ -246,8 +246,8 @@ render_entity(MD_RENDER_HTML* r, const MD_CHAR* text, MD_SIZE size,
 }
 
 static void
-render_attribute(MD_RENDER_HTML* r, const MD_ATTRIBUTE* attr,
-                 void (*fn_append)(MD_RENDER_HTML*, const MD_CHAR*, MD_SIZE))
+render_attribute(MD_HTML* r, const MD_ATTRIBUTE* attr,
+                 void (*fn_append)(MD_HTML*, const MD_CHAR*, MD_SIZE))
 {
     int i;
 
@@ -267,7 +267,7 @@ render_attribute(MD_RENDER_HTML* r, const MD_ATTRIBUTE* attr,
 
 
 static void
-render_open_ol_block(MD_RENDER_HTML* r, const MD_BLOCK_OL_DETAIL* det)
+render_open_ol_block(MD_HTML* r, const MD_BLOCK_OL_DETAIL* det)
 {
     char buf[64];
 
@@ -281,7 +281,7 @@ render_open_ol_block(MD_RENDER_HTML* r, const MD_BLOCK_OL_DETAIL* det)
 }
 
 static void
-render_open_li_block(MD_RENDER_HTML* r, const MD_BLOCK_LI_DETAIL* det)
+render_open_li_block(MD_HTML* r, const MD_BLOCK_LI_DETAIL* det)
 {
     if(det->is_task) {
         RENDER_VERBATIM(r, "<li class=\"task-list-item\">"
@@ -295,7 +295,7 @@ render_open_li_block(MD_RENDER_HTML* r, const MD_BLOCK_LI_DETAIL* det)
 }
 
 static void
-render_open_code_block(MD_RENDER_HTML* r, const MD_BLOCK_CODE_DETAIL* det)
+render_open_code_block(MD_HTML* r, const MD_BLOCK_CODE_DETAIL* det)
 {
     RENDER_VERBATIM(r, "<pre><code");
 
@@ -310,7 +310,7 @@ render_open_code_block(MD_RENDER_HTML* r, const MD_BLOCK_CODE_DETAIL* det)
 }
 
 static void
-render_open_td_block(MD_RENDER_HTML* r, const MD_CHAR* cell_type, const MD_BLOCK_TD_DETAIL* det)
+render_open_td_block(MD_HTML* r, const MD_CHAR* cell_type, const MD_BLOCK_TD_DETAIL* det)
 {
     RENDER_VERBATIM(r, "<");
     RENDER_VERBATIM(r, cell_type);
@@ -324,7 +324,7 @@ render_open_td_block(MD_RENDER_HTML* r, const MD_CHAR* cell_type, const MD_BLOCK
 }
 
 static void
-render_open_a_span(MD_RENDER_HTML* r, const MD_SPAN_A_DETAIL* det)
+render_open_a_span(MD_HTML* r, const MD_SPAN_A_DETAIL* det)
 {
     RENDER_VERBATIM(r, "<a href=\"");
     render_attribute(r, &det->href, render_url_escaped);
@@ -338,7 +338,7 @@ render_open_a_span(MD_RENDER_HTML* r, const MD_SPAN_A_DETAIL* det)
 }
 
 static void
-render_open_img_span(MD_RENDER_HTML* r, const MD_SPAN_IMG_DETAIL* det)
+render_open_img_span(MD_HTML* r, const MD_SPAN_IMG_DETAIL* det)
 {
     RENDER_VERBATIM(r, "<img src=\"");
     render_attribute(r, &det->src, render_url_escaped);
@@ -349,7 +349,7 @@ render_open_img_span(MD_RENDER_HTML* r, const MD_SPAN_IMG_DETAIL* det)
 }
 
 static void
-render_close_img_span(MD_RENDER_HTML* r, const MD_SPAN_IMG_DETAIL* det)
+render_close_img_span(MD_HTML* r, const MD_SPAN_IMG_DETAIL* det)
 {
     if(det->title.text != NULL) {
         RENDER_VERBATIM(r, "\" title=\"");
@@ -362,7 +362,7 @@ render_close_img_span(MD_RENDER_HTML* r, const MD_SPAN_IMG_DETAIL* det)
 }
 
 static void
-render_open_wikilink_span(MD_RENDER_HTML* r, const MD_SPAN_WIKILINK_DETAIL* det)
+render_open_wikilink_span(MD_HTML* r, const MD_SPAN_WIKILINK_DETAIL* det)
 {
     RENDER_VERBATIM(r, "<x-wikilink data-target=\"");
     render_attribute(r, &det->target, render_html_escaped);
@@ -379,7 +379,7 @@ static int
 enter_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata)
 {
     static const MD_CHAR* head[6] = { "<h1>", "<h2>", "<h3>", "<h4>", "<h5>", "<h6>" };
-    MD_RENDER_HTML* r = (MD_RENDER_HTML*) userdata;
+    MD_HTML* r = (MD_HTML*) userdata;
 
     switch(type) {
         case MD_BLOCK_DOC:      /* noop */ break;
@@ -407,7 +407,7 @@ static int
 leave_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata)
 {
     static const MD_CHAR* head[6] = { "</h1>\n", "</h2>\n", "</h3>\n", "</h4>\n", "</h5>\n", "</h6>\n" };
-    MD_RENDER_HTML* r = (MD_RENDER_HTML*) userdata;
+    MD_HTML* r = (MD_HTML*) userdata;
 
     switch(type) {
         case MD_BLOCK_DOC:      /*noop*/ break;
@@ -434,7 +434,7 @@ leave_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata)
 static int
 enter_span_callback(MD_SPANTYPE type, void* detail, void* userdata)
 {
-    MD_RENDER_HTML* r = (MD_RENDER_HTML*) userdata;
+    MD_HTML* r = (MD_HTML*) userdata;
 
     if(r->image_nesting_level > 0) {
         /* We are inside a Markdown image label. Markdown allows to use any
@@ -474,7 +474,7 @@ enter_span_callback(MD_SPANTYPE type, void* detail, void* userdata)
 static int
 leave_span_callback(MD_SPANTYPE type, void* detail, void* userdata)
 {
-    MD_RENDER_HTML* r = (MD_RENDER_HTML*) userdata;
+    MD_HTML* r = (MD_HTML*) userdata;
 
     if(r->image_nesting_level > 0) {
         /* Ditto as in enter_span_callback(), except we have to allow the
@@ -503,7 +503,7 @@ leave_span_callback(MD_SPANTYPE type, void* detail, void* userdata)
 static int
 text_callback(MD_TEXTTYPE type, const MD_CHAR* text, MD_SIZE size, void* userdata)
 {
-    MD_RENDER_HTML* r = (MD_RENDER_HTML*) userdata;
+    MD_HTML* r = (MD_HTML*) userdata;
 
     switch(type) {
         case MD_TEXT_NULLCHAR:  render_utf8_codepoint(r, 0x0000, render_verbatim); break;
@@ -520,17 +520,17 @@ text_callback(MD_TEXTTYPE type, const MD_CHAR* text, MD_SIZE size, void* userdat
 static void
 debug_log_callback(const char* msg, void* userdata)
 {
-    MD_RENDER_HTML* r = (MD_RENDER_HTML*) userdata;
-    if(r->flags & MD_RENDER_FLAG_DEBUG)
+    MD_HTML* r = (MD_HTML*) userdata;
+    if(r->flags & MD_HTML_FLAG_DEBUG)
         fprintf(stderr, "MD4C: %s\n", msg);
 }
 
 int
-md_render_html(const MD_CHAR* input, MD_SIZE input_size,
-               void (*process_output)(const MD_CHAR*, MD_SIZE, void*),
-               void* userdata, unsigned parser_flags, unsigned renderer_flags)
+md_html(const MD_CHAR* input, MD_SIZE input_size,
+        void (*process_output)(const MD_CHAR*, MD_SIZE, void*),
+        void* userdata, unsigned parser_flags, unsigned renderer_flags)
 {
-    MD_RENDER_HTML render = { process_output, userdata, renderer_flags, 0, { 0 } };
+    MD_HTML render = { process_output, userdata, renderer_flags, 0, { 0 } };
     int i;
 
     MD_PARSER parser = {
diff --git a/src/md4c-html.h b/src/md4c-html.h
index 2e9a77b..d5bf084 100644
--- a/src/md4c-html.h
+++ b/src/md4c-html.h
@@ -23,8 +23,8 @@
  * IN THE SOFTWARE.
  */
 
-#ifndef MD4C_RENDER_HTML_H
-#define MD4C_RENDER_HTML_H
+#ifndef MD4C_HTML_H
+#define MD4C_HTML_H
 
 #include "md4c.h"
 
@@ -46,22 +46,22 @@
  *
  * Params input and input_size specify the Markdown input.
  * Callback process_output() gets called with chunks of HTML output.
- * (Typical implementation may just output the bytes to file or append to
+ * (Typical implementation may just output the bytes to a file or append to
  * some buffer).
  * Param userdata is just propgated back to process_output() callback.
  * Param parser_flags are flags from md4c.h propagated to md_parse().
- * Param render_flags is bitmask of MD_RENDER_FLAG_xxxx.
+ * Param render_flags is bitmask of MD_HTML_FLAG_xxxx.
  *
  * Returns -1 on error (if md_parse() fails.)
  * Returns 0 on success.
  */
-int md_render_html(const MD_CHAR* input, MD_SIZE input_size,
-                   void (*process_output)(const MD_CHAR*, MD_SIZE, void*),
-                   void* userdata, unsigned parser_flags, unsigned renderer_flags);
+int md_html(const MD_CHAR* input, MD_SIZE input_size,
+            void (*process_output)(const MD_CHAR*, MD_SIZE, void*),
+            void* userdata, unsigned parser_flags, unsigned renderer_flags);
 
 
 #ifdef __cplusplus
     }  /* extern "C" { */
 #endif
 
-#endif  /* MD4C_RENDER_HTML_H */
+#endif  /* MD4C_HTML_H */
diff --git a/src/md4c.h b/src/md4c.h
index c2c4311..fa74f6d 100644
--- a/src/md4c.h
+++ b/src/md4c.h
@@ -23,8 +23,8 @@
  * IN THE SOFTWARE.
  */
 
-#ifndef MD4C_MARKDOWN_H
-#define MD4C_MARKDOWN_H
+#ifndef MD4C_H
+#define MD4C_H
 
 #ifdef __cplusplus
     extern "C" {
@@ -385,4 +385,4 @@ int md_parse(const MD_CHAR* text, MD_SIZE size, const MD_PARSER* parser, void* u
     }  /* extern "C" { */
 #endif
 
-#endif  /* MD4C_MARKDOWN_H */
+#endif  /* MD4C_H */