commonmarker 0.17.5 → 0.17.6

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.

Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/ext/commonmarker/cmark/CMakeLists.txt +1 -1
  4. data/ext/commonmarker/cmark/README.md +3 -2
  5. data/ext/commonmarker/cmark/api_test/CMakeLists.txt +1 -1
  6. data/ext/commonmarker/cmark/api_test/main.c +91 -0
  7. data/ext/commonmarker/cmark/changelog.txt +24 -1
  8. data/ext/commonmarker/cmark/extensions/core-extensions.c +1 -0
  9. data/ext/commonmarker/cmark/extensions/core-extensions.h +1 -0
  10. data/ext/commonmarker/cmark/extensions/strikethrough.c +2 -1
  11. data/ext/commonmarker/cmark/extensions/table.c +1 -0
  12. data/ext/commonmarker/cmark/man/man3/cmark-gfm.3 +41 -1
  13. data/ext/commonmarker/cmark/src/CMakeLists.txt +12 -4
  14. data/ext/commonmarker/cmark/src/blocks.c +115 -3
  15. data/ext/commonmarker/cmark/src/buffer.h +0 -2
  16. data/ext/commonmarker/cmark/src/chunk.h +1 -1
  17. data/ext/commonmarker/cmark/src/cmark.c +2 -2
  18. data/ext/commonmarker/cmark/src/cmark.h +9 -0
  19. data/ext/commonmarker/cmark/src/cmark_extension_api.h +9 -7
  20. data/ext/commonmarker/cmark/src/commonmark.c +23 -0
  21. data/ext/commonmarker/cmark/src/footnotes.c +40 -0
  22. data/ext/commonmarker/cmark/src/footnotes.h +25 -0
  23. data/ext/commonmarker/cmark/src/html.c +56 -1
  24. data/ext/commonmarker/cmark/src/inlines.c +46 -25
  25. data/ext/commonmarker/cmark/src/inlines.h +2 -2
  26. data/ext/commonmarker/cmark/src/latex.c +5 -0
  27. data/ext/commonmarker/cmark/src/libcmark-gfm.pc.in +1 -1
  28. data/ext/commonmarker/cmark/src/main.c +3 -0
  29. data/ext/commonmarker/cmark/src/man.c +5 -0
  30. data/ext/commonmarker/cmark/src/map.c +122 -0
  31. data/ext/commonmarker/cmark/src/map.h +42 -0
  32. data/ext/commonmarker/cmark/src/node.c +5 -0
  33. data/ext/commonmarker/cmark/src/parser.h +1 -1
  34. data/ext/commonmarker/cmark/src/plaintext.c +1 -0
  35. data/ext/commonmarker/cmark/src/references.c +11 -125
  36. data/ext/commonmarker/cmark/src/references.h +5 -20
  37. data/ext/commonmarker/cmark/src/render.c +2 -1
  38. data/ext/commonmarker/cmark/src/render.h +3 -0
  39. data/ext/commonmarker/cmark/src/scanners.c +168 -32
  40. data/ext/commonmarker/cmark/src/scanners.h +2 -0
  41. data/ext/commonmarker/cmark/src/scanners.re +10 -0
  42. data/ext/commonmarker/cmark/src/syntax_extension.c +3 -2
  43. data/ext/commonmarker/cmark/src/syntax_extension.h +1 -0
  44. data/ext/commonmarker/cmark/test/CMakeLists.txt +7 -2
  45. data/ext/commonmarker/cmark/test/extensions.txt +59 -0
  46. data/ext/commonmarker/cmark/test/pathological_tests.py +21 -3
  47. data/ext/commonmarker/cmark/wrappers/wrapper.js +6 -0
  48. data/ext/commonmarker/commonmarker.c +14 -0
  49. data/lib/commonmarker/config.rb +1 -0
  50. data/lib/commonmarker/renderer/html_renderer.rb +41 -0
  51. data/lib/commonmarker/version.rb +1 -1
  52. data/test/test_footnotes.rb +25 -0
  53. metadata +9 -148
  54. data/ext/commonmarker/cmark/build/CMakeCache.txt +0 -481
  55. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CMakeCCompiler.cmake +0 -68
  56. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CMakeCXXCompiler.cmake +0 -70
  57. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CMakeDetermineCompilerABI_C.bin +0 -0
  58. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
  59. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CMakeSystem.cmake +0 -15
  60. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CompilerIdC/CMakeCCompilerId.c +0 -567
  61. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CompilerIdC/a.out +0 -0
  62. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -539
  63. data/ext/commonmarker/cmark/build/CMakeFiles/3.8.2/CompilerIdCXX/a.out +0 -0
  64. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CMakeCCompiler.cmake +0 -71
  65. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CMakeCXXCompiler.cmake +0 -73
  66. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CMakeDetermineCompilerABI_C.bin +0 -0
  67. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CMakeDetermineCompilerABI_CXX.bin +0 -0
  68. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CMakeSystem.cmake +0 -15
  69. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CompilerIdC/CMakeCCompilerId.c +0 -567
  70. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CompilerIdC/a.out +0 -0
  71. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -539
  72. data/ext/commonmarker/cmark/build/CMakeFiles/3.9.4/CompilerIdCXX/a.out +0 -0
  73. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
  74. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +0 -14
  75. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +0 -1169
  76. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +0 -155
  77. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +0 -391
  78. data/ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt +0 -48
  79. data/ext/commonmarker/cmark/build/CMakeFiles/cmake.check_cache +0 -1
  80. data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin +0 -0
  81. data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.c +0 -34
  82. data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.cxx +0 -405
  83. data/ext/commonmarker/cmark/build/CMakeFiles/progress.marks +0 -1
  84. data/ext/commonmarker/cmark/build/CTestTestfile.cmake +0 -11
  85. data/ext/commonmarker/cmark/build/Makefile +0 -280
  86. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
  87. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake +0 -38
  88. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +0 -169
  89. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake +0 -12
  90. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.make +0 -2
  91. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make +0 -17
  92. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +0 -1
  93. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/progress.make +0 -5
  94. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks +0 -1
  95. data/ext/commonmarker/cmark/build/api_test/Makefile +0 -302
  96. data/ext/commonmarker/cmark/build/api_test/cmake_install.cmake +0 -29
  97. data/ext/commonmarker/cmark/build/cmake_install.cmake +0 -49
  98. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
  99. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/Export/lib/cmake-gfmextensions/cmark-gfmextensions-release.cmake +0 -30
  100. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/Export/lib/cmake-gfmextensions/cmark-gfmextensions.cmake +0 -108
  101. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/DependInfo.cmake +0 -36
  102. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/build.make +0 -253
  103. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/cmake_clean.cmake +0 -16
  104. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/depend.make +0 -2
  105. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/flags.make +0 -10
  106. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/link.txt +0 -1
  107. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/progress.make +0 -8
  108. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/C.includecache +0 -236
  109. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/DependInfo.cmake +0 -29
  110. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/autolink.c.o +0 -0
  111. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/build.make +0 -249
  112. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/cmake_clean.cmake +0 -15
  113. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/cmake_clean_target.cmake +0 -3
  114. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/core-extensions.c.o +0 -0
  115. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/depend.internal +0 -102
  116. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/depend.make +0 -102
  117. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/ext_scanners.c.o +0 -0
  118. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/flags.make +0 -10
  119. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/link.txt +0 -2
  120. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/progress.make +0 -8
  121. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/strikethrough.c.o +0 -0
  122. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/table.c.o +0 -0
  123. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/tagfilter.c.o +0 -0
  124. data/ext/commonmarker/cmark/build/extensions/CMakeFiles/progress.marks +0 -1
  125. data/ext/commonmarker/cmark/build/extensions/Makefile +0 -426
  126. data/ext/commonmarker/cmark/build/extensions/cmake_install.cmake +0 -84
  127. data/ext/commonmarker/cmark/build/extensions/cmarkextensions_export.h +0 -42
  128. data/ext/commonmarker/cmark/build/extensions/libcmark-gfmextensions.a +0 -0
  129. data/ext/commonmarker/cmark/build/man/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
  130. data/ext/commonmarker/cmark/build/man/CMakeFiles/progress.marks +0 -1
  131. data/ext/commonmarker/cmark/build/man/Makefile +0 -196
  132. data/ext/commonmarker/cmark/build/man/cmake_install.cmake +0 -37
  133. data/ext/commonmarker/cmark/build/src/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
  134. data/ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake-gfm/cmark-gfm-release.cmake +0 -38
  135. data/ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake-gfm/cmark-gfm.cmake +0 -95
  136. data/ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake/cmark-release.cmake +0 -38
  137. data/ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake/cmark.cmake +0 -95
  138. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark-gfm.dir/DependInfo.cmake +0 -30
  139. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark-gfm.dir/build.make +0 -115
  140. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark-gfm.dir/cmake_clean.cmake +0 -10
  141. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark-gfm.dir/depend.make +0 -2
  142. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark-gfm.dir/flags.make +0 -10
  143. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark-gfm.dir/link.txt +0 -1
  144. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark-gfm.dir/progress.make +0 -3
  145. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm.dir/DependInfo.cmake +0 -58
  146. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm.dir/build.make +0 -765
  147. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm.dir/cmake_clean.cmake +0 -35
  148. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm.dir/depend.make +0 -2
  149. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm.dir/flags.make +0 -10
  150. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm.dir/link.txt +0 -1
  151. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm.dir/progress.make +0 -27
  152. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/C.includecache +0 -624
  153. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/DependInfo.cmake +0 -52
  154. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/arena.c.o +0 -0
  155. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/blocks.c.o +0 -0
  156. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/buffer.c.o +0 -0
  157. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/build.make +0 -762
  158. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/cmake_clean.cmake +0 -34
  159. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/cmake_clean_target.cmake +0 -3
  160. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/cmark.c.o +0 -0
  161. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/cmark_ctype.c.o +0 -0
  162. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/commonmark.c.o +0 -0
  163. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/depend.internal +0 -310
  164. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/depend.make +0 -310
  165. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/flags.make +0 -10
  166. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/houdini_href_e.c.o +0 -0
  167. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/houdini_html_e.c.o +0 -0
  168. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/houdini_html_u.c.o +0 -0
  169. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/html.c.o +0 -0
  170. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/inlines.c.o +0 -0
  171. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/iterator.c.o +0 -0
  172. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/latex.c.o +0 -0
  173. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/link.txt +0 -2
  174. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/linked_list.c.o +0 -0
  175. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/man.c.o +0 -0
  176. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/node.c.o +0 -0
  177. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/plaintext.c.o +0 -0
  178. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/plugin.c.o +0 -0
  179. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/progress.make +0 -27
  180. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/references.c.o +0 -0
  181. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/registry.c.o +0 -0
  182. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/render.c.o +0 -0
  183. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/scanners.c.o +0 -0
  184. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/syntax_extension.c.o +0 -0
  185. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/utf8.c.o +0 -0
  186. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark-gfm_static.dir/xml.c.o +0 -0
  187. data/ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks +0 -1
  188. data/ext/commonmarker/cmark/build/src/Makefile +0 -1099
  189. data/ext/commonmarker/cmark/build/src/cmake_install.cmake +0 -97
  190. data/ext/commonmarker/cmark/build/src/cmark_export.h +0 -42
  191. data/ext/commonmarker/cmark/build/src/cmark_version.h +0 -8
  192. data/ext/commonmarker/cmark/build/src/config.h +0 -76
  193. data/ext/commonmarker/cmark/build/src/libcmark-gfm.a +0 -0
  194. data/ext/commonmarker/cmark/build/src/libcmark-gfm.pc +0 -10
  195. data/ext/commonmarker/cmark/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
  196. data/ext/commonmarker/cmark/build/testdir/CMakeFiles/progress.marks +0 -1
  197. data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +0 -17
  198. data/ext/commonmarker/cmark/build/testdir/Makefile +0 -196
  199. data/ext/commonmarker/cmark/build/testdir/cmake_install.cmake +0 -29
