commonmarker 0.14.15 → 0.15.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 +1 -1
- data/ext/commonmarker/cmark/Makefile +4 -3
- data/ext/commonmarker/cmark/README.md +18 -11
- data/ext/commonmarker/cmark/extensions/ext_scanners.c +562 -3
- data/ext/commonmarker/cmark/extensions/ext_scanners.h +6 -0
- data/ext/commonmarker/cmark/extensions/ext_scanners.re +32 -0
- data/ext/commonmarker/cmark/extensions/table.c +87 -215
- data/ext/commonmarker/cmark/man/CMakeLists.txt +2 -2
- data/ext/commonmarker/cmark/man/make_man_page.py +1 -1
- data/ext/commonmarker/cmark/man/man1/{cmark.1 → cmark-gfm.1} +10 -4
- data/ext/commonmarker/cmark/man/man3/cmark-gfm.3 +2 -2
- data/ext/commonmarker/cmark/src/buffer.c +5 -1
- data/ext/commonmarker/cmark/src/cmark.c +6 -2
- data/ext/commonmarker/cmark/src/cmark.h +1 -1
- data/ext/commonmarker/cmark/src/cmark_extension_api.h +0 -2
- data/ext/commonmarker/cmark/src/commonmark.c +1 -2
- data/ext/commonmarker/cmark/src/inlines.c +1 -1
- data/ext/commonmarker/cmark/src/libcmark-gfm.pc.in +1 -1
- data/ext/commonmarker/cmark/src/main.c +1 -1
- data/ext/commonmarker/cmark/src/render.c +15 -0
- data/ext/commonmarker/cmark/test/extensions.txt +24 -3
- data/ext/commonmarker/cmark/test/roundtrip_tests.py +1 -0
- data/ext/commonmarker/cmark/test/spec.txt +84 -15
- data/ext/commonmarker/cmark/test/spec_tests.py +9 -8
- data/ext/commonmarker/cmark/tools/Dockerfile +12 -0
- data/lib/commonmarker/node.rb +3 -0
- data/lib/commonmarker/node/inspect.rb +59 -0
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_node.rb +8 -0
- data/test/test_spec.rb +1 -1
- metadata +4 -3
@@ -129,5 +129,5 @@ with open(sourcefile, 'r') as cmarkh:
|
|
129
129
|
chunk = []
|
130
130
|
mdlines.append('\n')
|
131
131
|
|
132
|
-
sys.stdout.write('.TH
|
132
|
+
sys.stdout.write('.TH cmark-gfm 3 "' + date.today().strftime('%B %d, %Y') + '" "LOCAL" "Library Functions Manual"\n')
|
133
133
|
sys.stdout.write(''.join(mdlines))
|
@@ -1,14 +1,14 @@
|
|
1
|
-
.TH "cmark" "1" "March 24, 2016" "LOCAL" "General Commands Manual"
|
1
|
+
.TH "cmark-gfm" "1" "March 24, 2016" "LOCAL" "General Commands Manual"
|
2
2
|
.SH "NAME"
|
3
3
|
\fBcmark\fR
|
4
|
-
\- convert CommonMark formatted text to HTML
|
4
|
+
\- convert CommonMark formatted text with GitHub Flavored Markdown extensions to HTML
|
5
5
|
.SH "SYNOPSIS"
|
6
6
|
.HP 6n
|
7
|
-
\fBcmark\fR
|
7
|
+
\fBcmark-gfm\fR
|
8
8
|
[options]
|
9
9
|
file*
|
10
10
|
.SH "DESCRIPTION"
|
11
|
-
\fBcmark\fR
|
11
|
+
\fBcmark-gfm\fR
|
12
12
|
converts Markdown formatted plain text to either HTML, groff man,
|
13
13
|
CommonMark XML, LaTeX, or CommonMark, using the conventions
|
14
14
|
described in the CommonMark spec. It reads input from \fIstdin\fR
|
@@ -42,6 +42,12 @@ Include source position attribute.
|
|
42
42
|
.B \-\-normalize
|
43
43
|
Consolidate adjacent text nodes.
|
44
44
|
.TP 12n
|
45
|
+
.B \-\-extension, \-e \f[I]EXTENSION_NAME\f[]
|
46
|
+
Specify an extension name to use.
|
47
|
+
.TP 12n
|
48
|
+
.B \-\-list\-extensions
|
49
|
+
List available extensions and quit.
|
50
|
+
.TP 12n
|
45
51
|
.B \-\-validate-utf8
|
46
52
|
Validate UTF-8, replacing illegal sequences with U+FFFD.
|
47
53
|
.TP 12n
|
@@ -1,8 +1,8 @@
|
|
1
|
-
.TH cmark 3 "
|
1
|
+
.TH cmark-gfm 3 "April 03, 2017" "LOCAL" "Library Functions Manual"
|
2
2
|
.SH
|
3
3
|
NAME
|
4
4
|
.PP
|
5
|
-
\f[B]cmark\f[] \- CommonMark parsing, manipulating, and rendering
|
5
|
+
\f[B]cmark\-gfm\f[] \- CommonMark parsing, manipulating, and rendering
|
6
6
|
|
7
7
|
.SH
|
8
8
|
DESCRIPTION
|
@@ -42,8 +42,12 @@ void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size) {
|
|
42
42
|
if (target_size < buf->asize)
|
43
43
|
return;
|
44
44
|
|
45
|
-
if (target_size > (bufsize_t)(INT32_MAX / 2))
|
45
|
+
if (target_size > (bufsize_t)(INT32_MAX / 2)) {
|
46
|
+
fprintf(stderr,
|
47
|
+
"[cmark] cmark_strbuf_grow requests buffer with size > %d, aborting\n",
|
48
|
+
(INT32_MAX / 2));
|
46
49
|
abort();
|
50
|
+
}
|
47
51
|
|
48
52
|
/* Oversize the buffer by 50% to guarantee amortized linear time
|
49
53
|
* complexity on append operations. */
|
@@ -16,15 +16,19 @@ const char *cmark_version_string() { return CMARK_VERSION_STRING; }
|
|
16
16
|
|
17
17
|
static void *xcalloc(size_t nmem, size_t size) {
|
18
18
|
void *ptr = calloc(nmem, size);
|
19
|
-
if (!ptr)
|
19
|
+
if (!ptr) {
|
20
|
+
fprintf(stderr, "[cmark] calloc returned null pointer, aborting\n");
|
20
21
|
abort();
|
22
|
+
}
|
21
23
|
return ptr;
|
22
24
|
}
|
23
25
|
|
24
26
|
static void *xrealloc(void *ptr, size_t size) {
|
25
27
|
void *new_ptr = realloc(ptr, size);
|
26
|
-
if (!new_ptr)
|
28
|
+
if (!new_ptr) {
|
29
|
+
fprintf(stderr, "[cmark] realloc returned null pointer, aborting\n");
|
27
30
|
abort();
|
31
|
+
}
|
28
32
|
return new_ptr;
|
29
33
|
}
|
30
34
|
|
@@ -33,8 +33,7 @@ static CMARK_INLINE void outc(cmark_renderer *renderer, cmark_node *node,
|
|
33
33
|
needs_escaping =
|
34
34
|
c < 0x80 && escape != LITERAL &&
|
35
35
|
((escape == NORMAL &&
|
36
|
-
(
|
37
|
-
c == '*' || c == '_' || c == '[' || c == ']' || c == '#' || c == '<' ||
|
36
|
+
(c == '*' || c == '_' || c == '[' || c == ']' || c == '#' || c == '<' ||
|
38
37
|
c == '>' || c == '\\' || c == '`' || c == '!' ||
|
39
38
|
(c == '&' && cmark_isalpha(nextc)) || (c == '!' && nextc == '[') ||
|
40
39
|
(renderer->begin_content && (c == '-' || c == '+' || c == '=') &&
|
@@ -1209,7 +1209,7 @@ void cmark_parse_inlines(cmark_parser *parser,
|
|
1209
1209
|
process_emphasis(parser, &subj, NULL);
|
1210
1210
|
// free bracket and delim stack
|
1211
1211
|
while (subj.last_delim) {
|
1212
|
-
|
1212
|
+
remove_delimiter(&subj, subj.last_delim);
|
1213
1213
|
}
|
1214
1214
|
while (subj.last_bracket) {
|
1215
1215
|
pop_bracket(&subj);
|
@@ -40,7 +40,7 @@ void print_usage() {
|
|
40
40
|
printf(" --smart Use smart punctuation\n");
|
41
41
|
printf(" --github-pre-lang Use GitHub-style <pre lang> for code blocks\n");
|
42
42
|
printf(" --normalize Consolidate adjacent text nodes\n");
|
43
|
-
printf(" -e
|
43
|
+
printf(" --extension, -e EXTENSION_NAME Specify an extension name to use\n");
|
44
44
|
printf(" --list-extensions List available extensions and quit\n");
|
45
45
|
printf(" --help, -h Print usage information\n");
|
46
46
|
printf(" --version Print version\n");
|
@@ -5,6 +5,7 @@
|
|
5
5
|
#include "utf8.h"
|
6
6
|
#include "render.h"
|
7
7
|
#include "node.h"
|
8
|
+
#include "syntax_extension.h"
|
8
9
|
|
9
10
|
static CMARK_INLINE void S_cr(cmark_renderer *renderer) {
|
10
11
|
if (renderer->need_cr < 1) {
|
@@ -30,6 +31,16 @@ static void S_out(cmark_renderer *renderer, cmark_node *node,
|
|
30
31
|
cmark_chunk remainder = cmark_chunk_literal("");
|
31
32
|
int k = renderer->buffer->size - 1;
|
32
33
|
|
34
|
+
cmark_syntax_extension *ext = NULL;
|
35
|
+
cmark_node *n = node;
|
36
|
+
while (n && !ext) {
|
37
|
+
ext = n->extension;
|
38
|
+
if (!ext)
|
39
|
+
n = n->parent;
|
40
|
+
}
|
41
|
+
if (ext && !ext->commonmark_escape_func)
|
42
|
+
ext = NULL;
|
43
|
+
|
33
44
|
wrap = wrap && !renderer->no_linebreaks;
|
34
45
|
|
35
46
|
if (renderer->in_tight_list_item && renderer->need_cr > 1) {
|
@@ -63,6 +74,10 @@ static void S_out(cmark_renderer *renderer, cmark_node *node,
|
|
63
74
|
if (len == -1) { // error condition
|
64
75
|
return; // return without rendering rest of string
|
65
76
|
}
|
77
|
+
|
78
|
+
if (ext && ext->commonmark_escape_func(ext, node, c))
|
79
|
+
cmark_strbuf_putc(renderer->buffer, '\\');
|
80
|
+
|
66
81
|
nextc = source[i + len];
|
67
82
|
if (c == 32 && wrap) {
|
68
83
|
if (!renderer->begin_line) {
|
@@ -254,8 +254,8 @@ Tables with embedded pipes could be tricky.
|
|
254
254
|
| a | b |
|
255
255
|
| --- | --- |
|
256
256
|
| Escaped pipes are \|okay\|. | Like \| this. |
|
257
|
-
| Within
|
258
|
-
| _**`c
|
257
|
+
| Within `\|code\| is okay` too. |
|
258
|
+
| _**`c\|`**_ \| complex
|
259
259
|
| don't **\_reparse\_**
|
260
260
|
.
|
261
261
|
<table>
|
@@ -344,7 +344,7 @@ This shouldn't assert.
|
|
344
344
|
</tr>
|
345
345
|
<tr>
|
346
346
|
<td>|</td>
|
347
|
-
<td><code
|
347
|
+
<td><code>|</code></td>
|
348
348
|
</tr>
|
349
349
|
<tr>
|
350
350
|
<td>\a</td>
|
@@ -427,6 +427,27 @@ Here's a link to [Freedom Planet 2][].
|
|
427
427
|
</tr></tbody></table>
|
428
428
|
````````````````````````````````
|
429
429
|
|
430
|
+
### Interaction with emphasis
|
431
|
+
|
432
|
+
```````````````````````````````` example
|
433
|
+
| a | b |
|
434
|
+
| --- | --- |
|
435
|
+
|***(a)***|
|
436
|
+
.
|
437
|
+
<table>
|
438
|
+
<thead>
|
439
|
+
<tr>
|
440
|
+
<th>a</th>
|
441
|
+
<th>b</th>
|
442
|
+
</tr>
|
443
|
+
</thead>
|
444
|
+
<tbody>
|
445
|
+
<tr>
|
446
|
+
<td><em><strong>(a)</strong></em></td>
|
447
|
+
<td></td>
|
448
|
+
</tr></tbody></table>
|
449
|
+
````````````````````````````````
|
450
|
+
|
430
451
|
|
431
452
|
## Strikethroughs
|
432
453
|
|
@@ -46,4 +46,5 @@ result_counts = {'pass': 0, 'fail': 0, 'error': 0, 'skip': 0}
|
|
46
46
|
for test in tests:
|
47
47
|
do_test(converter, test, args.normalize, result_counts)
|
48
48
|
|
49
|
+
sys.stdout.buffer.write("{pass} passed, {fail} failed, {error} errored, {skip} skipped\n".format(**result_counts).encode('utf-8'))
|
49
50
|
exit(result_counts['fail'] + result_counts['error'])
|
@@ -1,13 +1,25 @@
|
|
1
1
|
---
|
2
|
-
title:
|
3
|
-
author: John MacFarlane
|
2
|
+
title: GitHub Flavored Markdown Spec
|
4
3
|
version: 0.27
|
5
|
-
date: '
|
4
|
+
date: '2017-2-20'
|
6
5
|
license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
|
7
6
|
...
|
8
7
|
|
9
8
|
# Introduction
|
10
9
|
|
10
|
+
## What is GitHub Flavored Markdown?
|
11
|
+
|
12
|
+
GitHub Flavored Markdown, often shortened as GFM, is the dialect of Markdown
|
13
|
+
that is currently supported for user content on GitHub.com and GitHub
|
14
|
+
Enterprise.
|
15
|
+
|
16
|
+
This formal specification, based on the CommonMark Spec, defines the syntax and
|
17
|
+
semantics of this dialect.
|
18
|
+
|
19
|
+
GFM is a strict superset of CommonMark. All the features which are supported in
|
20
|
+
GitHub user content and that are not specified on the original CommonMark Spec
|
21
|
+
are hence known as **extensions**, and highlighted as such.
|
22
|
+
|
11
23
|
## What is Markdown?
|
12
24
|
|
13
25
|
Markdown is a plain text format for writing structured documents,
|
@@ -3165,8 +3177,8 @@ aaa
|
|
3165
3177
|
|
3166
3178
|
## Tables (extension)
|
3167
3179
|
|
3168
|
-
|
3169
|
-
available
|
3180
|
+
GFM enables the `table` extension, where an additional leaf block type is
|
3181
|
+
available.
|
3170
3182
|
|
3171
3183
|
A [table](@) is an arrangement of data with rows and columns, consisting of a
|
3172
3184
|
single header row, a [delimiter row] separating the header from the data, and
|
@@ -3223,14 +3235,14 @@ bar | baz
|
|
3223
3235
|
</tr></tbody></table>
|
3224
3236
|
````````````````````````````````
|
3225
3237
|
|
3226
|
-
Include a pipe in a cell's content by escaping it
|
3227
|
-
spans
|
3238
|
+
Include a pipe in a cell's content by escaping it, including inside other
|
3239
|
+
inline spans:
|
3228
3240
|
|
3229
3241
|
```````````````````````````````` example table
|
3230
3242
|
| f\|oo |
|
3231
3243
|
| ------ |
|
3232
|
-
| b
|
3233
|
-
| b
|
3244
|
+
| b `\|` az |
|
3245
|
+
| b **\|** im |
|
3234
3246
|
.
|
3235
3247
|
<table>
|
3236
3248
|
<thead>
|
@@ -3314,8 +3326,8 @@ a table will not be recognized:
|
|
3314
3326
|
````````````````````````````````
|
3315
3327
|
|
3316
3328
|
The remainder of the table's rows may vary in the number of cells. If there
|
3317
|
-
are a number of cells than the
|
3318
|
-
greater, the excess is ignored:
|
3329
|
+
are a number of cells fewer than the number of cells in the header row, empty
|
3330
|
+
cells are inserted. If there are greater, the excess is ignored:
|
3319
3331
|
|
3320
3332
|
```````````````````````````````` example table
|
3321
3333
|
| abc | def |
|
@@ -4907,6 +4919,63 @@ that in such cases, we require one space indentation from the list marker
|
|
4907
4919
|
four-space rule in cases where the list marker plus its initial indentation
|
4908
4920
|
takes four spaces (a common case), but diverge in other cases.
|
4909
4921
|
|
4922
|
+
<div class="extension">
|
4923
|
+
|
4924
|
+
## Task list items (extension)
|
4925
|
+
|
4926
|
+
GFM enables the `tasklist` extension, where an additional processing step is
|
4927
|
+
performed on [list items].
|
4928
|
+
|
4929
|
+
A [task list item](@) is a [list item][list items] where the first block in it
|
4930
|
+
is a paragraph which begins with a [task list item marker] and at least one
|
4931
|
+
whitespace character before any other content.
|
4932
|
+
|
4933
|
+
A [task list item marker](@) consists of an optional number of spaces, a left
|
4934
|
+
bracket (`[`), either a whitespace character or the letter `x` in either
|
4935
|
+
lowercase or uppercase, and then a right bracket (`]`).
|
4936
|
+
|
4937
|
+
When rendered, the [task list item marker] is replaced with a semantic checkbox element;
|
4938
|
+
in an HTML output, this would be an `<input type="checkbox">` element.
|
4939
|
+
|
4940
|
+
If the character between the brackets is a whitespace character, the checkbox
|
4941
|
+
is unchecked. Otherwise, the checkbox is checked.
|
4942
|
+
|
4943
|
+
This spec does not define how the checkbox elements are interacted with: in practice,
|
4944
|
+
implementors are free to render the checkboxes as disabled or inmutable elements,
|
4945
|
+
or they may dynamically handle dynamic interactions (i.e. checking, unchecking) in
|
4946
|
+
the final rendered document.
|
4947
|
+
|
4948
|
+
```````````````````````````````` example disabled
|
4949
|
+
- [ ] foo
|
4950
|
+
- [x] bar
|
4951
|
+
.
|
4952
|
+
<ul>
|
4953
|
+
<li><input disabled="" type="checkbox"> foo</li>
|
4954
|
+
<li><input checked="" disabled="" type="checkbox"> bar</li>
|
4955
|
+
</ul>
|
4956
|
+
````````````````````````````````
|
4957
|
+
|
4958
|
+
Task lists can be arbitrarily nested:
|
4959
|
+
|
4960
|
+
```````````````````````````````` example disabled
|
4961
|
+
- [x] foo
|
4962
|
+
- [ ] bar
|
4963
|
+
- [x] baz
|
4964
|
+
- [ ] bim
|
4965
|
+
.
|
4966
|
+
<ul>
|
4967
|
+
<li><input checked="" disabled="" type="checkbox"> foo
|
4968
|
+
<ul>
|
4969
|
+
<li><input disabled="" type="checkbox"> bar</li>
|
4970
|
+
<li><input checked="" disabled="" type="checkbox"> baz</li>
|
4971
|
+
</ul>
|
4972
|
+
</li>
|
4973
|
+
<li><input disabled="" type="checkbox"> bim</li>
|
4974
|
+
</ul>
|
4975
|
+
````````````````````````````````
|
4976
|
+
|
4977
|
+
</div>
|
4978
|
+
|
4910
4979
|
## Lists
|
4911
4980
|
|
4912
4981
|
A [list](@) is a sequence of one or more
|
@@ -7292,7 +7361,7 @@ __a<http://foo.bar/?q=__>
|
|
7292
7361
|
|
7293
7362
|
## Strikethrough (extension)
|
7294
7363
|
|
7295
|
-
|
7364
|
+
GFM enables the `strikethrough` extension, where an additional emphasis type is
|
7296
7365
|
available.
|
7297
7366
|
|
7298
7367
|
Strikethrough text is any text wrapped in tildes (`~`).
|
@@ -8750,7 +8819,7 @@ foo@bar.example.com
|
|
8750
8819
|
|
8751
8820
|
## Autolinks (extension)
|
8752
8821
|
|
8753
|
-
|
8822
|
+
GFM enables the `autolink` extension, where autolinks will be recognised in a
|
8754
8823
|
greater number of conditions.
|
8755
8824
|
|
8756
8825
|
[Autolink]s can also be constructed without requiring the use of `<` and to `>`
|
@@ -9179,9 +9248,9 @@ foo <a href="\*">
|
|
9179
9248
|
|
9180
9249
|
<div class="extension">
|
9181
9250
|
|
9182
|
-
## Raw HTML (extension)
|
9251
|
+
## Disallowed Raw HTML (extension)
|
9183
9252
|
|
9184
|
-
|
9253
|
+
GFM enables the `tagfilter` extension, where the following HTML tags will be
|
9185
9254
|
filtered when rendering HTML output:
|
9186
9255
|
|
9187
9256
|
* `<title>`
|
@@ -104,14 +104,15 @@ def get_tests(specfile):
|
|
104
104
|
state = 0
|
105
105
|
example_number = example_number + 1
|
106
106
|
end_line = line_number
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
107
|
+
if 'disabled' not in extensions:
|
108
|
+
tests.append({
|
109
|
+
"markdown":''.join(markdown_lines).replace('→',"\t"),
|
110
|
+
"html":''.join(html_lines).replace('→',"\t"),
|
111
|
+
"example": example_number,
|
112
|
+
"start_line": start_line,
|
113
|
+
"end_line": end_line,
|
114
|
+
"section": headertext,
|
115
|
+
"extensions": extensions})
|
115
116
|
start_line = 0
|
116
117
|
markdown_lines = []
|
117
118
|
html_lines = []
|
@@ -22,3 +22,15 @@ RUN wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz && \
|
|
22
22
|
make install && \
|
23
23
|
cd .. && \
|
24
24
|
rm -rf afl-*
|
25
|
+
|
26
|
+
RUN apt-get install -y man
|
27
|
+
|
28
|
+
RUN wget https://github.com/skvadrik/re2c/releases/download/0.15.3/re2c-0.15.3.tar.gz && \
|
29
|
+
tar xf re2c-0.15.3.tar.gz && \
|
30
|
+
cd re2c-* && \
|
31
|
+
./configure && \
|
32
|
+
make install && \
|
33
|
+
cd .. && \
|
34
|
+
rm -rf re2c-*
|
35
|
+
|
36
|
+
RUN apt-get install -y clang-format-3.5
|