commonmarker 0.17.7.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -17
- data/commonmarker.gemspec +1 -1
- data/ext/commonmarker/arena.c +2 -2
- data/ext/commonmarker/autolink.h +3 -3
- data/ext/commonmarker/blocks.c +21 -15
- data/ext/commonmarker/buffer.h +23 -23
- data/ext/commonmarker/chunk.h +1 -1
- data/ext/commonmarker/cmark-gfm-core-extensions.h +28 -0
- data/ext/commonmarker/{cmark_extension_api.h → cmark-gfm-extension_api.h} +86 -69
- data/ext/commonmarker/cmark-gfm-extensions_export.h +42 -0
- data/ext/commonmarker/{cmark.h → cmark-gfm.h} +118 -96
- data/ext/commonmarker/cmark-gfm_export.h +42 -0
- data/ext/commonmarker/cmark-gfm_version.h +7 -0
- data/ext/commonmarker/cmark.c +3 -3
- data/ext/commonmarker/cmark_ctype.h +6 -6
- data/ext/commonmarker/commonmark.c +8 -4
- data/ext/commonmarker/commonmarker.c +33 -15
- data/ext/commonmarker/commonmarker.h +1 -1
- data/ext/commonmarker/core-extensions.c +2 -2
- data/ext/commonmarker/ext_scanners.h +1 -1
- data/ext/commonmarker/footnotes.c +1 -1
- data/ext/commonmarker/houdini.h +6 -6
- data/ext/commonmarker/houdini_href_e.c +2 -2
- data/ext/commonmarker/html.c +15 -7
- data/ext/commonmarker/inlines.c +36 -5
- data/ext/commonmarker/inlines.h +1 -1
- data/ext/commonmarker/iterator.c +1 -1
- data/ext/commonmarker/iterator.h +1 -1
- data/ext/commonmarker/latex.c +1 -1
- data/ext/commonmarker/linked_list.c +1 -1
- data/ext/commonmarker/man.c +1 -1
- data/ext/commonmarker/node.c +17 -3
- data/ext/commonmarker/node.h +4 -4
- data/ext/commonmarker/plugin.h +2 -2
- data/ext/commonmarker/references.c +1 -1
- data/ext/commonmarker/registry.c +1 -1
- data/ext/commonmarker/registry.h +4 -4
- data/ext/commonmarker/render.c +1 -1
- data/ext/commonmarker/scanners.c +10550 -18051
- data/ext/commonmarker/scanners.h +1 -1
- data/ext/commonmarker/strikethrough.c +13 -3
- data/ext/commonmarker/strikethrough.h +3 -3
- data/ext/commonmarker/syntax_extension.c +11 -1
- data/ext/commonmarker/syntax_extension.h +4 -2
- data/ext/commonmarker/table.c +88 -9
- data/ext/commonmarker/table.h +7 -3
- data/ext/commonmarker/tagfilter.h +3 -3
- data/ext/commonmarker/utf8.h +6 -6
- data/ext/commonmarker/xml.c +10 -3
- data/lib/commonmarker/config.rb +4 -1
- data/lib/commonmarker/node.rb +6 -4
- data/lib/commonmarker/renderer/html_renderer.rb +12 -12
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_extensions.rb +52 -1
- data/test/test_footnotes.rb +1 -1
- data/test/test_options.rb +35 -0
- data/test/test_spec.rb +4 -4
- metadata +12 -10
- data/ext/commonmarker/cmark_export.h +0 -42
- data/ext/commonmarker/cmark_version.h +0 -8
- data/ext/commonmarker/cmarkextensions_export.h +0 -42
- data/ext/commonmarker/core-extensions.h +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11d4791ae4e26e529efbad366fef1bf1b0354caa
|
|
4
|
+
data.tar.gz: 67dec1b64e22464e2b5fce687171ae338a80221f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77749bbebb465097693ce23e1436f38cdc9995389d3527b5e52fe0f1ef37cafd4438416c2d60ebf7863d4d3713f580244fd7f0aa8c3f718d9f7ebb5baf20630d
|
|
7
|
+
data.tar.gz: 40ef8944199e42c68b7a61aa4d667778d555ad83502267b768e1d8c9424a8d9302e85ca68fe92c99b76fdf37d66afb05b093986792ed933973ac00a94bb20e0b
|
data/README.md
CHANGED
|
@@ -129,24 +129,27 @@ CommonMarker accepts the same options that CMark does, as symbols. Note that the
|
|
|
129
129
|
|
|
130
130
|
### Parse options
|
|
131
131
|
|
|
132
|
-
| Name
|
|
133
|
-
|
|
|
134
|
-
| `:DEFAULT`
|
|
135
|
-
| `:
|
|
136
|
-
| `:
|
|
137
|
-
| `:
|
|
138
|
-
| `:
|
|
132
|
+
| Name | Description
|
|
133
|
+
| ----------------------------- | -----------
|
|
134
|
+
| `:DEFAULT` | The default parsing system.
|
|
135
|
+
| `:FOOTNOTES` | Parse footnotes.
|
|
136
|
+
| `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags.
|
|
137
|
+
| `:SMART` | Use smart punctuation (curly quotes, etc.).
|
|
138
|
+
| `:STRIKETHROUGH_DOUBLE_TILDE` | Parse strikethroughs by double tildes (compatibility with [redcarpet](https://github.com/vmg/redcarpet))
|
|
139
|
+
| `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`.
|
|
139
140
|
|
|
140
141
|
### Render options
|
|
141
142
|
|
|
142
|
-
| Name
|
|
143
|
-
| ------------------
|
|
144
|
-
| `:DEFAULT`
|
|
145
|
-
| `:
|
|
146
|
-
| `:HARDBREAKS`
|
|
147
|
-
| `:NOBREAKS`
|
|
148
|
-
| `:
|
|
149
|
-
| `:
|
|
143
|
+
| Name | Description |
|
|
144
|
+
| ------------------ | ----------- |
|
|
145
|
+
| `:DEFAULT` | The default rendering system. |
|
|
146
|
+
| `:GITHUB_PRE_LANG` | Use GitHub-style `<pre lang>` for fenced code blocks. |
|
|
147
|
+
| `:HARDBREAKS` | Treat `\n` as hardbreaks (by adding `<br/>`). |
|
|
148
|
+
| `:NOBREAKS` | Translate `\n` in the source to a single whitespace. |
|
|
149
|
+
| `:UNSAFE` | Allow raw HTML and unsafe links. |
|
|
150
|
+
| `:SOURCEPOS` | Include source position in rendered HTML. |
|
|
151
|
+
| `:TABLE_PREFER_STYLE_ATTRIBUTES` | Use `style` insted of `align` for table cells |
|
|
152
|
+
| `:FULL_INFO_STRING` | Include full info strings of code blocks in separate attribute |
|
|
150
153
|
|
|
151
154
|
### Passing options
|
|
152
155
|
|
|
@@ -174,8 +177,7 @@ The available extensions are:
|
|
|
174
177
|
* `:table` - This provides support for tables.
|
|
175
178
|
* `:strikethrough` - This provides support for strikethroughs.
|
|
176
179
|
* `:autolink` - This provides support for automatically converting URLs to anchor tags.
|
|
177
|
-
* `:tagfilter` - This
|
|
178
|
-
* `:tasklist` - This enables support for task list rendering.
|
|
180
|
+
* `:tagfilter` - This escapes [several "unsafe" HTML tags](https://github.github.com/gfm/#disallowed-raw-html-extension-), causing them to not have any effect.
|
|
179
181
|
|
|
180
182
|
## Developing locally
|
|
181
183
|
|
data/commonmarker.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
|
8
8
|
s.version = CommonMarker::VERSION
|
|
9
9
|
s.summary = 'CommonMark parser and renderer. Written in C, wrapped in Ruby.'
|
|
10
10
|
s.description = 'A fast, safe, extensible parser for CommonMark. This wraps the official libcmark library.'
|
|
11
|
-
s.authors = ['Garen Torikian', '
|
|
11
|
+
s.authors = ['Garen Torikian', 'Ashe Connor']
|
|
12
12
|
s.homepage = 'http://github.com/gjtorikian/commonmarker'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.required_ruby_version = '>= 2.0.0'
|
data/ext/commonmarker/arena.c
CHANGED
data/ext/commonmarker/autolink.h
CHANGED
data/ext/commonmarker/blocks.c
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
#include "syntax_extension.h"
|
|
14
14
|
#include "config.h"
|
|
15
15
|
#include "parser.h"
|
|
16
|
-
#include "cmark.h"
|
|
16
|
+
#include "cmark-gfm.h"
|
|
17
17
|
#include "node.h"
|
|
18
18
|
#include "references.h"
|
|
19
19
|
#include "utf8.h"
|
|
@@ -755,22 +755,24 @@ static void S_find_first_nonspace(cmark_parser *parser, cmark_chunk *input) {
|
|
|
755
755
|
char c;
|
|
756
756
|
int chars_to_tab = TAB_STOP - (parser->column % TAB_STOP);
|
|
757
757
|
|
|
758
|
-
parser->first_nonspace
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
758
|
+
if (parser->first_nonspace <= parser->offset) {
|
|
759
|
+
parser->first_nonspace = parser->offset;
|
|
760
|
+
parser->first_nonspace_column = parser->column;
|
|
761
|
+
while ((c = peek_at(input, parser->first_nonspace))) {
|
|
762
|
+
if (c == ' ') {
|
|
763
|
+
parser->first_nonspace += 1;
|
|
764
|
+
parser->first_nonspace_column += 1;
|
|
765
|
+
chars_to_tab = chars_to_tab - 1;
|
|
766
|
+
if (chars_to_tab == 0) {
|
|
767
|
+
chars_to_tab = TAB_STOP;
|
|
768
|
+
}
|
|
769
|
+
} else if (c == '\t') {
|
|
770
|
+
parser->first_nonspace += 1;
|
|
771
|
+
parser->first_nonspace_column += chars_to_tab;
|
|
766
772
|
chars_to_tab = TAB_STOP;
|
|
773
|
+
} else {
|
|
774
|
+
break;
|
|
767
775
|
}
|
|
768
|
-
} else if (c == '\t') {
|
|
769
|
-
parser->first_nonspace += 1;
|
|
770
|
-
parser->first_nonspace_column += chars_to_tab;
|
|
771
|
-
chars_to_tab = TAB_STOP;
|
|
772
|
-
} else {
|
|
773
|
-
break;
|
|
774
776
|
}
|
|
775
777
|
}
|
|
776
778
|
|
|
@@ -1137,6 +1139,7 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container,
|
|
|
1137
1139
|
|
|
1138
1140
|
(*container)->internal_offset = matched;
|
|
1139
1141
|
} else if ((!indented || cont_type == CMARK_NODE_LIST) &&
|
|
1142
|
+
parser->indent < 4 &&
|
|
1140
1143
|
(matched = parse_list_marker(
|
|
1141
1144
|
parser->mem, input, parser->first_nonspace,
|
|
1142
1145
|
(*container)->type == CMARK_NODE_PARAGRAPH, &data))) {
|
|
@@ -1372,6 +1375,9 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
|
|
|
1372
1375
|
|
|
1373
1376
|
parser->offset = 0;
|
|
1374
1377
|
parser->column = 0;
|
|
1378
|
+
parser->first_nonspace = 0;
|
|
1379
|
+
parser->first_nonspace_column = 0;
|
|
1380
|
+
parser->indent = 0;
|
|
1375
1381
|
parser->blank = false;
|
|
1376
1382
|
parser->partially_consumed_tab = false;
|
|
1377
1383
|
|
data/ext/commonmarker/buffer.h
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#include <limits.h>
|
|
8
8
|
#include <stdint.h>
|
|
9
9
|
#include "config.h"
|
|
10
|
-
#include "cmark.h"
|
|
10
|
+
#include "cmark-gfm.h"
|
|
11
11
|
|
|
12
12
|
#ifdef __cplusplus
|
|
13
13
|
extern "C" {
|
|
@@ -30,32 +30,32 @@ extern unsigned char cmark_strbuf__initbuf[];
|
|
|
30
30
|
* For the cases where CMARK_BUF_INIT cannot be used to do static
|
|
31
31
|
* initialization.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
CMARK_GFM_EXPORT
|
|
34
34
|
void cmark_strbuf_init(cmark_mem *mem, cmark_strbuf *buf,
|
|
35
35
|
bufsize_t initial_size);
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Grow the buffer to hold at least `target_size` bytes.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
CMARK_GFM_EXPORT
|
|
41
41
|
void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size);
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
CMARK_GFM_EXPORT
|
|
44
44
|
void cmark_strbuf_free(cmark_strbuf *buf);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
CMARK_GFM_EXPORT
|
|
47
47
|
void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
CMARK_GFM_EXPORT
|
|
50
50
|
bufsize_t cmark_strbuf_len(const cmark_strbuf *buf);
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
CMARK_GFM_EXPORT
|
|
53
53
|
int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
CMARK_GFM_EXPORT
|
|
56
56
|
unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
CMARK_GFM_EXPORT
|
|
59
59
|
void cmark_strbuf_copy_cstr(char *data, bufsize_t datasize,
|
|
60
60
|
const cmark_strbuf *buf);
|
|
61
61
|
|
|
@@ -65,48 +65,48 @@ static CMARK_INLINE const char *cmark_strbuf_cstr(const cmark_strbuf *buf) {
|
|
|
65
65
|
|
|
66
66
|
#define cmark_strbuf_at(buf, n) ((buf)->ptr[n])
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
CMARK_GFM_EXPORT
|
|
69
69
|
void cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data,
|
|
70
70
|
bufsize_t len);
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
CMARK_GFM_EXPORT
|
|
73
73
|
void cmark_strbuf_sets(cmark_strbuf *buf, const char *string);
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
CMARK_GFM_EXPORT
|
|
76
76
|
void cmark_strbuf_putc(cmark_strbuf *buf, int c);
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
CMARK_GFM_EXPORT
|
|
79
79
|
void cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data,
|
|
80
80
|
bufsize_t len);
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
CMARK_GFM_EXPORT
|
|
83
83
|
void cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
CMARK_GFM_EXPORT
|
|
86
86
|
void cmark_strbuf_clear(cmark_strbuf *buf);
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
CMARK_GFM_EXPORT
|
|
89
89
|
bufsize_t cmark_strbuf_strchr(const cmark_strbuf *buf, int c, bufsize_t pos);
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
CMARK_GFM_EXPORT
|
|
92
92
|
bufsize_t cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, bufsize_t pos);
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
CMARK_GFM_EXPORT
|
|
95
95
|
void cmark_strbuf_drop(cmark_strbuf *buf, bufsize_t n);
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
CMARK_GFM_EXPORT
|
|
98
98
|
void cmark_strbuf_truncate(cmark_strbuf *buf, bufsize_t len);
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
CMARK_GFM_EXPORT
|
|
101
101
|
void cmark_strbuf_rtrim(cmark_strbuf *buf);
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
CMARK_GFM_EXPORT
|
|
104
104
|
void cmark_strbuf_trim(cmark_strbuf *buf);
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
CMARK_GFM_EXPORT
|
|
107
107
|
void cmark_strbuf_normalize_whitespace(cmark_strbuf *s);
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
CMARK_GFM_EXPORT
|
|
110
110
|
void cmark_strbuf_unescape(cmark_strbuf *s);
|
|
111
111
|
|
|
112
112
|
#ifdef __cplusplus
|
data/ext/commonmarker/chunk.h
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#ifndef CMARK_GFM_CORE_EXTENSIONS_H
|
|
2
|
+
#define CMARK_GFM_CORE_EXTENSIONS_H
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include "cmark-gfm-extension_api.h"
|
|
9
|
+
#include "cmark-gfm-extensions_export.h"
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
|
|
12
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
|
13
|
+
void cmark_gfm_core_extensions_ensure_registered(void);
|
|
14
|
+
|
|
15
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
|
16
|
+
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node);
|
|
17
|
+
|
|
18
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
|
19
|
+
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node);
|
|
20
|
+
|
|
21
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
|
22
|
+
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node);
|
|
23
|
+
|
|
24
|
+
#ifdef __cplusplus
|
|
25
|
+
}
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
#endif
|