@@ -1,38 +1,23 @@
1
1
  #ifndef CMARK_REFERENCES_H
2
2
  #define CMARK_REFERENCES_H
3
3
 
4
- #include "memory.h"
5
- #include "chunk.h"
4
+ #include "map.h"
6
5
 
7
6
  #ifdef __cplusplus
8
7
  extern "C" {
9
8
  #endif
10
9
 
11
10
  struct cmark_reference {
12
- struct cmark_reference *next;
13
- unsigned char *label;
11
+ cmark_map_entry entry;
14
12
  cmark_chunk url;
15
13
  cmark_chunk title;
16
- unsigned int age;
17
14
  };
18
15
 
19
16
  typedef struct cmark_reference cmark_reference;
20
17
 
21
- struct cmark_reference_map {
22
- cmark_mem *mem;
23
- cmark_reference *refs;
24
- cmark_reference **sorted;
25
- unsigned int size;
26
- };
27
-
28
- typedef struct cmark_reference_map cmark_reference_map;
29
-
30
- cmark_reference_map *cmark_reference_map_new(cmark_mem *mem);
31
- void cmark_reference_map_free(cmark_reference_map *map);
32
- cmark_reference *cmark_reference_lookup(cmark_reference_map *map,
33
- cmark_chunk *label);
34
- extern void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label,
35
- cmark_chunk *url, cmark_chunk *title);
18
+ void cmark_reference_create(cmark_map *map, cmark_chunk *label,
19
+ cmark_chunk *url, cmark_chunk *title);
20
+ cmark_map *cmark_reference_map_new(cmark_mem *mem);
36
21
 
