Rename HTML renderer public identifier names. This is to reflect we make it a public API.
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
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 */