commonmarker 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of commonmarker might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +23 -17
- data/ext/commonmarker/cmark/CMakeLists.txt +1 -1
- data/ext/commonmarker/cmark/Makefile +13 -14
- data/ext/commonmarker/cmark/README.md +1 -0
- data/ext/commonmarker/cmark/api_test/cplusplus.h +1 -2
- data/ext/commonmarker/cmark/api_test/harness.c +60 -79
- data/ext/commonmarker/cmark/api_test/harness.h +13 -20
- data/ext/commonmarker/cmark/api_test/main.c +809 -714
- data/ext/commonmarker/cmark/build/CMakeCache.txt +3 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +0 -67
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +1 -1
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +23 -23
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark_ctype.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/cmake_install.cmake +10 -2
- data/ext/commonmarker/cmark/build/src/cmark_version.h +2 -2
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.pc +1 -1
- data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +1 -0
- data/ext/commonmarker/cmark/changelog.txt +85 -0
- data/ext/commonmarker/cmark/man/man3/cmark.3 +75 -34
- data/ext/commonmarker/cmark/src/CMakeLists.txt +13 -8
- data/ext/commonmarker/cmark/src/blocks.c +78 -70
- data/ext/commonmarker/cmark/src/chunk.h +5 -7
- data/ext/commonmarker/cmark/src/cmark.h +88 -34
- data/ext/commonmarker/cmark/src/cmark_ctype.c +6 -6
- data/ext/commonmarker/cmark/src/commonmark.c +24 -8
- data/ext/commonmarker/cmark/src/houdini_html_u.c +6 -5
- data/ext/commonmarker/cmark/src/html.c +33 -11
- data/ext/commonmarker/cmark/src/inlines.c +9 -10
- data/ext/commonmarker/cmark/src/iterator.c +2 -2
- data/ext/commonmarker/cmark/src/latex.c +54 -28
- data/ext/commonmarker/cmark/src/main.c +0 -9
- data/ext/commonmarker/cmark/src/man.c +17 -5
- data/ext/commonmarker/cmark/src/node.c +123 -44
- data/ext/commonmarker/cmark/src/node.h +8 -2
- data/ext/commonmarker/cmark/src/render.c +8 -1
- data/ext/commonmarker/cmark/src/render.h +1 -0
- data/ext/commonmarker/cmark/src/scanners.c +3755 -4379
- data/ext/commonmarker/cmark/src/scanners.h +7 -6
- data/ext/commonmarker/cmark/src/scanners.re +9 -10
- data/ext/commonmarker/cmark/src/utf8.c +6 -3
- data/ext/commonmarker/cmark/src/utf8.h +4 -2
- data/ext/commonmarker/cmark/src/xml.c +18 -4
- data/ext/commonmarker/cmark/test/CMakeLists.txt +11 -0
- data/ext/commonmarker/cmark/test/normalize.py +5 -1
- data/ext/commonmarker/cmark/test/roundtrip.bat +1 -0
- data/ext/commonmarker/cmark/test/roundtrip.sh +1 -1
- data/ext/commonmarker/cmark/test/spec.txt +257 -157
- data/ext/commonmarker/cmark/why-cmark-and-not-x.md +104 -0
- data/lib/commonmarker/config.rb +6 -6
- data/lib/commonmarker/version.rb +1 -1
- metadata +5 -5
- data/ext/commonmarker/cmark/src/bench.h +0 -27
- data/ext/commonmarker/cmark/wrappers/wrapper.lua +0 -239
@@ -39,20 +39,22 @@ typedef enum {
|
|
39
39
|
CMARK_NODE_LIST,
|
40
40
|
CMARK_NODE_ITEM,
|
41
41
|
CMARK_NODE_CODE_BLOCK,
|
42
|
-
|
42
|
+
CMARK_NODE_HTML_BLOCK,
|
43
|
+
CMARK_NODE_CUSTOM_BLOCK,
|
43
44
|
CMARK_NODE_PARAGRAPH,
|
44
|
-
|
45
|
-
|
45
|
+
CMARK_NODE_HEADING,
|
46
|
+
CMARK_NODE_THEMATIC_BREAK,
|
46
47
|
|
47
48
|
CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
|
48
|
-
CMARK_NODE_LAST_BLOCK =
|
49
|
+
CMARK_NODE_LAST_BLOCK = CMARK_NODE_THEMATIC_BREAK,
|
49
50
|
|
50
51
|
/* Inline */
|
51
52
|
CMARK_NODE_TEXT,
|
52
53
|
CMARK_NODE_SOFTBREAK,
|
53
54
|
CMARK_NODE_LINEBREAK,
|
54
55
|
CMARK_NODE_CODE,
|
55
|
-
|
56
|
+
CMARK_NODE_HTML_INLINE,
|
57
|
+
CMARK_NODE_CUSTOM_INLINE,
|
56
58
|
CMARK_NODE_EMPH,
|
57
59
|
CMARK_NODE_STRONG,
|
58
60
|
CMARK_NODE_LINK,
|
@@ -62,6 +64,12 @@ typedef enum {
|
|
62
64
|
CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
|
63
65
|
} cmark_node_type;
|
64
66
|
|
67
|
+
/* For backwards compatibility: */
|
68
|
+
#define CMARK_NODE_HEADER CMARK_NODE_HEADING
|
69
|
+
#define CMARK_NODE_HRULE CMARK_NODE_THEMATIC_BREAK
|
70
|
+
#define CMARK_NODE_HTML CMARK_NODE_HTML_BLOCK
|
71
|
+
#define CMARK_NODE_INLINE_HTML CMARK_NODE_HTML_INLINE
|
72
|
+
|
65
73
|
typedef enum {
|
66
74
|
CMARK_NO_LIST,
|
67
75
|
CMARK_BULLET_LIST,
|
@@ -139,7 +147,7 @@ CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
|
|
139
147
|
* One natural application is an HTML renderer, where an `ENTER` event
|
140
148
|
* outputs an open tag and an `EXIT` event outputs a close tag.
|
141
149
|
* An iterator might also be used to transform an AST in some systematic
|
142
|
-
* way, for example, turning all level-3
|
150
|
+
* way, for example, turning all level-3 headings into regular paragraphs.
|
143
151
|
*
|
144
152
|
* void
|
145
153
|
* usage_example(cmark_node *root) {
|
@@ -157,14 +165,14 @@ CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
|
|
157
165
|
* Iterators will never return `EXIT` events for leaf nodes, which are nodes
|
158
166
|
* of type:
|
159
167
|
*
|
160
|
-
* *
|
161
|
-
* *
|
168
|
+
* * CMARK_NODE_HTML_BLOCK
|
169
|
+
* * CMARK_NODE_THEMATIC_BREAK
|
162
170
|
* * CMARK_NODE_CODE_BLOCK
|
163
171
|
* * CMARK_NODE_TEXT
|
164
172
|
* * CMARK_NODE_SOFTBREAK
|
165
173
|
* * CMARK_NODE_LINEBREAK
|
166
174
|
* * CMARK_NODE_CODE
|
167
|
-
* *
|
175
|
+
* * CMARK_NODE_HTML_INLINE
|
168
176
|
*
|
169
177
|
* Nodes must only be modified after an `EXIT` event, or an `ENTER` event for
|
170
178
|
* leaf nodes.
|
@@ -233,7 +241,8 @@ CMARK_EXPORT cmark_node_type cmark_node_get_type(cmark_node *node);
|
|
233
241
|
CMARK_EXPORT
|
234
242
|
const char *cmark_node_get_type_string(cmark_node *node);
|
235
243
|
|
236
|
-
/** Returns the string contents of 'node', or
|
244
|
+
/** Returns the string contents of 'node', or an empty
|
245
|
+
string if none is set.
|
237
246
|
*/
|
238
247
|
CMARK_EXPORT const char *cmark_node_get_literal(cmark_node *node);
|
239
248
|
|
@@ -242,13 +251,17 @@ CMARK_EXPORT const char *cmark_node_get_literal(cmark_node *node);
|
|
242
251
|
*/
|
243
252
|
CMARK_EXPORT int cmark_node_set_literal(cmark_node *node, const char *content);
|
244
253
|
|
245
|
-
/** Returns the
|
254
|
+
/** Returns the heading level of 'node', or 0 if 'node' is not a heading.
|
246
255
|
*/
|
247
|
-
CMARK_EXPORT int
|
256
|
+
CMARK_EXPORT int cmark_node_get_heading_level(cmark_node *node);
|
257
|
+
|
258
|
+
/* For backwards compatibility */
|
259
|
+
#define cmark_node_get_header_level cmark_node_get_heading_level
|
260
|
+
#define cmark_node_set_header_level cmark_node_set_heading_level
|
248
261
|
|
249
|
-
/** Sets the
|
262
|
+
/** Sets the heading level of 'node', returning 1 on success and 0 on error.
|
250
263
|
*/
|
251
|
-
CMARK_EXPORT int
|
264
|
+
CMARK_EXPORT int cmark_node_set_heading_level(cmark_node *node, int level);
|
252
265
|
|
253
266
|
/** Returns the list type of 'node', or `CMARK_NO_LIST` if 'node'
|
254
267
|
* is not a list.
|
@@ -288,7 +301,7 @@ CMARK_EXPORT int cmark_node_get_list_tight(cmark_node *node);
|
|
288
301
|
*/
|
289
302
|
CMARK_EXPORT int cmark_node_set_list_tight(cmark_node *node, int tight);
|
290
303
|
|
291
|
-
/** Returns the info string from a fenced code block
|
304
|
+
/** Returns the info string from a fenced code block.
|
292
305
|
*/
|
293
306
|
CMARK_EXPORT const char *cmark_node_get_fence_info(cmark_node *node);
|
294
307
|
|
@@ -297,7 +310,8 @@ CMARK_EXPORT const char *cmark_node_get_fence_info(cmark_node *node);
|
|
297
310
|
*/
|
298
311
|
CMARK_EXPORT int cmark_node_set_fence_info(cmark_node *node, const char *info);
|
299
312
|
|
300
|
-
/**
|
313
|
+
/** Returns the URL of a link or image 'node', or an empty string
|
314
|
+
if no URL is set.
|
301
315
|
*/
|
302
316
|
CMARK_EXPORT const char *cmark_node_get_url(cmark_node *node);
|
303
317
|
|
@@ -306,7 +320,8 @@ CMARK_EXPORT const char *cmark_node_get_url(cmark_node *node);
|
|
306
320
|
*/
|
307
321
|
CMARK_EXPORT int cmark_node_set_url(cmark_node *node, const char *url);
|
308
322
|
|
309
|
-
/**
|
323
|
+
/** Returns the title of a link or image 'node', or an empty
|
324
|
+
string if no title is set.
|
310
325
|
*/
|
311
326
|
CMARK_EXPORT const char *cmark_node_get_title(cmark_node *node);
|
312
327
|
|
@@ -315,6 +330,29 @@ CMARK_EXPORT const char *cmark_node_get_title(cmark_node *node);
|
|
315
330
|
*/
|
316
331
|
CMARK_EXPORT int cmark_node_set_title(cmark_node *node, const char *title);
|
317
332
|
|
333
|
+
/** Returns the literal "on enter" text for a custom 'node', or
|
334
|
+
an empty string if no on_enter is set.
|
335
|
+
*/
|
336
|
+
CMARK_EXPORT const char *cmark_node_get_on_enter(cmark_node *node);
|
337
|
+
|
338
|
+
/** Sets the literal text to render "on enter" for a custom 'node'.
|
339
|
+
Any children of the node will be rendered after this text.
|
340
|
+
Returns 1 on success 0 on failure.
|
341
|
+
*/
|
342
|
+
CMARK_EXPORT int cmark_node_set_on_enter(cmark_node *node,
|
343
|
+
const char *on_enter);
|
344
|
+
|
345
|
+
/** Returns the literal "on exit" text for a custom 'node', or
|
346
|
+
an empty string if no on_exit is set.
|
347
|
+
*/
|
348
|
+
CMARK_EXPORT const char *cmark_node_get_on_exit(cmark_node *node);
|
349
|
+
|
350
|
+
/** Sets the literal text to render "on exit" for a custom 'node'.
|
351
|
+
Any children of the node will be rendered before this text.
|
352
|
+
Returns 1 on success 0 on failure.
|
353
|
+
*/
|
354
|
+
CMARK_EXPORT int cmark_node_set_on_exit(cmark_node *node, const char *on_exit);
|
355
|
+
|
318
356
|
/** Returns the line on which 'node' begins.
|
319
357
|
*/
|
320
358
|
CMARK_EXPORT int cmark_node_get_start_line(cmark_node *node);
|
@@ -368,7 +406,7 @@ CMARK_EXPORT void cmark_consolidate_text_nodes(cmark_node *root);
|
|
368
406
|
*
|
369
407
|
* Simple interface:
|
370
408
|
*
|
371
|
-
* cmark_node *document = cmark_parse_document("Hello *world*",
|
409
|
+
* cmark_node *document = cmark_parse_document("Hello *world*", 13,
|
372
410
|
* CMARK_OPT_DEFAULT);
|
373
411
|
*
|
374
412
|
* Streaming interface:
|
@@ -447,38 +485,50 @@ char *cmark_render_commonmark(cmark_node *root, int options, int width);
|
|
447
485
|
CMARK_EXPORT
|
448
486
|
char *cmark_render_latex(cmark_node *root, int options, int width);
|
449
487
|
|
450
|
-
/**
|
488
|
+
/**
|
489
|
+
* ## Options
|
490
|
+
*/
|
491
|
+
|
492
|
+
/** Default options.
|
451
493
|
*/
|
452
494
|
#define CMARK_OPT_DEFAULT 0
|
453
495
|
|
496
|
+
/**
|
497
|
+
* ### Options affecting rendering
|
498
|
+
*/
|
499
|
+
|
454
500
|
/** Include a `data-sourcepos` attribute on all block elements.
|
455
501
|
*/
|
456
|
-
#define CMARK_OPT_SOURCEPOS 1
|
502
|
+
#define CMARK_OPT_SOURCEPOS (1 << 1)
|
457
503
|
|
458
504
|
/** Render `softbreak` elements as hard line breaks.
|
459
505
|
*/
|
460
|
-
#define CMARK_OPT_HARDBREAKS 2
|
506
|
+
#define CMARK_OPT_HARDBREAKS (1 << 2)
|
461
507
|
|
462
|
-
/**
|
508
|
+
/** Suppress raw HTML and unsafe links (`javascript:`, `vbscript:`,
|
509
|
+
* `file:`, and `data:`, except for `image/png`, `image/gif`,
|
510
|
+
* `image/jpeg`, or `image/webp` mime types). Raw HTML is replaced
|
511
|
+
* by a placeholder HTML comment. Unsafe links are replaced by
|
512
|
+
* empty strings.
|
463
513
|
*/
|
464
|
-
#define
|
514
|
+
#define CMARK_OPT_SAFE (1 << 3)
|
465
515
|
|
466
|
-
/**
|
516
|
+
/**
|
517
|
+
* ### Options affecting parsing
|
518
|
+
*/
|
519
|
+
|
520
|
+
/** Normalize tree by consolidating adjacent text nodes.
|
467
521
|
*/
|
468
|
-
#define
|
522
|
+
#define CMARK_OPT_NORMALIZE (1 << 8)
|
469
523
|
|
470
524
|
/** Validate UTF-8 in the input before parsing, replacing illegal
|
471
525
|
* sequences with the replacement character U+FFFD.
|
472
526
|
*/
|
473
|
-
#define CMARK_OPT_VALIDATE_UTF8
|
527
|
+
#define CMARK_OPT_VALIDATE_UTF8 (1 << 9)
|
474
528
|
|
475
|
-
/**
|
476
|
-
* `file:`, and `data:`, except for `image/png`, `image/gif`,
|
477
|
-
* `image/jpeg`, or `image/webp` mime types). Raw HTML is replaced
|
478
|
-
* by a placeholder HTML comment. Unsafe links are replaced by
|
479
|
-
* empty strings.
|
529
|
+
/** Convert straight quotes to curly, --- to em dashes, -- to en dashes.
|
480
530
|
*/
|
481
|
-
#define
|
531
|
+
#define CMARK_OPT_SMART (1 << 10)
|
482
532
|
|
483
533
|
/**
|
484
534
|
* ## Version information
|
@@ -513,15 +563,19 @@ const char *cmark_version_string();
|
|
513
563
|
#define NODE_LIST CMARK_NODE_LIST
|
514
564
|
#define NODE_ITEM CMARK_NODE_ITEM
|
515
565
|
#define NODE_CODE_BLOCK CMARK_NODE_CODE_BLOCK
|
516
|
-
#define
|
566
|
+
#define NODE_HTML_BLOCK CMARK_NODE_HTML_BLOCK
|
567
|
+
#define NODE_CUSTOM_BLOCK CMARK_NODE_CUSTOM_BLOCK
|
517
568
|
#define NODE_PARAGRAPH CMARK_NODE_PARAGRAPH
|
569
|
+
#define NODE_HEADING CMARK_NODE_HEADING
|
518
570
|
#define NODE_HEADER CMARK_NODE_HEADER
|
571
|
+
#define NODE_THEMATIC_BREAK CMARK_NODE_THEMATIC_BREAK
|
519
572
|
#define NODE_HRULE CMARK_NODE_HRULE
|
520
573
|
#define NODE_TEXT CMARK_NODE_TEXT
|
521
574
|
#define NODE_SOFTBREAK CMARK_NODE_SOFTBREAK
|
522
575
|
#define NODE_LINEBREAK CMARK_NODE_LINEBREAK
|
523
576
|
#define NODE_CODE CMARK_NODE_CODE
|
524
|
-
#define
|
577
|
+
#define NODE_HTML_INLINE CMARK_NODE_HTML_INLINE
|
578
|
+
#define NODE_CUSTOM_INLINE CMARK_NODE_CUSTOM_INLINE
|
525
579
|
#define NODE_EMPH CMARK_NODE_EMPH
|
526
580
|
#define NODE_STRONG CMARK_NODE_STRONG
|
527
581
|
#define NODE_LINK CMARK_NODE_LINK
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
/** 1 = space, 2 = punct, 3 = digit, 4 = alpha, 0 = other
|
6
6
|
*/
|
7
|
-
static const
|
7
|
+
static const uint8_t cmark_ctype_class[256] = {
|
8
8
|
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
|
9
9
|
/* 0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,
|
10
10
|
/* 1 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
@@ -26,17 +26,17 @@ static const int8_t cmark_ctype_class[256] = {
|
|
26
26
|
/**
|
27
27
|
* Returns 1 if c is a "whitespace" character as defined by the spec.
|
28
28
|
*/
|
29
|
-
int cmark_isspace(char c) { return cmark_ctype_class[(
|
29
|
+
int cmark_isspace(char c) { return cmark_ctype_class[(uint8_t)c] == 1; }
|
30
30
|
|
31
31
|
/**
|
32
32
|
* Returns 1 if c is an ascii punctuation character.
|
33
33
|
*/
|
34
|
-
int cmark_ispunct(char c) { return cmark_ctype_class[(
|
34
|
+
int cmark_ispunct(char c) { return cmark_ctype_class[(uint8_t)c] == 2; }
|
35
35
|
|
36
36
|
int cmark_isalnum(char c) {
|
37
|
-
|
38
|
-
result = cmark_ctype_class[(
|
37
|
+
uint8_t result;
|
38
|
+
result = cmark_ctype_class[(uint8_t)c];
|
39
39
|
return (result == 3 || result == 4);
|
40
40
|
}
|
41
41
|
|
42
|
-
int cmark_isdigit(char c) { return cmark_ctype_class[(
|
42
|
+
int cmark_isdigit(char c) { return cmark_ctype_class[(uint8_t)c] == 3; }
|
@@ -31,7 +31,7 @@ static inline void outc(cmark_renderer *renderer, cmark_escaping escape,
|
|
31
31
|
(c == '*' || c == '_' || c == '[' || c == ']' || c == '#' || c == '<' ||
|
32
32
|
c == '>' || c == '\\' || c == '`' || c == '!' ||
|
33
33
|
(c == '&' && isalpha(nextc)) || (c == '!' && nextc == '[') ||
|
34
|
-
(renderer->
|
34
|
+
(renderer->begin_content && (c == '-' || c == '+' || c == '=')) ||
|
35
35
|
((c == '.' || c == ')') &&
|
36
36
|
isdigit(renderer->buffer->ptr[renderer->buffer->size - 1])))) ||
|
37
37
|
(escape == URL && (c == '`' || c == '<' || c == '>' || isspace(c) ||
|
@@ -176,6 +176,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
176
176
|
case CMARK_NODE_BLOCK_QUOTE:
|
177
177
|
if (entering) {
|
178
178
|
LIT("> ");
|
179
|
+
renderer->begin_content = true;
|
179
180
|
cmark_strbuf_puts(renderer->prefix, "> ");
|
180
181
|
} else {
|
181
182
|
cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 2);
|
@@ -214,9 +215,11 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
214
215
|
if (entering) {
|
215
216
|
if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
|
216
217
|
LIT("* ");
|
218
|
+
renderer->begin_content = true;
|
217
219
|
cmark_strbuf_puts(renderer->prefix, " ");
|
218
220
|
} else {
|
219
221
|
LIT(listmarker);
|
222
|
+
renderer->begin_content = true;
|
220
223
|
for (i = marker_width; i--;) {
|
221
224
|
cmark_strbuf_putc(renderer->prefix, ' ');
|
222
225
|
}
|
@@ -228,12 +231,13 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
228
231
|
}
|
229
232
|
break;
|
230
233
|
|
231
|
-
case
|
234
|
+
case CMARK_NODE_HEADING:
|
232
235
|
if (entering) {
|
233
|
-
for (
|
236
|
+
for (i = cmark_node_get_heading_level(node); i > 0; i--) {
|
234
237
|
LIT("#");
|
235
238
|
}
|
236
239
|
LIT(" ");
|
240
|
+
renderer->begin_content = true;
|
237
241
|
renderer->no_wrap = true;
|
238
242
|
} else {
|
239
243
|
renderer->no_wrap = false;
|
@@ -279,13 +283,20 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
279
283
|
BLANKLINE();
|
280
284
|
break;
|
281
285
|
|
282
|
-
case
|
286
|
+
case CMARK_NODE_HTML_BLOCK:
|
283
287
|
BLANKLINE();
|
284
288
|
OUT(cmark_node_get_literal(node), false, LITERAL);
|
285
289
|
BLANKLINE();
|
286
290
|
break;
|
287
291
|
|
288
|
-
case
|
292
|
+
case CMARK_NODE_CUSTOM_BLOCK:
|
293
|
+
BLANKLINE();
|
294
|
+
OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
|
295
|
+
false, LITERAL);
|
296
|
+
BLANKLINE();
|
297
|
+
break;
|
298
|
+
|
299
|
+
case CMARK_NODE_THEMATIC_BREAK:
|
289
300
|
BLANKLINE();
|
290
301
|
LIT("-----");
|
291
302
|
BLANKLINE();
|
@@ -335,10 +346,15 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
335
346
|
}
|
336
347
|
break;
|
337
348
|
|
338
|
-
case
|
349
|
+
case CMARK_NODE_HTML_INLINE:
|
339
350
|
OUT(cmark_node_get_literal(node), false, LITERAL);
|
340
351
|
break;
|
341
352
|
|
353
|
+
case CMARK_NODE_CUSTOM_INLINE:
|
354
|
+
OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
|
355
|
+
false, LITERAL);
|
356
|
+
break;
|
357
|
+
|
342
358
|
case CMARK_NODE_STRONG:
|
343
359
|
if (entering) {
|
344
360
|
LIT("**");
|
@@ -368,9 +384,9 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
368
384
|
if (entering) {
|
369
385
|
LIT("<");
|
370
386
|
if (strncmp(cmark_node_get_url(node), "mailto:", 7) == 0) {
|
371
|
-
LIT((char *)cmark_node_get_url(node) + 7);
|
387
|
+
LIT((const char *)cmark_node_get_url(node) + 7);
|
372
388
|
} else {
|
373
|
-
LIT((char *)cmark_node_get_url(node));
|
389
|
+
LIT((const char *)cmark_node_get_url(node));
|
374
390
|
}
|
375
391
|
LIT(">");
|
376
392
|
// return signal to skip contents of node...
|
@@ -9,12 +9,13 @@
|
|
9
9
|
|
10
10
|
/* Binary tree lookup code for entities added by JGM */
|
11
11
|
|
12
|
-
static unsigned char *S_lookup(int i, int low, int hi,
|
13
|
-
|
12
|
+
static const unsigned char *S_lookup(int i, int low, int hi,
|
13
|
+
const unsigned char *s, int len) {
|
14
14
|
int j;
|
15
|
-
int cmp =
|
15
|
+
int cmp =
|
16
|
+
strncmp((const char *)s, (const char *)cmark_entities[i].entity, len);
|
16
17
|
if (cmp == 0 && cmark_entities[i].entity[len] == 0) {
|
17
|
-
return (unsigned char *)cmark_entities[i].bytes;
|
18
|
+
return (const unsigned char *)cmark_entities[i].bytes;
|
18
19
|
} else if (cmp < 0 && i > low) {
|
19
20
|
j = i - ((i - low) / 2);
|
20
21
|
if (j == i)
|
@@ -30,7 +31,7 @@ static unsigned char *S_lookup(int i, int low, int hi, const unsigned char *s,
|
|
30
31
|
}
|
31
32
|
}
|
32
33
|
|
33
|
-
static unsigned char *S_lookup_entity(const unsigned char *s, int len) {
|
34
|
+
static const unsigned char *S_lookup_entity(const unsigned char *s, int len) {
|
34
35
|
return S_lookup(CMARK_NUM_ENTITIES / 2, 0, CMARK_NUM_ENTITIES - 1, s, len);
|
35
36
|
}
|
36
37
|
|
@@ -43,8 +43,8 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
|
43
43
|
cmark_node *parent;
|
44
44
|
cmark_node *grandparent;
|
45
45
|
cmark_strbuf *html = state->html;
|
46
|
-
char
|
47
|
-
char
|
46
|
+
char start_heading[] = "<h0";
|
47
|
+
char end_heading[] = "</h0";
|
48
48
|
bool tight;
|
49
49
|
char buffer[100];
|
50
50
|
|
@@ -58,7 +58,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
|
58
58
|
switch (node->type) {
|
59
59
|
case CMARK_NODE_TEXT:
|
60
60
|
case CMARK_NODE_CODE:
|
61
|
-
case
|
61
|
+
case CMARK_NODE_HTML_INLINE:
|
62
62
|
escape_html(html, node->as.literal.data, node->as.literal.len);
|
63
63
|
break;
|
64
64
|
|
@@ -127,16 +127,16 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
|
127
127
|
}
|
128
128
|
break;
|
129
129
|
|
130
|
-
case
|
130
|
+
case CMARK_NODE_HEADING:
|
131
131
|
if (entering) {
|
132
132
|
cr(html);
|
133
|
-
|
134
|
-
cmark_strbuf_puts(html,
|
133
|
+
start_heading[2] = (char)('0' + node->as.heading.level);
|
134
|
+
cmark_strbuf_puts(html, start_heading);
|
135
135
|
S_render_sourcepos(node, html, options);
|
136
136
|
cmark_strbuf_putc(html, '>');
|
137
137
|
} else {
|
138
|
-
|
139
|
-
cmark_strbuf_puts(html,
|
138
|
+
end_heading[3] = (char)('0' + node->as.heading.level);
|
139
|
+
cmark_strbuf_puts(html, end_heading);
|
140
140
|
cmark_strbuf_puts(html, ">\n");
|
141
141
|
}
|
142
142
|
break;
|
@@ -166,7 +166,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
|
166
166
|
cmark_strbuf_puts(html, "</code></pre>\n");
|
167
167
|
break;
|
168
168
|
|
169
|
-
case
|
169
|
+
case CMARK_NODE_HTML_BLOCK:
|
170
170
|
cr(html);
|
171
171
|
if (options & CMARK_OPT_SAFE) {
|
172
172
|
cmark_strbuf_puts(html, "<!-- raw HTML omitted -->");
|
@@ -176,7 +176,19 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
|
176
176
|
cr(html);
|
177
177
|
break;
|
178
178
|
|
179
|
-
case
|
179
|
+
case CMARK_NODE_CUSTOM_BLOCK:
|
180
|
+
cr(html);
|
181
|
+
if (entering) {
|
182
|
+
cmark_strbuf_put(html, node->as.custom.on_enter.data,
|
183
|
+
node->as.custom.on_enter.len);
|
184
|
+
} else {
|
185
|
+
cmark_strbuf_put(html, node->as.custom.on_exit.data,
|
186
|
+
node->as.custom.on_exit.len);
|
187
|
+
}
|
188
|
+
cr(html);
|
189
|
+
break;
|
190
|
+
|
191
|
+
case CMARK_NODE_THEMATIC_BREAK:
|
180
192
|
cr(html);
|
181
193
|
cmark_strbuf_puts(html, "<hr");
|
182
194
|
S_render_sourcepos(node, html, options);
|
@@ -225,7 +237,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
|
225
237
|
cmark_strbuf_puts(html, "</code>");
|
226
238
|
break;
|
227
239
|
|
228
|
-
case
|
240
|
+
case CMARK_NODE_HTML_INLINE:
|
229
241
|
if (options & CMARK_OPT_SAFE) {
|
230
242
|
cmark_strbuf_puts(html, "<!-- raw HTML omitted -->");
|
231
243
|
} else {
|
@@ -233,6 +245,16 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
|
233
245
|
}
|
234
246
|
break;
|
235
247
|
|
248
|
+
case CMARK_NODE_CUSTOM_INLINE:
|
249
|
+
if (entering) {
|
250
|
+
cmark_strbuf_put(html, node->as.custom.on_enter.data,
|
251
|
+
node->as.custom.on_enter.len);
|
252
|
+
} else {
|
253
|
+
cmark_strbuf_put(html, node->as.custom.on_exit.data,
|
254
|
+
node->as.custom.on_exit.len);
|
255
|
+
}
|
256
|
+
break;
|
257
|
+
|
236
258
|
case CMARK_NODE_STRONG:
|
237
259
|
if (entering) {
|
238
260
|
cmark_strbuf_puts(html, "<strong>");
|