37
22
  #ifdef __cplusplus
38
23
  }
@@ -174,7 +174,8 @@ char *cmark_render(cmark_mem *mem, cmark_node *root, int options, int width,
174
174
 
175
175
  cmark_renderer renderer = {mem, &buf, &pref, 0, width,
176
176
  0, 0, true, true, false,
177
- false, outc, S_cr, S_blankline, S_out};
177
+ false, outc, S_cr, S_blankline, S_out,
178
+ 0};
178
179
 
179
180
  while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
180
181
  cur = cmark_iter_get_node(iter);
@@ -28,6 +28,7 @@ struct cmark_renderer {
28
28
  void (*cr)(struct cmark_renderer *);
29
29
  void (*blankline)(struct cmark_renderer *);
30
30
  void (*out)(struct cmark_renderer *, cmark_node *, const char *, bool, cmark_escaping);
31
+ unsigned int footnote_ix;
31
32
  };
32
33
 
33
34
  typedef struct cmark_renderer cmark_renderer;
@@ -36,6 +37,8 @@ struct cmark_html_renderer {
36
37
  cmark_strbuf *html;
37
38
  cmark_node *plain;
38
39
  cmark_llist *filter_extensions;
40
+ unsigned int footnote_ix;
41
+ unsigned int written_footnote_ix;
39
42
  void *opaque;
40
43
  };
