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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -17
  3. data/commonmarker.gemspec +1 -1
  4. data/ext/commonmarker/arena.c +2 -2
  5. data/ext/commonmarker/autolink.h +3 -3
  6. data/ext/commonmarker/blocks.c +21 -15
  7. data/ext/commonmarker/buffer.h +23 -23
  8. data/ext/commonmarker/chunk.h +1 -1
  9. data/ext/commonmarker/cmark-gfm-core-extensions.h +28 -0
  10. data/ext/commonmarker/{cmark_extension_api.h → cmark-gfm-extension_api.h} +86 -69
  11. data/ext/commonmarker/cmark-gfm-extensions_export.h +42 -0
  12. data/ext/commonmarker/{cmark.h → cmark-gfm.h} +118 -96
  13. data/ext/commonmarker/cmark-gfm_export.h +42 -0
  14. data/ext/commonmarker/cmark-gfm_version.h +7 -0
  15. data/ext/commonmarker/cmark.c +3 -3
  16. data/ext/commonmarker/cmark_ctype.h +6 -6
  17. data/ext/commonmarker/commonmark.c +8 -4
  18. data/ext/commonmarker/commonmarker.c +33 -15
  19. data/ext/commonmarker/commonmarker.h +1 -1
  20. data/ext/commonmarker/core-extensions.c +2 -2
  21. data/ext/commonmarker/ext_scanners.h +1 -1
  22. data/ext/commonmarker/footnotes.c +1 -1
  23. data/ext/commonmarker/houdini.h +6 -6
  24. data/ext/commonmarker/houdini_href_e.c +2 -2
  25. data/ext/commonmarker/html.c +15 -7
  26. data/ext/commonmarker/inlines.c +36 -5
  27. data/ext/commonmarker/inlines.h +1 -1
  28. data/ext/commonmarker/iterator.c +1 -1
  29. data/ext/commonmarker/iterator.h +1 -1
  30. data/ext/commonmarker/latex.c +1 -1
  31. data/ext/commonmarker/linked_list.c +1 -1
  32. data/ext/commonmarker/man.c +1 -1
  33. data/ext/commonmarker/node.c +17 -3
  34. data/ext/commonmarker/node.h +4 -4
  35. data/ext/commonmarker/plugin.h +2 -2
  36. data/ext/commonmarker/references.c +1 -1
  37. data/ext/commonmarker/registry.c +1 -1
  38. data/ext/commonmarker/registry.h +4 -4
  39. data/ext/commonmarker/render.c +1 -1
  40. data/ext/commonmarker/scanners.c +10550 -18051
  41. data/ext/commonmarker/scanners.h +1 -1
  42. data/ext/commonmarker/strikethrough.c +13 -3
  43. data/ext/commonmarker/strikethrough.h +3 -3
  44. data/ext/commonmarker/syntax_extension.c +11 -1
  45. data/ext/commonmarker/syntax_extension.h +4 -2
  46. data/ext/commonmarker/table.c +88 -9
  47. data/ext/commonmarker/table.h +7 -3
  48. data/ext/commonmarker/tagfilter.h +3 -3
  49. data/ext/commonmarker/utf8.h +6 -6
  50. data/ext/commonmarker/xml.c +10 -3
  51. data/lib/commonmarker/config.rb +4 -1
  52. data/lib/commonmarker/node.rb +6 -4
  53. data/lib/commonmarker/renderer/html_renderer.rb +12 -12
  54. data/lib/commonmarker/version.rb +1 -1
  55. data/test/test_extensions.rb +52 -1
  56. data/test/test_footnotes.rb +1 -1
  57. data/test/test_options.rb +35 -0
  58. data/test/test_spec.rb +4 -4
  59. metadata +12 -10
  60. data/ext/commonmarker/cmark_export.h +0 -42
  61. data/ext/commonmarker/cmark_version.h +0 -8
  62. data/ext/commonmarker/cmarkextensions_export.h +0 -42
  63. data/ext/commonmarker/core-extensions.h +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62db9ada9b0ec7e95b771d2ddf75f6062b5f4434
4
- data.tar.gz: 4b2fc6430b0cfdbdff042429511d5cb82415c3dc
3
+ metadata.gz: 11d4791ae4e26e529efbad366fef1bf1b0354caa
4
+ data.tar.gz: 67dec1b64e22464e2b5fce687171ae338a80221f
5
5
  SHA512:
