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
@@ -13,8 +13,6 @@
13
13
  extern "C" {
14
14
  #endif
15
15
 
16
- typedef int32_t bufsize_t;
17
-
18
16
  typedef struct {
19
17
  cmark_mem *mem;
20
18
  unsigned char *ptr;
@@ -12,7 +12,7 @@
12
12
  #define CMARK_CHUNK_EMPTY \
13
13
  { NULL, 0, 0 }
14
14
 
15
- typedef struct {
15
+ typedef struct cmark_chunk {
16
16
  unsigned char *data;
17
17
  bufsize_t len;
18
18
  bufsize_t alloc; // also implies a NULL-terminated string
@@ -7,8 +7,8 @@
7
7
  #include "cmark.h"
8
8
  #include "buffer.h"
9
9
 
10
- cmark_node_type CMARK_NODE_LAST_BLOCK = CMARK_NODE_THEMATIC_BREAK;
11
- cmark_node_type CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE;
10
+ cmark_node_type CMARK_NODE_LAST_BLOCK = CMARK_NODE_FOOTNOTE_DEFINITION;
11
+ cmark_node_type CMARK_NODE_LAST_INLINE = CMARK_NODE_FOOTNOTE_REFERENCE;
12
12
 
13
13
  int cmark_version() { return CMARK_VERSION; }
14
14
 
@@ -2,6 +2,7 @@
2
2
  #define CMARK_CMARK_H
3
3
 
4
4
  #include <stdio.h>
5
+ #include <stdint.h>
5
6
  #include "cmark_export.h"
6
7
  #include "cmark_version.h"
7
8
 
@@ -51,6 +52,7 @@ typedef enum {
51
52
  CMARK_NODE_PARAGRAPH = CMARK_NODE_TYPE_BLOCK | 0x0008,
52
53
  CMARK_NODE_HEADING = CMARK_NODE_TYPE_BLOCK | 0x0009,
53
54
  CMARK_NODE_THEMATIC_BREAK = CMARK_NODE_TYPE_BLOCK | 0x000a,
55
+ CMARK_NODE_FOOTNOTE_DEFINITION = CMARK_NODE_TYPE_BLOCK | 0x000b,
54
56
 
55
57
  /* Inline */
56
58
  CMARK_NODE_TEXT = CMARK_NODE_TYPE_INLINE | 0x0001,
@@ -63,6 +65,7 @@ typedef enum {
63
65
  CMARK_NODE_STRONG = CMARK_NODE_TYPE_INLINE | 0x0008,
64
66
  CMARK_NODE_LINK = CMARK_NODE_TYPE_INLINE | 0x0009,
65
67
  CMARK_NODE_IMAGE = CMARK_NODE_TYPE_INLINE | 0x000a,
68
+ CMARK_NODE_FOOTNOTE_REFERENCE = CMARK_NODE_TYPE_INLINE | 0x000b,
66
69
  } cmark_node_type;
67
70
 
68
71
  extern cmark_node_type CMARK_NODE_LAST_BLOCK;
@@ -717,6 +720,10 @@ char *cmark_render_latex_with_mem(cmark_node *root, int options, int width, cmar
717
720
  */
718
721
  #define CMARK_OPT_LIBERAL_HTML_TAG (1 << 12)
719
722
 
723
+ /** Parse footnotes.
724
+ */
725
+ #define CMARK_OPT_FOOTNOTES (1 << 13)
726
+
720
727
  /**
721
728
  * ## Version information
722
729
  */
@@ -773,6 +780,8 @@ const char *cmark_version_string(void);
773
780
  #define PAREN_DELIM CMARK_PAREN_DELIM
774
781
  #endif
775
782
 
783
+ typedef int32_t bufsize_t;
784
+
776
785
  #ifdef __cplusplus
777
786
  }
778
787
  #endif
@@ -6,8 +6,10 @@ extern "C" {
6
6
  #endif
7
7
 
8
8
  #include <cmark.h>
9
- #include <render.h>
10
- #include <buffer.h>
9
+
10
+ struct cmark_renderer;
11
+ struct cmark_html_renderer;
12
+ struct cmark_chunk;
11
13
 
12
14
  /**
13
15
  * ## Extension Support
@@ -227,7 +229,7 @@ typedef int (*cmark_contains_inlines_func) (cmark_syntax_extension *extension,
227
229
  cmark_node *node);
228
230
 
229
231
  typedef void (*cmark_common_render_func) (cmark_syntax_extension *extension,
230
- cmark_renderer *renderer,
232
+ struct cmark_renderer *renderer,
231
233
  cmark_node *node,
232
234
  cmark_event_type ev_type,
233
235
  int options);
@@ -237,7 +239,7 @@ typedef int (*cmark_commonmark_escape_func) (cmark_syntax_extension *extension,
237
239
  int c);
238
240
 
239
241
  typedef void (*cmark_html_render_func) (cmark_syntax_extension *extension,
240
- cmark_html_renderer *renderer,
242
+ struct cmark_html_renderer *renderer,
241
243
  cmark_node *node,
242
244
  cmark_event_type ev_type,
243
245
  int options);
@@ -270,7 +272,7 @@ CMARK_EXPORT
270
272
  cmark_node_type cmark_syntax_extension_add_node(int is_inline);
271
273
 
272
274
  CMARK_EXPORT
273
- void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension, bool emphasis);
275
+ void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension, int emphasis);
274
276
 
275
277
  /** See the documentation for 'cmark_syntax_extension'
276
278
  */
@@ -614,7 +616,7 @@ void cmark_inline_parser_set_offset(cmark_inline_parser *parser, int offset);
614
616
  * Use cmark_inline_parser_get_offset to get our current position in the chunk.
615
617
  */
616
618
  CMARK_EXPORT
617
- cmark_chunk *cmark_inline_parser_get_chunk(cmark_inline_parser *parser);
619
+ struct cmark_chunk *cmark_inline_parser_get_chunk(cmark_inline_parser *parser);
618
620
 
619
621
  /** Returns 1 if the inline parser is currently in a bracket; pass 1 for 'image'
620
622
  * if you want to know about an image-type bracket, 0 for link-type. */
@@ -699,7 +701,7 @@ int cmark_inline_parser_scan_delimiters(cmark_inline_parser *parser,
699
701
  int *punct_after);
700
702
 
701
703
  CMARK_EXPORT
702
- void cmark_manage_extensions_special_characters(cmark_parser *parser, bool add);
704
+ void cmark_manage_extensions_special_characters(cmark_parser *parser, int add);
703
705
 
704
706
  CMARK_EXPORT
705
707
  cmark_llist *cmark_parser_get_syntax_extensions(cmark_parser *parser);
@@ -463,6 +463,29 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
463
463
  }
464
464
  break;
465
465
 
466
+ case CMARK_NODE_FOOTNOTE_REFERENCE:
467
+ if (entering) {
468
+ LIT("[^");
469
+ OUT(cmark_chunk_to_cstr(renderer->mem, &node->as.literal), false, LITERAL);
470
+ LIT("]");
471
+ }
472
+ break;
473
+
474
+ case CMARK_NODE_FOOTNOTE_DEFINITION:
475
+ if (entering) {
476
+ renderer->footnote_ix += 1;
477
+ LIT("[^");
478
+ char n[32];
479
+ snprintf(n, sizeof(n), "%d", renderer->footnote_ix);
480
+ OUT(n, false, LITERAL);
481
+ LIT("]:\n");
482
+
483
+ cmark_strbuf_puts(renderer->prefix, " ");
484
+ } else {
485
+ cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 4);
486
+ }
487
+ break;
488
+
466
489
  default:
467
490
  assert(false);
468
491
  break;
@@ -0,0 +1,40 @@
1
+ #include "cmark.h"
2
+ #include "parser.h"
3
+ #include "footnotes.h"
4
+ #include "inlines.h"
5
+ #include "chunk.h"
6
+
7
+ static void footnote_free(cmark_map *map, cmark_map_entry *_ref) {
8
+ cmark_footnote *ref = (cmark_footnote *)_ref;
9
+ cmark_mem *mem = map->mem;
10
+ if (ref != NULL) {
11
+ mem->free(ref->entry.label);
12
+ if (ref->node)
13
+ cmark_node_free(ref->node);
14
+ mem->free(ref);
15
+ }
16
+ }
17
+
18
+ void cmark_footnote_create(cmark_map *map, cmark_node *node) {
19
+ cmark_footnote *ref;
20
+ unsigned char *reflabel = normalize_map_label(map->mem, &node->as.literal);
21
+
22
+ /* empty footnote name, or composed from only whitespace */
23
+ if (reflabel == NULL)
24
+ return;
25
+
26
+ assert(map->sorted == NULL);
27
+
28
+ ref = (cmark_footnote *)map->mem->calloc(1, sizeof(*ref));
29
+ ref->entry.label = reflabel;
30
+ ref->node = node;
31
+ ref->entry.age = map->size;
32
+ ref->entry.next = map->refs;
33
+
34
+ map->refs = (cmark_map_entry *)ref;
35
+ map->size++;
36
+ }
37
+
38
+ cmark_map *cmark_footnote_map_new(cmark_mem *mem) {
39
+ return cmark_map_new(mem, footnote_free);
40
+ }
@@ -0,0 +1,25 @@
1
+ #ifndef CMARK_FOOTNOTES_H
2
+ #define CMARK_FOOTNOTES_H
3
+
4
+ #include "map.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ struct cmark_footnote {
11
+ cmark_map_entry entry;
12
+ cmark_node *node;
13
+ unsigned int ix;
14
+ };
15
+
16
+ typedef struct cmark_footnote cmark_footnote;
17
+
18
+ void cmark_footnote_create(cmark_map *map, cmark_node *node);
19
+ cmark_map *cmark_footnote_map_new(cmark_mem *mem);
20
+
21
+ #ifdef __cplusplus
22
+ }
23
+ #endif
24
+
25
+ #endif
@@ -9,6 +9,7 @@
9
9
  #include "scanners.h"
10
10
  #include "syntax_extension.h"
11
11
  #include "html.h"
12
+ #include "render.h"
12
13
 
13
14
  // Functions to convert cmark_nodes to HTML strings.
14
15
 
@@ -58,6 +59,20 @@ static void filter_html_block(cmark_html_renderer *renderer, uint8_t *data, size
58
59
  cmark_strbuf_put(html, data, (bufsize_t)len);
59
60
  }
60
61
 
62
+ static bool S_put_footnote_backref(cmark_html_renderer *renderer, cmark_strbuf *html) {
63
+ if (renderer->written_footnote_ix >= renderer->footnote_ix)
64
+ return false;
65
+ renderer->written_footnote_ix = renderer->footnote_ix;
66
+
67
+ cmark_strbuf_puts(html, "<a href=\"#fnref");
68
+ char n[32];
69
+ snprintf(n, sizeof(n), "%d", renderer->footnote_ix);
70
+ cmark_strbuf_puts(html, n);
71
+ cmark_strbuf_puts(html, "\" class=\"footnote-backref\">↩</a>");
72
+
73
+ return true;
74
+ }
75
+
61
76
  static int S_render_node(cmark_html_renderer *renderer, cmark_node *node,
62
77
  cmark_event_type ev_type, int options) {
63
78
  cmark_node *parent;
@@ -248,6 +263,10 @@ static int S_render_node(cmark_html_renderer *renderer, cmark_node *node,
248
263
  cmark_html_render_sourcepos(node, html, options);
249
264
  cmark_strbuf_putc(html, '>');
250
265
  } else {
266
+ if (parent->type == CMARK_NODE_FOOTNOTE_DEFINITION && node->next == NULL) {
267
+ cmark_strbuf_putc(html, ' ');
268
+ S_put_footnote_backref(renderer, html);
269
+ }
251
270
  cmark_strbuf_puts(html, "</p>\n");
252
271
  }
253
272
  }
@@ -362,6 +381,37 @@ static int S_render_node(cmark_html_renderer *renderer, cmark_node *node,
362
381
  }
363
382
  break;
364
383
 
384
+ case CMARK_NODE_FOOTNOTE_DEFINITION:
385
+ if (entering) {
386
+ if (renderer->footnote_ix == 0) {
387
+ cmark_strbuf_puts(html, "<section class=\"footnotes\">\n<ol>\n");
388
+ }
389
+ ++renderer->footnote_ix;
390
+ cmark_strbuf_puts(html, "<li id=\"fn");
391
+ char n[32];
392
+ snprintf(n, sizeof(n), "%d", renderer->footnote_ix);
393
+ cmark_strbuf_puts(html, n);
394
+ cmark_strbuf_puts(html, "\">\n");
395
+ } else {
396
+ if (S_put_footnote_backref(renderer, html)) {
397
+ cmark_strbuf_putc(html, '\n');
398
+ }
399
+ cmark_strbuf_puts(html, "</li>\n");
400
+ }
401
+ break;
402
+
403
+ case CMARK_NODE_FOOTNOTE_REFERENCE:
404
+ if (entering) {
405
+ cmark_strbuf_puts(html, "<sup class=\"footnote-ref\"><a href=\"#fn");
406
+ cmark_strbuf_put(html, node->as.literal.data, node->as.literal.len);
407
+ cmark_strbuf_puts(html, "\" id=\"fnref");
408
+ cmark_strbuf_put(html, node->as.literal.data, node->as.literal.len);
409
+ cmark_strbuf_puts(html, "\">[");
410
+ cmark_strbuf_put(html, node->as.literal.data, node->as.literal.len);
411
+ cmark_strbuf_puts(html, "]</a></sup>");
412
+ }
413
+ break;
414
+
365
415
  default:
366
416
  assert(false);
367
417
  break;
@@ -379,7 +429,7 @@ char *cmark_render_html_with_mem(cmark_node *root, int options, cmark_llist *ext
379
429
  cmark_strbuf html = CMARK_BUF_INIT(mem);
380
430
  cmark_event_type ev_type;
381
431
  cmark_node *cur;
382
- cmark_html_renderer renderer = {&html, NULL, NULL, NULL};
432
+ cmark_html_renderer renderer = {&html, NULL, NULL, 0, 0, NULL};
383
433
  cmark_iter *iter = cmark_iter_new(root);
384
434
 
385
435
  for (; extensions; extensions = extensions->next)
@@ -393,6 +443,11 @@ char *cmark_render_html_with_mem(cmark_node *root, int options, cmark_llist *ext
393
443
  cur = cmark_iter_get_node(iter);
394
444
  S_render_node(&renderer, cur, ev_type, options);
395
445
  }
446
+
447
+ if (renderer.footnote_ix) {
448
+ cmark_strbuf_puts(&html, "</ol>\n</section>\n");
449
+ }
450
+
396
451
  result = (char *)cmark_strbuf_detach(&html);
397
452
 
398
453
  cmark_llist_free(mem, renderer.filter_extensions);
@@ -50,7 +50,7 @@ typedef struct subject{
50
50
  bufsize_t pos;
51
51
  int block_offset;
52
52
  int column_offset;
53
- cmark_reference_map *refmap;
53
+ cmark_map *refmap;
54
54
  delimiter *last_delim;
55
55
  bracket *last_bracket;
56
56
  bufsize_t backticks[MAXBACKTICKS + 1];
@@ -70,7 +70,7 @@ static delimiter *S_insert_emph(subject *subj, delimiter *opener,
70
70
  static int parse_inline(cmark_parser *parser, subject *subj, cmark_node *parent, int options);
71
71
 
72
72
  static void subject_from_buf(cmark_mem *mem, int line_number, int block_offset, subject *e,
73
- cmark_chunk *buffer, cmark_reference_map *refmap);
73
+ cmark_chunk *buffer, cmark_map *refmap);
74
74
  static bufsize_t subject_find_special_char(subject *subj, int options);
75
75
 
76
76
  // Create an inline with a literal string value.
@@ -157,7 +157,7 @@ static CMARK_INLINE cmark_node *make_autolink(subject *subj,
157
157
  }
158
158
 
159
159
  static void subject_from_buf(cmark_mem *mem, int line_number, int block_offset, subject *e,
160
- cmark_chunk *chunk, cmark_reference_map *refmap) {
160
+ cmark_chunk *chunk, cmark_map *refmap) {
161
161
  int i;
162
162
  e->mem = mem;
163
163
  e->input = *chunk;
@@ -793,7 +793,7 @@ cmark_chunk cmark_clean_url(cmark_mem *mem, cmark_chunk *url) {
793
793
  return result;
794
794
  }
795
795
 
796
- houdini_unescape_html_f(&buf, url->data, url->len);
796
+ houdini_unescape_html_f(&buf, url->data, url->len);
797
797
 
798
798
  cmark_strbuf_unescape(&buf);
799
799
  return cmark_chunk_buf_detach(&buf);
@@ -925,26 +925,26 @@ static bufsize_t manual_scan_link_url_2(cmark_chunk *input, bufsize_t offset,
925
925
  bufsize_t i = offset;
926
926
  size_t nb_p = 0;
927
927
 
928
- while (i < input->len) {
929
- if (input->data[i] == '\\' &&
930
- i + 1 < input-> len &&
931
- cmark_ispunct(input->data[i+1]))
932
- i += 2;
933
- else if (input->data[i] == '(') {
934
- ++nb_p;
935
- ++i;
928
+ while (i < input->len) {
929
+ if (input->data[i] == '\\' &&
930
+ i + 1 < input-> len &&
931
+ cmark_ispunct(input->data[i+1]))
932
+ i += 2;
933
+ else if (input->data[i] == '(') {
934
+ ++nb_p;
935
+ ++i;
936
936
  if (nb_p > 32)
937
937
  return -1;
938
- } else if (input->data[i] == ')') {
939
- if (nb_p == 0)
940
- break;
941
- --nb_p;
942
- ++i;
943
- } else if (cmark_isspace(input->data[i]))
938
+ } else if (input->data[i] == ')') {
939
+ if (nb_p == 0)
944
940
  break;
945
- else
946
- ++i;
947
- }
941
+ --nb_p;
942
+ ++i;
943
+ } else if (cmark_isspace(input->data[i]))
944
+ break;
945
+ else
946
+ ++i;
947
+ }
948
948
 
949
949
  if (i >= input->len)
950
950
  return -1;
@@ -1076,7 +1076,7 @@ static cmark_node *handle_close_bracket(cmark_parser *parser, subject *subj) {
1076
1076
  }
1077
1077
 
1078
1078
  if (found_label) {
1079
- ref = cmark_reference_lookup(subj->refmap, &raw_label);
1079
+ ref = (cmark_reference *)cmark_map_lookup(subj->refmap, &raw_label);
1080
1080
  cmark_chunk_free(subj->mem, &raw_label);
1081
1081
  }
1082
1082
 
@@ -1089,7 +1089,28 @@ static cmark_node *handle_close_bracket(cmark_parser *parser, subject *subj) {
1089
1089
  }
1090
1090
 
1091
1091
  noMatch:
1092
- // If we fall through to here, it means we didn't match a link:
1092
+ // If we fall through to here, it means we didn't match a link.
1093
+ // What if we're a footnote link?
1094
+ if (parser->options & CMARK_OPT_FOOTNOTES &&
1095
+ opener->inl_text->next &&
1096
+ opener->inl_text->next->type == CMARK_NODE_TEXT &&
1097
+ !opener->inl_text->next->next) {
1098
+ cmark_chunk *literal = &opener->inl_text->next->as.literal;
1099
+ if (literal->len > 1 && literal->data[0] == '^') {
1100
+ inl = make_simple(subj->mem, CMARK_NODE_FOOTNOTE_REFERENCE);
1101
+ inl->as.literal = cmark_chunk_dup(literal, 1, literal->len - 1);
1102
+ inl->start_line = inl->end_line = subj->line;
1103
+ inl->start_column = opener->inl_text->start_column;
1104
+ inl->end_column = subj->pos + subj->column_offset + subj->block_offset;
1105
+ cmark_node_insert_before(opener->inl_text, inl);
1106
+ cmark_node_free(opener->inl_text->next);
1107
+ cmark_node_free(opener->inl_text);
1108
+ process_emphasis(parser, subj, opener->previous_delimiter);
1109
+ pop_bracket(subj);
1110
+ return NULL;
1111
+ }
1112
+ }
1113
+
1093
1114
  pop_bracket(subj); // remove this opener from delimiter list
1094
1115
  subj->pos = initial_pos;
1095
1116
  return make_str(subj, subj->pos - 1, subj->pos - 1, cmark_chunk_literal("]"));
@@ -1317,7 +1338,7 @@ static int parse_inline(cmark_parser *parser, subject *subj, cmark_node *parent,
1317
1338
  // Parse inlines from parent's string_content, adding as children of parent.
1318
1339
  void cmark_parse_inlines(cmark_parser *parser,
1319
1340
  cmark_node *parent,
1320
- cmark_reference_map *refmap,
1341
+ cmark_map *refmap,
1321
1342
  int options) {
1322
1343
  subject subj;
1323
1344
  cmark_chunk content = {parent->content.ptr, parent->content.size, 0};
@@ -1350,7 +1371,7 @@ static void spnl(subject *subj) {
1350
1371
  // Return 0 if no reference found, otherwise position of subject
1351
1372
  // after reference is parsed.
1352
1373
  bufsize_t cmark_parse_reference_inline(cmark_mem *mem, cmark_chunk *input,
1353
- cmark_reference_map *refmap) {
1374
+ cmark_map *refmap) {
1354
1375
  subject subj;
1355
1376
 
1356
1377
  cmark_chunk lab;