41
44
 
@@ -7887,45 +7887,35 @@ bufsize_t _scan_html_tag(const unsigned char *p) {
7887
7887
  unsigned char yych;
7888
7888
  static const unsigned char yybm[] = {
7889
7889
  /* table 1 .. 8: 0 */
7890
- 0, 239, 239, 239, 239, 239, 239, 239, 239, 238, 238, 238, 238, 238,
7890
+ 0, 239, 239, 239, 239, 239, 239, 239, 239, 238, 238, 238, 238, 238, 239,
7891
7891
  239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
7892
- 239, 239, 239, 239, 238, 239, 234, 239, 239, 239, 239, 236, 239, 239,
7893
- 239, 239, 239, 207, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
7894
- 239, 239, 239, 239, 238, 238, 174, 231, 239, 255, 255, 255, 255, 255,
7892
+ 239, 239, 239, 238, 239, 234, 239, 239, 239, 239, 236, 239, 239, 239,
7893
+ 239, 239, 207, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
7894
+ 239, 239, 239, 238, 238, 174, 231, 239, 255, 255, 255, 255, 255, 255,
7895
7895
  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
7896
- 255, 255, 255, 255, 255, 255, 255, 239, 239, 111, 239, 239, 238, 239,
7896
+ 255, 255, 255, 255, 255, 255, 239, 239, 111, 239, 239, 238, 239, 239,
7897
7897
  239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
7898
7898
  239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
7899
- 239, 239, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7900
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7901
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7902
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7903
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7904
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7905
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7906
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7907
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7908
- 0, 0, 0, 0,
7899
+ 239, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7900
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7901
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7902
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7903
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7904
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7909
7905
  /* table 9 .. 11: 256 */
7910
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64,
7911
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7912
- 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7913
- 0, 0, 0, 160, 128, 0, 160, 160, 160, 160, 160, 160, 160, 160,
7914
- 160, 160, 128, 0, 0, 0, 0, 0, 0, 160, 160, 160, 160, 160,
7906
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0,
7907
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7908
+ 160, 128, 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 128, 0,
7909
+ 0, 0, 0, 0, 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
7915
7910
  160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
7916
- 160, 160, 160, 160, 160, 160, 160, 0, 0, 0, 0, 128, 0, 160,
7911
+ 160, 0, 0, 0, 0, 128, 0, 160, 160, 160, 160, 160, 160, 160, 160, 160,
7917
7912
  160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
7918
- 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 0, 0, 0,
7919
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7920
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7921
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7922
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7923
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7924
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7925
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7926
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7927
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7928
- 0, 0, 0, 0,
7913
+ 160, 160, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7914
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7915
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7916
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7917
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7918
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7929
7919
  };
7930
7920
  yych = *p;
7931
7921
  if (yych <= '>') {
@@ -18057,3 +18047,149 @@ bufsize_t _scan_dangerous_url(const unsigned char *p) {
18057
18047
  goto yy1188;
18058
18048
  }
18059
18049
  }
18050
+
18051
+ // Scans a footnote definition opening.
18052
+ bufsize_t _scan_footnote_definition(const unsigned char *p) {
18053
+ const unsigned char *marker = NULL;
18054
+ const unsigned char *start = p;
18055
+
18056
+ {
18057
+ unsigned char yych;
18058
+ static const unsigned char yybm[] = {
18059
+ 0, 64, 64, 64, 64, 64, 64, 64, 64, 128, 0, 64, 64, 0, 64, 64,
18060
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
18061
+ 128, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
18062
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
18063
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
18064
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 64, 64,
18065
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
18066
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
18067
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18068
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18069
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18070
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18071
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18072
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18073
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18074
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18075
+ };
18076
+ yych = *p;
18077
+ if (yych == '[')
18078
+ goto yy1235;
18079
+ ++p;
18080
+ yy1234 : { return 0; }
18081
+ yy1235:
18082
+ yych = *(marker = ++p);
18083
+ if (yych != '^')
18084
+ goto yy1234;
18085
+ yych = *++p;
18086
+ if (yych != ']')
18087
+ goto yy1239;
18088
+ yy1237:
18089
+ p = marker;
18090
+ goto yy1234;
18091
+ yy1238:
18092
+ ++p;
18093
+ yych = *p;
18094
+ yy1239:
18095
+ if (yybm[0 + yych] & 64) {
18096
+ goto yy1238;
18097
+ }
18098
+ if (yych <= 0xEC) {
18099
+ if (yych <= 0xC1) {
18100
+ if (yych <= ' ')
18101
+ goto yy1237;
18102
+ if (yych <= ']')
18103
+ goto yy1247;
18104
+ goto yy1237;
18105
+ } else {
18106
+ if (yych <= 0xDF)
18107
+ goto yy1240;
18108
+ if (yych <= 0xE0)
18109
+ goto yy1241;
18110
+ goto yy1242;
18111
+ }
18112
+ } else {
18113
+ if (yych <= 0xF0) {
18114
+ if (yych <= 0xED)
18115
+ goto yy1246;
18116
+ if (yych <= 0xEF)
18117
+ goto yy1242;
18118
+ goto yy1243;
18119
+ } else {
18120
+ if (yych <= 0xF3)
18121
+ goto yy1244;
18122
+ if (yych <= 0xF4)
18123
+ goto yy1245;
18124
+ goto yy1237;
18125
+ }
18126
+ }
18127
+ yy1240:
18128
+ ++p;
18129
+ yych = *p;
18130
+ if (yych <= 0x7F)
18131
+ goto yy1237;
18132
+ if (yych <= 0xBF)
18133
+ goto yy1238;
18134
+ goto yy1237;
18135
+ yy1241:
18136
+ ++p;
18137
+ yych = *p;
18138
+ if (yych <= 0x9F)
18139
+ goto yy1237;
18140
+ if (yych <= 0xBF)
18141
+ goto yy1240;
18142
+ goto yy1237;
18143
+ yy1242:
18144
+ ++p;
18145
+ yych = *p;
18146
+ if (yych <= 0x7F)
18147
+ goto yy1237;
18148
+ if (yych <= 0xBF)
18149
+ goto yy1240;
18150
+ goto yy1237;
18151
+ yy1243:
18152
+ ++p;
18153
+ yych = *p;
18154
+ if (yych <= 0x8F)
18155
+ goto yy1237;
18156
+ if (yych <= 0xBF)
18157
+ goto yy1242;
18158
+ goto yy1237;
18159
+ yy1244:
18160
+ ++p;
18161
+ yych = *p;
18162
+ if (yych <= 0x7F)
18163
+ goto yy1237;
18164
+ if (yych <= 0xBF)
18165
+ goto yy1242;
18166
+ goto yy1237;
18167
+ yy1245:
18168
+ ++p;
18169
+ yych = *p;
18170
+ if (yych <= 0x7F)
18171
+ goto yy1237;
18172
+ if (yych <= 0x8F)
18173
+ goto yy1242;
18174
+ goto yy1237;
18175
+ yy1246:
18176
+ ++p;
18177
+ yych = *p;
18178
+ if (yych <= 0x7F)
18179
+ goto yy1237;
18180
+ if (yych <= 0x9F)
18181
+ goto yy1240;
18182
+ goto yy1237;
18183
+ yy1247:
18184
+ yych = *++p;
18185
+ if (yych != ':')
18186
+ goto yy1237;
18187
+ yy1248:
18188
+ ++p;
18189
+ yych = *p;
18190
+ if (yybm[0 + yych] & 128) {
18191
+ goto yy1248;
18192
+ }
18193
+ { return (bufsize_t)(p - start); }
18194
+ }
18195
+ }
@@ -31,6 +31,7 @@ bufsize_t _scan_open_code_fence(const unsigned char *p);
31
31
  bufsize_t _scan_close_code_fence(const unsigned char *p);
32
32
  bufsize_t _scan_entity(const unsigned char *p);
33
33
  bufsize_t _scan_dangerous_url(const unsigned char *p);
34
+ bufsize_t _scan_footnote_definition(const unsigned char *p);
34
35
 
35
36
  #define scan_scheme(c, n) _scan_at(&_scan_scheme, c, n)
36
37
  #define scan_autolink_uri(c, n) _scan_at(&_scan_autolink_uri, c, n)
@@ -54,6 +55,7 @@ bufsize_t _scan_dangerous_url(const unsigned char *p);
54
55
  #define scan_close_code_fence(c, n) _scan_at(&_scan_close_code_fence, c, n)
55
56
  #define scan_entity(c, n) _scan_at(&_scan_entity, c, n)
56
57
  #define scan_dangerous_url(c, n) _scan_at(&_scan_dangerous_url, c, n)
58
+ #define scan_footnote_definition(c, n) _scan_at(&_scan_footnote_definition, c, n)
57
59
 
58
60
  #ifdef __cplusplus
59
61
  }
