commonmarker 0.14.3 → 0.14.4
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/commonmarker.gemspec +1 -1
- data/ext/commonmarker/cmark/Makefile +2 -2
- data/ext/commonmarker/cmark/extensions/CMakeLists.txt +38 -12
- data/ext/commonmarker/cmark/extensions/autolink.c +151 -102
- data/ext/commonmarker/cmark/extensions/core-extensions.h +2 -0
- data/ext/commonmarker/cmark/extensions/strikethrough.c +15 -10
- data/ext/commonmarker/cmark/extensions/table.c +31 -26
- data/ext/commonmarker/cmark/src/CMakeLists.txt +4 -1
- data/ext/commonmarker/cmark/src/blocks.c +11 -7
- data/ext/commonmarker/cmark/src/cmark_extension_api.h +14 -0
- data/ext/commonmarker/cmark/src/commonmark.c +7 -5
- data/ext/commonmarker/cmark/src/inlines.c +1 -6
- data/ext/commonmarker/cmark/src/latex.c +4 -3
- data/ext/commonmarker/cmark/src/man.c +4 -3
- data/ext/commonmarker/cmark/src/render.c +5 -3
- data/ext/commonmarker/cmark/src/render.h +4 -3
- data/ext/commonmarker/cmark/src/syntax_extension.c +5 -0
- data/ext/commonmarker/cmark/src/syntax_extension.h +1 -0
- data/ext/commonmarker/cmark/test/CMakeLists.txt +3 -2
- data/ext/commonmarker/cmark/test/cmark.py +69 -23
- data/ext/commonmarker/cmark/test/extensions.txt +6 -6
- data/ext/commonmarker/cmark/test/roundtrip_tests.py +6 -4
- data/ext/commonmarker/cmark/test/spec.txt +420 -4
- data/ext/commonmarker/cmark/test/spec_tests.py +12 -6
- data/ext/commonmarker/extconf.rb +1 -1
- data/lib/commonmarker/renderer/html_renderer.rb +4 -0
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_helper.rb +5 -2
- data/test/test_spec.rb +9 -7
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e197672d34d9b8ce80830230f748a1a82dc41de
|
4
|
+
data.tar.gz: e43f9b677a242a8c928f0d446df6be992ce9aede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf9e8dfac4bebdc8d4d15af724a93d15070730721bbba2637db42d0e12fbf0a5455cdb69c3e21043476ebe58ba7e615326af1e310c447626cc5d20bf3668684
|
7
|
+
data.tar.gz: cdad436d0936f904787febab5367a7633d101e2108856d2507b707a5bc475adecdb482bb7e728d4795715bf706b47e0d133364aec94ad3e1485cbc9669b5e24c
|
data/commonmarker.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.executables = ['commonmarker']
|
25
25
|
s.require_paths = %w(lib ext)
|
26
26
|
|
27
|
-
s.add_dependency 'ruby-enum', '
|
27
|
+
s.add_dependency 'ruby-enum', '= 0.5.0'
|
28
28
|
|
29
29
|
s.add_development_dependency 'minitest', '~> 5.6'
|
30
30
|
s.add_development_dependency 'rake-compiler', '~> 0.9'
|
@@ -148,9 +148,9 @@ test: $(SPEC) cmake_build
|
|
148
148
|
$(ALLTESTS): $(SPEC) $(EXTENSIONS_SPEC)
|
149
149
|
( \
|
150
150
|
python3 test/spec_tests.py --spec $(SPEC) --dump-tests | \
|
151
|
-
python3 -c 'import json; import sys; tests = json.loads(sys.stdin.read()); print("\n".join([test["markdown"] for test in tests]))'; \
|
151
|
+
python3 -c 'import json; import sys; tests = json.loads(sys.stdin.read()); u8s = open(1, "w", encoding="utf-8", closefd=False); print("\n".join([test["markdown"] for test in tests]), file=u8s)'; \
|
152
152
|
python3 test/spec_tests.py --spec $(EXTENSIONS_SPEC) --dump-tests | \
|
153
|
-
python3 -c 'import json; import sys; tests = json.loads(sys.stdin.read()); print("\n".join([test["markdown"] for test in tests]))'; \
|
153
|
+
python3 -c 'import json; import sys; tests = json.loads(sys.stdin.read()); u8s = open(1, "w", encoding="utf-8", closefd=False); print("\n".join([test["markdown"] for test in tests]), file=u8s)'; \
|
154
154
|
) > $@
|
155
155
|
|
156
156
|
leakcheck: $(ALLTESTS)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
cmake_minimum_required(VERSION 2.8)
|
2
|
+
set(LIBRARY "libcmarkextensions")
|
2
3
|
set(STATICLIBRARY "libcmarkextensions_static")
|
3
4
|
set(LIBRARY_SOURCES
|
4
5
|
core-extensions.c
|
@@ -16,6 +17,8 @@ include_directories(
|
|
16
17
|
${PROJECT_BINARY_DIR}/src
|
17
18
|
)
|
18
19
|
|
20
|
+
include (GenerateExportHeader)
|
21
|
+
|
19
22
|
# We make LIB_INSTALL_DIR configurable rather than
|
20
23
|
# hard-coding lib, because on some OSes different locations
|
21
24
|
# are used for different architectures (e.g. /usr/lib64 on
|
@@ -29,22 +32,45 @@ include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
|
|
29
32
|
|
30
33
|
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
|
31
34
|
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
|
35
|
+
add_compiler_export_flags()
|
32
36
|
|
33
|
-
|
37
|
+
if (CMARK_SHARED)
|
38
|
+
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
|
34
39
|
|
35
|
-
set_target_properties(${
|
36
|
-
|
37
|
-
|
40
|
+
set_target_properties(${LIBRARY} PROPERTIES
|
41
|
+
OUTPUT_NAME "cmarkextensions"
|
42
|
+
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
43
|
+
VERSION ${PROJECT_VERSION})
|
44
|
+
|
45
|
+
set_property(TARGET ${LIBRARY}
|
46
|
+
APPEND PROPERTY MACOSX_RPATH true)
|
47
|
+
|
48
|
+
# Avoid name clash between PROGRAM and LIBRARY pdb files.
|
49
|
+
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmarkextensions_dll)
|
50
|
+
|
51
|
+
list(APPEND CMARK_INSTALL ${LIBRARY})
|
52
|
+
target_link_libraries(${LIBRARY} libcmark)
|
53
|
+
|
54
|
+
generate_export_header(${LIBRARY} BASE_NAME cmarkextensions)
|
55
|
+
endif()
|
56
|
+
|
57
|
+
if (CMARK_STATIC)
|
58
|
+
add_library(${STATICLIBRARY} STATIC ${LIBRARY_SOURCES})
|
38
59
|
|
39
|
-
if (MSVC)
|
40
|
-
set_target_properties(${STATICLIBRARY} PROPERTIES
|
41
|
-
OUTPUT_NAME "cmarkextensions_static"
|
42
|
-
VERSION ${PROJECT_VERSION})
|
43
|
-
else()
|
44
60
|
set_target_properties(${STATICLIBRARY} PROPERTIES
|
45
|
-
|
46
|
-
|
47
|
-
|
61
|
+
COMPILE_FLAGS -DCMARKEXTENSIONS_STATIC_DEFINE
|
62
|
+
POSITION_INDEPENDENT_CODE ON)
|
63
|
+
|
64
|
+
if (MSVC)
|
65
|
+
set_target_properties(${STATICLIBRARY} PROPERTIES
|
66
|
+
OUTPUT_NAME "cmarkextensions_static"
|
67
|
+
VERSION ${PROJECT_VERSION})
|
68
|
+
else()
|
69
|
+
set_target_properties(${STATICLIBRARY} PROPERTIES
|
70
|
+
OUTPUT_NAME "cmarkextensions"
|
71
|
+
VERSION ${PROJECT_VERSION})
|
72
|
+
endif(MSVC)
|
73
|
+
endif()
|
48
74
|
|
49
75
|
# Feature tests
|
50
76
|
include(CheckIncludeFile)
|
@@ -9,9 +9,8 @@
|
|
9
9
|
#endif
|
10
10
|
|
11
11
|
static int sd_autolink_issafe(const uint8_t *link, size_t link_len) {
|
12
|
-
static const size_t valid_uris_count =
|
13
|
-
static const char *valid_uris[] = {"
|
14
|
-
"mailto:"};
|
12
|
+
static const size_t valid_uris_count = 3;
|
13
|
+
static const char *valid_uris[] = {"http://", "https://", "ftp://"};
|
15
14
|
|
16
15
|
size_t i;
|
17
16
|
|
@@ -40,21 +39,9 @@ static size_t autolink_delim(uint8_t *data, size_t link_end) {
|
|
40
39
|
cclose = data[link_end - 1];
|
41
40
|
|
42
41
|
switch (cclose) {
|
43
|
-
case '"':
|
44
|
-
copen = '"';
|
45
|
-
break;
|
46
|
-
case '\'':
|
47
|
-
copen = '\'';
|
48
|
-
break;
|
49
42
|
case ')':
|
50
43
|
copen = '(';
|
51
44
|
break;
|
52
|
-
case ']':
|
53
|
-
copen = '[';
|
54
|
-
break;
|
55
|
-
case '}':
|
56
|
-
copen = '{';
|
57
|
-
break;
|
58
45
|
default:
|
59
46
|
copen = 0;
|
60
47
|
}
|
@@ -77,24 +64,24 @@ static size_t autolink_delim(uint8_t *data, size_t link_end) {
|
|
77
64
|
size_t opening = 0;
|
78
65
|
i = 0;
|
79
66
|
|
80
|
-
/*
|
81
|
-
*
|
82
|
-
*
|
83
|
-
*
|
67
|
+
/* Allow any number of matching brackets (as recognised in copen/cclose)
|
68
|
+
* at the end of the URL. If there is a greater number of closing
|
69
|
+
* brackets than opening ones, we remove one character from the end of
|
70
|
+
* the link.
|
84
71
|
*
|
85
|
-
* Examples:
|
72
|
+
* Examples (input text => output linked portion):
|
86
73
|
*
|
87
|
-
*
|
74
|
+
* http://www.pokemon.com/Pikachu_(Electric)
|
88
75
|
* => http://www.pokemon.com/Pikachu_(Electric)
|
89
76
|
*
|
90
|
-
*
|
91
|
-
* => http://www.pokemon.com/Pikachu_(Electric)
|
77
|
+
* http://www.pokemon.com/Pikachu_((Electric)
|
78
|
+
* => http://www.pokemon.com/Pikachu_((Electric)
|
92
79
|
*
|
93
|
-
*
|
80
|
+
* http://www.pokemon.com/Pikachu_(Electric))
|
94
81
|
* => http://www.pokemon.com/Pikachu_(Electric)
|
95
82
|
*
|
96
|
-
*
|
97
|
-
* =>
|
83
|
+
* http://www.pokemon.com/Pikachu_((Electric))
|
84
|
+
* => http://www.pokemon.com/Pikachu_((Electric))
|
98
85
|
*/
|
99
86
|
|
100
87
|
while (i < link_end) {
|
@@ -106,7 +93,7 @@ static size_t autolink_delim(uint8_t *data, size_t link_end) {
|
|
106
93
|
i++;
|
107
94
|
}
|
108
95
|
|
109
|
-
if (closing
|
96
|
+
if (closing <= opening)
|
110
97
|
break;
|
111
98
|
|
112
99
|
link_end--;
|
@@ -194,77 +181,6 @@ static cmark_node *www_match(cmark_parser *parser, cmark_node *parent,
|
|
194
181
|
return node;
|
195
182
|
}
|
196
183
|
|
197
|
-
static cmark_node *email_match(cmark_parser *parser, cmark_node *parent,
|
198
|
-
cmark_inline_parser *inline_parser) {
|
199
|
-
size_t link_end;
|
200
|
-
int rewind;
|
201
|
-
int nb = 0, np = 0, ns = 0;
|
202
|
-
|
203
|
-
cmark_chunk *chunk = cmark_inline_parser_get_chunk(inline_parser);
|
204
|
-
int max_rewind = cmark_inline_parser_get_offset(inline_parser);
|
205
|
-
uint8_t *data = chunk->data + max_rewind;
|
206
|
-
size_t size = chunk->len - max_rewind;
|
207
|
-
|
208
|
-
for (rewind = 0; rewind < max_rewind; ++rewind) {
|
209
|
-
uint8_t c = data[-rewind - 1];
|
210
|
-
|
211
|
-
if (cmark_isalnum(c))
|
212
|
-
continue;
|
213
|
-
|
214
|
-
if (strchr(".+-_", c) != NULL)
|
215
|
-
continue;
|
216
|
-
|
217
|
-
if (c == '/')
|
218
|
-
ns++;
|
219
|
-
|
220
|
-
break;
|
221
|
-
}
|
222
|
-
|
223
|
-
if (rewind == 0 || ns > 0)
|
224
|
-
return 0;
|
225
|
-
|
226
|
-
for (link_end = 0; link_end < size; ++link_end) {
|
227
|
-
uint8_t c = data[link_end];
|
228
|
-
|
229
|
-
if (cmark_isalnum(c))
|
230
|
-
continue;
|
231
|
-
|
232
|
-
if (c == '@')
|
233
|
-
nb++;
|
234
|
-
else if (c == '.' && link_end < size - 1)
|
235
|
-
np++;
|
236
|
-
else if (c != '-' && c != '_')
|
237
|
-
break;
|
238
|
-
}
|
239
|
-
|
240
|
-
if (link_end < 2 || nb != 1 || np == 0 ||
|
241
|
-
(!cmark_isalpha(data[link_end - 1]) && data[link_end - 1] != '.'))
|
242
|
-
return 0;
|
243
|
-
|
244
|
-
link_end = autolink_delim(data, link_end);
|
245
|
-
|
246
|
-
if (link_end == 0)
|
247
|
-
return NULL;
|
248
|
-
|
249
|
-
cmark_inline_parser_set_offset(inline_parser, (int)(max_rewind + link_end));
|
250
|
-
cmark_node_unput(parent, rewind);
|
251
|
-
|
252
|
-
cmark_node *node = cmark_node_new_with_mem(CMARK_NODE_LINK, parser->mem);
|
253
|
-
|
254
|
-
cmark_strbuf buf;
|
255
|
-
cmark_strbuf_init(parser->mem, &buf, 10);
|
256
|
-
cmark_strbuf_puts(&buf, "mailto:");
|
257
|
-
cmark_strbuf_put(&buf, data - rewind, (bufsize_t)(link_end + rewind));
|
258
|
-
node->as.link.url = cmark_chunk_buf_detach(&buf);
|
259
|
-
|
260
|
-
cmark_node *text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
|
261
|
-
text->as.literal = cmark_chunk_dup(chunk, max_rewind - rewind,
|
262
|
-
(bufsize_t)(link_end + rewind));
|
263
|
-
cmark_node_append_child(node, text);
|
264
|
-
|
265
|
-
return node;
|
266
|
-
}
|
267
|
-
|
268
184
|
static cmark_node *url_match(cmark_parser *parser, cmark_node *parent,
|
269
185
|
cmark_inline_parser *inline_parser) {
|
270
186
|
size_t link_end, domain_len;
|
@@ -326,9 +242,6 @@ static cmark_node *match(cmark_syntax_extension *ext, cmark_parser *parser,
|
|
326
242
|
if (c == ':')
|
327
243
|
return url_match(parser, parent, inline_parser);
|
328
244
|
|
329
|
-
if (c == '@')
|
330
|
-
return email_match(parser, parent, inline_parser);
|
331
|
-
|
332
245
|
if (c == 'w')
|
333
246
|
return www_match(parser, parent, inline_parser);
|
334
247
|
|
@@ -339,15 +252,151 @@ static cmark_node *match(cmark_syntax_extension *ext, cmark_parser *parser,
|
|
339
252
|
// inline was finished in inlines.c.
|
340
253
|
}
|
341
254
|
|
255
|
+
static void postprocess_text(cmark_parser *parser, cmark_node *text, int offset) {
|
256
|
+
size_t link_end;
|
257
|
+
uint8_t *data = text->as.literal.data,
|
258
|
+
*at;
|
259
|
+
size_t size = text->as.literal.len;
|
260
|
+
int rewind, max_rewind,
|
261
|
+
nb = 0, np = 0, ns = 0;
|
262
|
+
|
263
|
+
if (offset < 0 || (size_t)offset >= size)
|
264
|
+
return;
|
265
|
+
|
266
|
+
data += offset;
|
267
|
+
size -= offset;
|
268
|
+
|
269
|
+
at = (uint8_t *)memchr(data, '@', size);
|
270
|
+
if (!at)
|
271
|
+
return;
|
272
|
+
|
273
|
+
max_rewind = (int)(at - data);
|
274
|
+
data += max_rewind;
|
275
|
+
size -= max_rewind;
|
276
|
+
|
277
|
+
for (rewind = 0; rewind < max_rewind; ++rewind) {
|
278
|
+
uint8_t c = data[-rewind - 1];
|
279
|
+
|
280
|
+
if (cmark_isalnum(c))
|
281
|
+
continue;
|
282
|
+
|
283
|
+
if (strchr(".+-_", c) != NULL)
|
284
|
+
continue;
|
285
|
+
|
286
|
+
if (c == '/')
|
287
|
+
ns++;
|
288
|
+
|
289
|
+
break;
|
290
|
+
}
|
291
|
+
|
292
|
+
if (rewind == 0 || ns > 0) {
|
293
|
+
postprocess_text(parser, text, max_rewind + 1 + offset);
|
294
|
+
return;
|
295
|
+
}
|
296
|
+
|
297
|
+
for (link_end = 0; link_end < size; ++link_end) {
|
298
|
+
uint8_t c = data[link_end];
|
299
|
+
|
300
|
+
if (cmark_isalnum(c))
|
301
|
+
continue;
|
302
|
+
|
303
|
+
if (c == '@')
|
304
|
+
nb++;
|
305
|
+
else if (c == '.' && link_end < size - 1)
|
306
|
+
np++;
|
307
|
+
else if (c != '-' && c != '_')
|
308
|
+
break;
|
309
|
+
}
|
310
|
+
|
311
|
+
if (link_end < 2 || nb != 1 || np == 0 ||
|
312
|
+
(!cmark_isalpha(data[link_end - 1]) && data[link_end - 1] != '.')) {
|
313
|
+
postprocess_text(parser, text, max_rewind + 1 + offset);
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
|
317
|
+
link_end = autolink_delim(data, link_end);
|
318
|
+
|
319
|
+
if (link_end == 0) {
|
320
|
+
postprocess_text(parser, text, max_rewind + 1 + offset);
|
321
|
+
return;
|
322
|
+
}
|
323
|
+
|
324
|
+
cmark_chunk_to_cstr(parser->mem, &text->as.literal);
|
325
|
+
|
326
|
+
cmark_node *link_node = cmark_node_new_with_mem(CMARK_NODE_LINK, parser->mem);
|
327
|
+
cmark_strbuf buf;
|
328
|
+
cmark_strbuf_init(parser->mem, &buf, 10);
|
329
|
+
cmark_strbuf_puts(&buf, "mailto:");
|
330
|
+
cmark_strbuf_put(&buf, data - rewind, (bufsize_t)(link_end + rewind));
|
331
|
+
link_node->as.link.url = cmark_chunk_buf_detach(&buf);
|
332
|
+
|
333
|
+
cmark_node *link_text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
|
334
|
+
cmark_chunk email = cmark_chunk_dup(
|
335
|
+
&text->as.literal,
|
336
|
+
offset + max_rewind - rewind,
|
337
|
+
(bufsize_t)(link_end + rewind));
|
338
|
+
cmark_chunk_to_cstr(parser->mem, &email);
|
339
|
+
link_text->as.literal = email;
|
340
|
+
cmark_node_append_child(link_node, link_text);
|
341
|
+
|
342
|
+
cmark_node_insert_after(text, link_node);
|
343
|
+
|
344
|
+
cmark_node *post = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
|
345
|
+
post->as.literal = cmark_chunk_dup(&text->as.literal,
|
346
|
+
(bufsize_t)(offset + max_rewind + link_end),
|
347
|
+
(bufsize_t)(size - link_end));
|
348
|
+
cmark_chunk_to_cstr(parser->mem, &post->as.literal);
|
349
|
+
|
350
|
+
cmark_node_insert_after(link_node, post);
|
351
|
+
|
352
|
+
text->as.literal.len = offset + max_rewind - rewind;
|
353
|
+
text->as.literal.data[text->as.literal.len] = 0;
|
354
|
+
|
355
|
+
postprocess_text(parser, post, 0);
|
356
|
+
}
|
357
|
+
|
358
|
+
static cmark_node *postprocess(cmark_syntax_extension *ext, cmark_parser *parser, cmark_node *root) {
|
359
|
+
cmark_iter *iter;
|
360
|
+
cmark_event_type ev;
|
361
|
+
cmark_node *node;
|
362
|
+
bool in_link = false;
|
363
|
+
|
364
|
+
cmark_consolidate_text_nodes(root);
|
365
|
+
iter = cmark_iter_new(root);
|
366
|
+
|
367
|
+
while ((ev = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
|
368
|
+
node = cmark_iter_get_node(iter);
|
369
|
+
if (in_link) {
|
370
|
+
if (ev == CMARK_EVENT_EXIT && node->type == CMARK_NODE_LINK) {
|
371
|
+
in_link = false;
|
372
|
+
}
|
373
|
+
continue;
|
374
|
+
}
|
375
|
+
|
376
|
+
if (ev == CMARK_EVENT_ENTER && node->type == CMARK_NODE_LINK) {
|
377
|
+
in_link = true;
|
378
|
+
continue;
|
379
|
+
}
|
380
|
+
|
381
|
+
if (ev == CMARK_EVENT_ENTER && node->type == CMARK_NODE_TEXT) {
|
382
|
+
postprocess_text(parser, node, 0);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
cmark_iter_free(iter);
|
387
|
+
|
388
|
+
return root;
|
389
|
+
}
|
390
|
+
|
342
391
|
cmark_syntax_extension *create_autolink_extension(void) {
|
343
392
|
cmark_syntax_extension *ext = cmark_syntax_extension_new("autolink");
|
344
393
|
cmark_llist *special_chars = NULL;
|
345
394
|
|
346
395
|
cmark_syntax_extension_set_match_inline_func(ext, match);
|
396
|
+
cmark_syntax_extension_set_postprocess_func(ext, postprocess);
|
347
397
|
|
348
398
|
cmark_mem *mem = cmark_get_default_mem_allocator();
|
349
399
|
special_chars = cmark_llist_append(mem, special_chars, (void *)':');
|
350
|
-
special_chars = cmark_llist_append(mem, special_chars, (void *)'@');
|
351
400
|
special_chars = cmark_llist_append(mem, special_chars, (void *)'w');
|
352
401
|
cmark_syntax_extension_set_special_inline_chars(ext, special_chars);
|
353
402
|
|
@@ -7,17 +7,22 @@ static cmark_node *match(cmark_syntax_extension *self, cmark_parser *parser,
|
|
7
7
|
cmark_node *parent, unsigned char character,
|
8
8
|
cmark_inline_parser *inline_parser) {
|
9
9
|
cmark_node *res = NULL;
|
10
|
-
int left_flanking, right_flanking, punct_before, punct_after;
|
10
|
+
int left_flanking, right_flanking, punct_before, punct_after, delims;
|
11
|
+
char buffer[101];
|
11
12
|
|
12
13
|
if (character != '~')
|
13
14
|
return NULL;
|
14
15
|
|
15
|
-
cmark_inline_parser_scan_delimiters(
|
16
|
-
|
17
|
-
|
16
|
+
delims = cmark_inline_parser_scan_delimiters(
|
17
|
+
inline_parser, sizeof(buffer) - 1, '~',
|
18
|
+
&left_flanking,
|
19
|
+
&right_flanking, &punct_before, &punct_after);
|
20
|
+
|
21
|
+
memset(buffer, '~', delims);
|
22
|
+
buffer[delims] = 0;
|
18
23
|
|
19
24
|
res = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
|
20
|
-
cmark_node_set_literal(res,
|
25
|
+
cmark_node_set_literal(res, buffer);
|
21
26
|
|
22
27
|
if (left_flanking || right_flanking) {
|
23
28
|
cmark_inline_parser_push_delimiter(inline_parser, character, left_flanking,
|
@@ -84,7 +89,7 @@ static int can_contain(cmark_syntax_extension *extension, cmark_node *node,
|
|
84
89
|
static void commonmark_render(cmark_syntax_extension *extension,
|
85
90
|
cmark_renderer *renderer, cmark_node *node,
|
86
91
|
cmark_event_type ev_type, int options) {
|
87
|
-
renderer->out(renderer, cmark_node_get_string_content(node), false, LITERAL);
|
92
|
+
renderer->out(renderer, node, cmark_node_get_string_content(node), false, LITERAL);
|
88
93
|
}
|
89
94
|
|
90
95
|
static void latex_render(cmark_syntax_extension *extension,
|
@@ -93,9 +98,9 @@ static void latex_render(cmark_syntax_extension *extension,
|
|
93
98
|
// requires \usepackage{ulem}
|
94
99
|
bool entering = (ev_type == CMARK_EVENT_ENTER);
|
95
100
|
if (entering) {
|
96
|
-
renderer->out(renderer, "\\sout{", false, LITERAL);
|
101
|
+
renderer->out(renderer, node, "\\sout{", false, LITERAL);
|
97
102
|
} else {
|
98
|
-
renderer->out(renderer, "}", false, LITERAL);
|
103
|
+
renderer->out(renderer, node, "}", false, LITERAL);
|
99
104
|
}
|
100
105
|
}
|
101
106
|
|
@@ -105,9 +110,9 @@ static void man_render(cmark_syntax_extension *extension,
|
|
105
110
|
bool entering = (ev_type == CMARK_EVENT_ENTER);
|
106
111
|
if (entering) {
|
107
112
|
renderer->cr(renderer);
|
108
|
-
renderer->out(renderer, ".ST \"", false, LITERAL);
|
113
|
+
renderer->out(renderer, node, ".ST \"", false, LITERAL);
|
109
114
|
} else {
|
110
|
-
renderer->out(renderer, "\"", false, LITERAL);
|
115
|
+
renderer->out(renderer, node, "\"", false, LITERAL);
|
111
116
|
renderer->cr(renderer);
|
112
117
|
}
|
113
118
|
}
|