6
- metadata.gz: d817521a55244e3f9f1632e827b998fe72adcaa2975b8d79615cc03347ac4c1105f81eee423d5ae36fcbf64ef5f54d4fc36d18d77e70c5da820f11568e559e4d
7
- data.tar.gz: 5c4afeae4736e9122721a0052a77e494c3925c974d3f32689b6fdf40aa94e2bf3aaa4d01f23f36cd7935cf0c18dc1780d0792b25ac5448c947745f880b48d7bb
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 | Description
133
- | ------------------- | -----------
134
- | `:DEFAULT` | The default parsing system.
135
- | `:SMART` | Use smart punctuation (curly quotes, etc.).
136
- | `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`.
137
- | `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags.
138
- | `:FOOTNOTES` | Parse footnotes.
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 | Description
143
- | ------------------ | -----------
144
- | `:DEFAULT` | The default rendering system.
145
- | `:SOURCEPOS` | Include source position in rendered HTML.
146
- | `:HARDBREAKS` | Treat `\n` as hardbreaks (by adding `<br/>`).
147
- | `:NOBREAKS` | Translate `\n` in the source to a single whitespace.
148
- | `:SAFE` | Suppress raw HTML and unsafe links.
149
- | `:GITHUB_PRE_LANG` | Use GitHub-style `<pre lang>` for fenced code blocks.
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 strips out [several "unsafe" HTML tags](https://github.github.com/gfm/#disallowed-raw-html-extension-) from being used.
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', 'Yuki Izumi']
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'
@@ -1,8 +1,8 @@
1
1
  #include <stdlib.h>
2
2
  #include <string.h>
3
3
  #include <stdint.h>
4
- #include "cmark.h"
5
- #include "cmark_extension_api.h"
4
+ #include "cmark-gfm.h"
5
+ #include "cmark-gfm-extension_api.h"
6
6
 
7
7
  static struct arena_chunk {
8
8
  size_t sz, used;
@@ -1,7 +1,7 @@
1
- #ifndef AUTOLINK_H
2
- #define AUTOLINK_H
1
+ #ifndef CMARK_GFM_AUTOLINK_H
2
+ #define CMARK_GFM_AUTOLINK_H
3
3
 
4
- #include "core-extensions.h"
4
+ #include "cmark-gfm-core-extensions.h"
5
5
 
6
6
  cmark_syntax_extension *create_autolink_extension(void);
7
7
 
@@ -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 = parser->offset;
759
- parser->first_nonspace_column = parser->column;
760
- while ((c = peek_at(input, parser->first_nonspace))) {
761
- if (c == ' ') {
762
- parser->first_nonspace += 1;
763
- parser->first_nonspace_column += 1;
764
- chars_to_tab = chars_to_tab - 1;
765
- if (chars_to_tab == 0) {
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
 
@@ -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
- CMARK_EXPORT
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
- CMARK_EXPORT
40
+ CMARK_GFM_EXPORT
41
41
  void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size);
42
42
 
43
- CMARK_EXPORT
43
+ CMARK_GFM_EXPORT
44
44
  void cmark_strbuf_free(cmark_strbuf *buf);
45
45
 
46
- CMARK_EXPORT
46
+ CMARK_GFM_EXPORT
47
47
  void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
48
48
 
49
- CMARK_EXPORT
49
+ CMARK_GFM_EXPORT
50
50
  bufsize_t cmark_strbuf_len(const cmark_strbuf *buf);
51
51
 
52
- CMARK_EXPORT
52
+ CMARK_GFM_EXPORT
53
53
  int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b);
54
54
 
55
- CMARK_EXPORT
55
+ CMARK_GFM_EXPORT
56
56
  unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
57
57
 
58
- CMARK_EXPORT
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
- CMARK_EXPORT
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
- CMARK_EXPORT
72
+ CMARK_GFM_EXPORT
73
73
  void cmark_strbuf_sets(cmark_strbuf *buf, const char *string);
74
74
 
75
- CMARK_EXPORT
75
+ CMARK_GFM_EXPORT
76
76
  void cmark_strbuf_putc(cmark_strbuf *buf, int c);
77
77
 
78
- CMARK_EXPORT
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
- CMARK_EXPORT
82
+ CMARK_GFM_EXPORT
83
83
  void cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
84
84
 
85
- CMARK_EXPORT
85
+ CMARK_GFM_EXPORT
86
86
  void cmark_strbuf_clear(cmark_strbuf *buf);
87
87
 
88
- CMARK_EXPORT
88
+ CMARK_GFM_EXPORT
89
89
  bufsize_t cmark_strbuf_strchr(const cmark_strbuf *buf, int c, bufsize_t pos);
90
90
 
91
- CMARK_EXPORT
91
+ CMARK_GFM_EXPORT
92
92
  bufsize_t cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, bufsize_t pos);
93
93
 
94
- CMARK_EXPORT
94
+ CMARK_GFM_EXPORT
95
95
  void cmark_strbuf_drop(cmark_strbuf *buf, bufsize_t n);
96
96
 
97
- CMARK_EXPORT
97
+ CMARK_GFM_EXPORT
98
98
  void cmark_strbuf_truncate(cmark_strbuf *buf, bufsize_t len);
99
99
 
100
- CMARK_EXPORT
100
+ CMARK_GFM_EXPORT
101
101
  void cmark_strbuf_rtrim(cmark_strbuf *buf);
102
102
 
103
- CMARK_EXPORT
103
+ CMARK_GFM_EXPORT
104
104
  void cmark_strbuf_trim(cmark_strbuf *buf);
105
105
 
106
- CMARK_EXPORT
106
+ CMARK_GFM_EXPORT
107
107
  void cmark_strbuf_normalize_whitespace(cmark_strbuf *s);
108
108
 
109
- CMARK_EXPORT
109
+ CMARK_GFM_EXPORT
110
110
  void cmark_strbuf_unescape(cmark_strbuf *s);
111
111
 
112
112
  #ifdef __cplusplus
@@ -4,7 +4,7 @@
4
4
  #include <string.h>
5
5
  #include <stdlib.h>
6
6
  #include <assert.h>
7
- #include "cmark.h"
7
+ #include "cmark-gfm.h"
8
8
  #include "buffer.h"
9
9
  #include "memory.h"
10
10
  #include "cmark_ctype.h"
@@ -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