@@ -329,3 +329,13 @@ bufsize_t _scan_dangerous_url(const unsigned char *p)
329
329
  */
330
330
  }
331
331
 
332
+ // Scans a footnote definition opening.
333
+ bufsize_t _scan_footnote_definition(const unsigned char *p)
334
+ {
335
+ const unsigned char *marker = NULL;
336
+ const unsigned char *start = p;
337
+ /*!re2c
338
+ '[^' ([^\] \r\n\x00\t]+) ']:' [ \t]* { return (bufsize_t)(p - start); }
339
+ * { return 0; }
340
+ */
341
+ }
@@ -1,4 +1,5 @@
1
1
  #include <stdlib.h>
2
+ #include <assert.h>
2
3
 
3
4
  #include "cmark.h"
4
5
  #include "syntax_extension.h"
@@ -37,8 +38,8 @@ cmark_node_type cmark_syntax_extension_add_node(int is_inline) {
37
38
  }
38
39
 
39
40
  void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension,
40
- bool emphasis) {
41
- extension->emphasis = emphasis;
41
+ int emphasis) {
42
+ extension->emphasis = emphasis == 1;
42
43
  }
43
44
 
44
45
  void cmark_syntax_extension_set_open_block_func(cmark_syntax_extension *extension,
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include "cmark.h"
5
5
  #include "cmark_extension_api.h"
6
+ #include "config.h"
6
7
 
7
8
  struct cmark_syntax_extension {
8
9
  cmark_match_block_func last_block_matches;
@@ -64,14 +64,19 @@ IF (PYTHONINTERP_FOUND)
64
64
  )
65
65
 
66
66
  add_test(extensions_executable
67
- ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${CMAKE_CURRENT_SOURCE_DIR}/extensions.txt" "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark-gfm" "--extensions" "table strikethrough autolink tagfilter"
67
+ ${PYTHON_EXECUTABLE}
68
+ "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py"
69
+ "--no-normalize"
70
+ "--spec" "${CMAKE_CURRENT_SOURCE_DIR}/extensions.txt"
71
+ "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark-gfm --footnotes"
72
+ "--extensions" "table strikethrough autolink tagfilter"
68
73
  )
69
74
 
70
75
  add_test(roundtrip_extensions_executable
71
76
  ${PYTHON_EXECUTABLE}
72
77
  "${CMAKE_CURRENT_SOURCE_DIR}/roundtrip_tests.py"
73
78
  "--spec" "${CMAKE_CURRENT_SOURCE_DIR}/extensions.txt"
74
- "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark-gfm"
79
+ "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark-gfm --footnotes"
75
80
  "--extensions" "table strikethrough autolink tagfilter"
76
81
  )
77
82
 
@@ -579,6 +579,65 @@ Even with {"x":"y"} or 1 > 2 or whatever. Even **markdown**.
579
579
  <!--thistoo-->
580
580
  ````````````````````````````````
581
581
 
582
+ ## Footnotes
583
+
584
+ ```````````````````````````````` example
585
+ This is some text.[^1]. Other text.[^footnote].
586
+
587
+ Here's a thing[^other-note].
588
+
589
+ And another thing[^codeblock-note].
590
+
591
+ This doesn't have a referent[^nope].
592
+
593
+
594
+ [^other-note]: no code block here (spaces are stripped away)
595
+
596
+ [^codeblock-note]:
597
+ this is now a code block (8 spaces indentation)
598
+
599
+ [^1]: Some *bolded* footnote definition.
600
+
601
+ Hi!
602
+
603
+ [^footnote]:
604
+ > Blockquotes can be in a footnote.
605
+
606
+ as well as code blocks
607
+
608
+ or, naturally, simple paragraphs.
609
+
610
+ [^unused]: This is unused.
611
+ .
612
+ <p>This is some text.<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup>. Other text.<sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup>.</p>
613
+ <p>Here's a thing<sup class="footnote-ref"><a href="#fn3" id="fnref3">[3]</a></sup>.</p>
614
+ <p>And another thing<sup class="footnote-ref"><a href="#fn4" id="fnref4">[4]</a></sup>.</p>
615
+ <p>This doesn't have a referent[^nope].</p>
616
+ <p>Hi!</p>
617
+ <section class="footnotes">
618
+ <ol>
619
+ <li id="fn1">
620
+ <p>Some <em>bolded</em> footnote definition. <a href="#fnref1" class="footnote-backref">↩</a></p>
621
+ </li>
622
+ <li id="fn2">
623
+ <blockquote>
624
+ <p>Blockquotes can be in a footnote.</p>
625
+ </blockquote>
626
+ <pre><code>as well as code blocks
627
+ </code></pre>
628
+ <p>or, naturally, simple paragraphs. <a href="#fnref2" class="footnote-backref">↩</a></p>
629
+ </li>
630
+ <li id="fn3">
631
+ <p>no code block here (spaces are stripped away) <a href="#fnref3" class="footnote-backref">↩</a></p>
632
+ </li>
633
+ <li id="fn4">
634
+ <pre><code>this is now a code block (8 spaces indentation)
635
+ </code></pre>
636
+ <a href="#fnref4" class="footnote-backref">↩</a>
637
+ </li>
638
+ </ol>
639
+ </section>
640
+ ````````````````````````````````
582
641
 
583
642
  ## Interop
584
643
 
@@ -31,6 +31,8 @@ def hash_collisions():
31
31
 
32
32
  return document, re.compile("(<p>\[%s\]</p>\n){%d}" % (bad_key, COUNT-1))
33
33
 
34
+ allowed_failures = {"many references": True}
35
+
34
36
  # list of pairs consisting of input and a regex that must match the output.
35
37
  pathological = {
36
38
  # note - some pythons have limit of 65535 for {num-matches} in re.
@@ -73,12 +75,22 @@ pathological = {
73
75
  "backticks":
74
76
  ("".join(map(lambda x: ("e" + "`" * x), range(1,10000))),
75
77
  re.compile("^<p>[e`]*</p>\n$")),
78
+ "unclosed links A":
79
+ ("[a](<b" * 50000,
80
+ re.compile("(\[a\]\(&lt;b){50000}")),
81
+ "unclosed links B":
82
+ ("[a](b" * 50000,
83
+ re.compile("(\[a\]\(b){50000}")),
84
+ "many references":
85
+ ("".join(map(lambda x: ("[" + str(x) + "]: u\n"), range(1,50000 * 16))) + "[0] " * 50000,
86
+ re.compile("(\[0\] ){49999}")),
76
87
  "reference collisions": hash_collisions()
77
88
  }
78
89
 
79
90
  whitespace_re = re.compile('/s+/')
80
91
  passed = 0
81
92
  errored = 0
93
+ ignored = 0
82
94
  TIMEOUT = 5
83
95
 
84
96
  def run_test(inp, regex):
@@ -117,11 +129,17 @@ if __name__ == '__main__':
117
129
  p.terminate()
118
130
  p.join()
119
131
  print('[TIMED OUT]')
120
- errored += 1
132
+ if allowed_failures[description]:
133
+ ignored += 1
134
+ else:
135
+ errored += 1
121
136
  elif p.exitcode != 0:
122
- errored += 1
137
+ if allowed_failures[description]:
138
+ ignored += 1
139
+ else:
140
+ errored += 1
123
141
  else:
124
142
  passed += 1
125
143
 
126
- print("%d passed, %d errored" % (passed, errored))
144
+ print("%d passed, %d errored, %d ignored" % (passed, errored, ignored))
127
145
  exit(errored)