commonmarker 0.23.10 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +1220 -0
  3. data/Cargo.toml +7 -0
  4. data/README.md +217 -170
  5. data/ext/commonmarker/Cargo.toml +20 -0
  6. data/ext/commonmarker/extconf.rb +3 -6
  7. data/ext/commonmarker/src/lib.rs +183 -0
  8. data/ext/commonmarker/src/node.rs +1095 -0
  9. data/ext/commonmarker/src/options.rs +165 -0
  10. data/ext/commonmarker/src/plugins/syntax_highlighting.rs +74 -0
  11. data/ext/commonmarker/src/plugins.rs +3 -0
  12. data/ext/commonmarker/src/utils.rs +8 -0
  13. data/lib/commonmarker/config.rb +90 -40
  14. data/lib/commonmarker/constants.rb +7 -0
  15. data/lib/commonmarker/extension.rb +14 -0
  16. data/lib/commonmarker/node/ast.rb +8 -0
  17. data/lib/commonmarker/node/inspect.rb +14 -4
  18. data/lib/commonmarker/node.rb +29 -47
  19. data/lib/commonmarker/renderer.rb +1 -127
  20. data/lib/commonmarker/utils.rb +22 -0
  21. data/lib/commonmarker/version.rb +2 -2
  22. data/lib/commonmarker.rb +27 -25
  23. metadata +38 -186
  24. data/Rakefile +0 -109
  25. data/bin/commonmarker +0 -118
  26. data/commonmarker.gemspec +0 -38
  27. data/ext/commonmarker/arena.c +0 -104
  28. data/ext/commonmarker/autolink.c +0 -508
  29. data/ext/commonmarker/autolink.h +0 -8
  30. data/ext/commonmarker/blocks.c +0 -1622
  31. data/ext/commonmarker/buffer.c +0 -278
  32. data/ext/commonmarker/buffer.h +0 -116
  33. data/ext/commonmarker/case_fold_switch.inc +0 -4327
  34. data/ext/commonmarker/chunk.h +0 -135
  35. data/ext/commonmarker/cmark-gfm-core-extensions.h +0 -54
  36. data/ext/commonmarker/cmark-gfm-extension_api.h +0 -737
  37. data/ext/commonmarker/cmark-gfm-extensions_export.h +0 -42
  38. data/ext/commonmarker/cmark-gfm.h +0 -833
  39. data/ext/commonmarker/cmark-gfm_export.h +0 -42
  40. data/ext/commonmarker/cmark-gfm_version.h +0 -7
  41. data/ext/commonmarker/cmark.c +0 -55
  42. data/ext/commonmarker/cmark_ctype.c +0 -44
  43. data/ext/commonmarker/cmark_ctype.h +0 -33
  44. data/ext/commonmarker/commonmark.c +0 -514
  45. data/ext/commonmarker/commonmarker.c +0 -1308
  46. data/ext/commonmarker/commonmarker.h +0 -16
  47. data/ext/commonmarker/config.h +0 -76
  48. data/ext/commonmarker/core-extensions.c +0 -27
  49. data/ext/commonmarker/entities.inc +0 -2138
  50. data/ext/commonmarker/ext_scanners.c +0 -879
  51. data/ext/commonmarker/ext_scanners.h +0 -24
  52. data/ext/commonmarker/footnotes.c +0 -63
  53. data/ext/commonmarker/footnotes.h +0 -27
  54. data/ext/commonmarker/houdini.h +0 -57
  55. data/ext/commonmarker/houdini_href_e.c +0 -100
  56. data/ext/commonmarker/houdini_html_e.c +0 -66
  57. data/ext/commonmarker/houdini_html_u.c +0 -149
  58. data/ext/commonmarker/html.c +0 -502
  59. data/ext/commonmarker/html.h +0 -27
  60. data/ext/commonmarker/inlines.c +0 -1788
  61. data/ext/commonmarker/inlines.h +0 -29
  62. data/ext/commonmarker/iterator.c +0 -159
  63. data/ext/commonmarker/iterator.h +0 -26
  64. data/ext/commonmarker/latex.c +0 -468
  65. data/ext/commonmarker/linked_list.c +0 -37
  66. data/ext/commonmarker/man.c +0 -274
  67. data/ext/commonmarker/map.c +0 -129
  68. data/ext/commonmarker/map.h +0 -44
  69. data/ext/commonmarker/node.c +0 -1045
  70. data/ext/commonmarker/node.h +0 -167
  71. data/ext/commonmarker/parser.h +0 -59
  72. data/ext/commonmarker/plaintext.c +0 -218
  73. data/ext/commonmarker/plugin.c +0 -36
  74. data/ext/commonmarker/plugin.h +0 -34
  75. data/ext/commonmarker/references.c +0 -43
  76. data/ext/commonmarker/references.h +0 -26
  77. data/ext/commonmarker/registry.c +0 -63
  78. data/ext/commonmarker/registry.h +0 -24
  79. data/ext/commonmarker/render.c +0 -213
  80. data/ext/commonmarker/render.h +0 -62
  81. data/ext/commonmarker/scanners.c +0 -14056
  82. data/ext/commonmarker/scanners.h +0 -70
  83. data/ext/commonmarker/scanners.re +0 -341
  84. data/ext/commonmarker/strikethrough.c +0 -167
  85. data/ext/commonmarker/strikethrough.h +0 -9
  86. data/ext/commonmarker/syntax_extension.c +0 -149
  87. data/ext/commonmarker/syntax_extension.h +0 -34
  88. data/ext/commonmarker/table.c +0 -917
  89. data/ext/commonmarker/table.h +0 -12
  90. data/ext/commonmarker/tagfilter.c +0 -60
  91. data/ext/commonmarker/tagfilter.h +0 -8
  92. data/ext/commonmarker/tasklist.c +0 -156
  93. data/ext/commonmarker/tasklist.h +0 -8
  94. data/ext/commonmarker/utf8.c +0 -317
  95. data/ext/commonmarker/utf8.h +0 -35
  96. data/ext/commonmarker/xml.c +0 -182
  97. data/lib/commonmarker/renderer/html_renderer.rb +0 -256
@@ -1,737 +0,0 @@
1
- #ifndef CMARK_GFM_EXTENSION_API_H
2
- #define CMARK_GFM_EXTENSION_API_H
3
-
4
- #ifdef __cplusplus
5
- extern "C" {
6
- #endif
7
-
8
- #include "cmark-gfm.h"
9
-
10
- struct cmark_renderer;
11
- struct cmark_html_renderer;
12
- struct cmark_chunk;
13
-
14
- /**
15
- * ## Extension Support
16
- *
17
- * While the "core" of libcmark is strictly compliant with the
18
- * specification, an API is provided for extension writers to
19
- * hook into the parsing process.
20
- *
21
- * It should be noted that the cmark_node API already offers
22
- * room for customization, with methods offered to traverse and
23
- * modify the AST, and even define custom blocks.
24
- * When the desired customization is achievable in an error-proof
25
- * way using that API, it should be the preferred method.
26
- *
27
- * The following API requires a more in-depth understanding
28
- * of libcmark's parsing strategy, which is exposed
29
- * [here](http://spec.commonmark.org/0.24/#appendix-a-parsing-strategy).
30
- *
31
- * It should be used when "a posteriori" modification of the AST
32
- * proves to be too difficult / impossible to implement correctly.
33
- *
34
- * It can also serve as an intermediary step before extending
35
- * the specification, as an extension implemented using this API
36
- * will be trivially integrated in the core if it proves to be
37
- * desirable.
38
- */
39
-
40
- typedef struct cmark_plugin cmark_plugin;
41
-
42
- /** A syntax extension that can be attached to a cmark_parser
43
- * with cmark_parser_attach_syntax_extension().
44
- *
45
- * Extension writers should assign functions matching
46
- * the signature of the following 'virtual methods' to
47
- * implement new functionality.
48
- *
49
- * Their calling order and expected behaviour match the procedure outlined
50
- * at <http://spec.commonmark.org/0.24/#phase-1-block-structure>:
51
- *
52
- * During step 1, cmark will call the function provided through
53
- * 'cmark_syntax_extension_set_match_block_func' when it
54
- * iterates over an open block created by this extension,
55
- * to determine whether it could contain the new line.
56
- * If no function was provided, cmark will close the block.
57
- *
58
- * During step 2, if and only if the new line doesn't match any
59
- * of the standard syntax rules, cmark will call the function
60
- * provided through 'cmark_syntax_extension_set_open_block_func'
61
- * to let the extension determine whether that new line matches
62
- * one of its syntax rules.
63
- * It is the responsibility of the parser to create and add the
64
- * new block with cmark_parser_make_block and cmark_parser_add_child.
65
- * If no function was provided is NULL, the extension will have
66
- * no effect at all on the final block structure of the AST.
67
- *
68
- * #### Inline parsing phase hooks
69
- *
70
- * For each character provided by the extension through
71
- * 'cmark_syntax_extension_set_special_inline_chars',
72
- * the function provided by the extension through
73
- * 'cmark_syntax_extension_set_match_inline_func'
74
- * will get called, it is the responsibility of the extension
75
- * to scan the characters located at the current inline parsing offset
76
- * with the cmark_inline_parser API.
77
- *
78
- * Depending on the type of the extension, it can either:
79
- *
80
- * * Scan forward, determine that the syntax matches and return
81
- * a newly-created inline node with the appropriate type.
82
- * This is the technique that would be used if inline code
83
- * (with backticks) was implemented as an extension.
84
- * * Scan only the character(s) that its syntax rules require
85
- * for opening and closing nodes, push a delimiter on the
86
- * delimiter stack, and return a simple text node with its
87
- * contents set to the character(s) consumed.
88
- * This is the technique that would be used if emphasis
89
- * inlines were implemented as an extension.
90
- *
91
- * When an extension has pushed delimiters on the stack,
92
- * the function provided through
93
- * 'cmark_syntax_extension_set_inline_from_delim_func'
94
- * will get called in a latter phase,
95
- * when the inline parser has matched opener and closer delimiters
96
- * created by the extension together.
97
- *
98
- * It is then the responsibility of the extension to modify
99
- * and populate the opener inline text node, and to remove
100
- * the necessary delimiters from the delimiter stack.
101
- *
102
- * Finally, the extension should return NULL if its scan didn't
103
- * match its syntax rules.
104
- *
105
- * The extension can store whatever private data it might need
106
- * with 'cmark_syntax_extension_set_private',
107
- * and optionally define a free function for this data.
108
- */
109
- typedef struct subject cmark_inline_parser;
110
-
111
- /** Exposed raw for now */
112
-
113
- typedef struct delimiter {
114
- struct delimiter *previous;
115
- struct delimiter *next;
116
- cmark_node *inl_text;
117
- bufsize_t position;
118
- bufsize_t length;
119
- unsigned char delim_char;
120
- int can_open;
121
- int can_close;
122
- } delimiter;
123
-
124
- /**
125
- * ### Plugin API.
126
- *
127
- * Extensions should be distributed as dynamic libraries,
128
- * with a single exported function named after the distributed
129
- * filename.
130
- *
131
- * When discovering extensions (see cmark_init), cmark will
132
- * try to load a symbol named "init_{{filename}}" in all the
133
- * dynamic libraries it encounters.
134
- *
135
- * For example, given a dynamic library named myextension.so
136
- * (or myextension.dll), cmark will try to load the symbol
137
- * named "init_myextension". This means that the filename
138
- * must lend itself to forming a valid C identifier, with
139
- * the notable exception of dashes, which will be translated
140
- * to underscores, which means cmark will look for a function
141
- * named "init_my_extension" if it encounters a dynamic library
142
- * named "my-extension.so".
143
- *
144
- * See the 'cmark_plugin_init_func' typedef for the exact prototype
145
- * this function should follow.
146
- *
147
- * For now the extensibility of cmark is not complete, as
148
- * it only offers API to hook into the block parsing phase
149
- * (<http://spec.commonmark.org/0.24/#phase-1-block-structure>).
150
- *
151
- * See 'cmark_plugin_register_syntax_extension' for more information.
152
- */
153
-
154
- /** The prototype plugins' init function should follow.
155
- */
156
- typedef int (*cmark_plugin_init_func)(cmark_plugin *plugin);
157
-
158
- /** Register a syntax 'extension' with the 'plugin', it will be made
159
- * available as an extension and, if attached to a cmark_parser
160
- * with 'cmark_parser_attach_syntax_extension', it will contribute
161
- * to the block parsing process.
162
- *
163
- * See the documentation for 'cmark_syntax_extension' for information
164
- * on how to implement one.
165
- *
166
- * This function will typically be called from the init function
167
- * of external modules.
168
- *
169
- * This takes ownership of 'extension', one should not call
170
- * 'cmark_syntax_extension_free' on a registered extension.
171
- */
172
- CMARK_GFM_EXPORT
173
- int cmark_plugin_register_syntax_extension(cmark_plugin *plugin,
174
- cmark_syntax_extension *extension);
175
-
176
- /** This will search for the syntax extension named 'name' among the
177
- * registered syntax extensions.
178
- *
179
- * It can then be attached to a cmark_parser
180
- * with the cmark_parser_attach_syntax_extension method.
181
- */
182
- CMARK_GFM_EXPORT
183
- cmark_syntax_extension *cmark_find_syntax_extension(const char *name);
184
-
185
- /** Should create and add a new open block to 'parent_container' if
186
- * 'input' matches a syntax rule for that block type. It is allowed
187
- * to modify the type of 'parent_container'.
188
- *
189
- * Should return the newly created block if there is one, or
190
- * 'parent_container' if its type was modified, or NULL.
191
- */
192
- typedef cmark_node * (*cmark_open_block_func) (cmark_syntax_extension *extension,
193
- int indented,
194
- cmark_parser *parser,
195
- cmark_node *parent_container,
196
- unsigned char *input,
197
- int len);
198
-
199
- typedef cmark_node *(*cmark_match_inline_func)(cmark_syntax_extension *extension,
200
- cmark_parser *parser,
201
- cmark_node *parent,
202
- unsigned char character,
203
- cmark_inline_parser *inline_parser);
204
-
205
- typedef delimiter *(*cmark_inline_from_delim_func)(cmark_syntax_extension *extension,
206
- cmark_parser *parser,
207
- cmark_inline_parser *inline_parser,
208
- delimiter *opener,
209
- delimiter *closer);
210
-
211
- /** Should return 'true' if 'input' can be contained in 'container',
212
- * 'false' otherwise.
213
- */
214
- typedef int (*cmark_match_block_func) (cmark_syntax_extension *extension,
215
- cmark_parser *parser,
216
- unsigned char *input,
217
- int len,
218
- cmark_node *container);
219
-
220
- typedef const char *(*cmark_get_type_string_func) (cmark_syntax_extension *extension,
221
- cmark_node *node);
222
-
223
- typedef int (*cmark_can_contain_func) (cmark_syntax_extension *extension,
224
- cmark_node *node,
225
- cmark_node_type child);
226
-
227
- typedef int (*cmark_contains_inlines_func) (cmark_syntax_extension *extension,
228
- cmark_node *node);
229
-
230
- typedef void (*cmark_common_render_func) (cmark_syntax_extension *extension,
231
- struct cmark_renderer *renderer,
232
- cmark_node *node,
233
- cmark_event_type ev_type,
234
- int options);
235
-
236
- typedef int (*cmark_commonmark_escape_func) (cmark_syntax_extension *extension,
237
- cmark_node *node,
238
- int c);
239
-
240
- typedef const char* (*cmark_xml_attr_func) (cmark_syntax_extension *extension,
241
- cmark_node *node);
242
-
243
- typedef void (*cmark_html_render_func) (cmark_syntax_extension *extension,
244
- struct cmark_html_renderer *renderer,
245
- cmark_node *node,
246
- cmark_event_type ev_type,
247
- int options);
248
-
249
- typedef int (*cmark_html_filter_func) (cmark_syntax_extension *extension,
250
- const unsigned char *tag,
251
- size_t tag_len);
252
-
253
- typedef cmark_node *(*cmark_postprocess_func) (cmark_syntax_extension *extension,
254
- cmark_parser *parser,
255
- cmark_node *root);
256
-
257
- typedef int (*cmark_ispunct_func) (char c);
258
-
259
- typedef void (*cmark_opaque_alloc_func) (cmark_syntax_extension *extension,
260
- cmark_mem *mem,
261
- cmark_node *node);
262
-
263
- typedef void (*cmark_opaque_free_func) (cmark_syntax_extension *extension,
264
- cmark_mem *mem,
265
- cmark_node *node);
266
-
267
- /** Free a cmark_syntax_extension.
268
- */
269
- CMARK_GFM_EXPORT
270
- void cmark_syntax_extension_free (cmark_mem *mem, cmark_syntax_extension *extension);
271
-
272
- /** Return a newly-constructed cmark_syntax_extension, named 'name'.
273
- */
274
- CMARK_GFM_EXPORT
275
- cmark_syntax_extension *cmark_syntax_extension_new (const char *name);
276
-
277
- CMARK_GFM_EXPORT
278
- cmark_node_type cmark_syntax_extension_add_node(int is_inline);
279
-
280
- CMARK_GFM_EXPORT
281
- void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension, int emphasis);
282
-
283
- /** See the documentation for 'cmark_syntax_extension'
284
- */
285
- CMARK_GFM_EXPORT
286
- void cmark_syntax_extension_set_open_block_func(cmark_syntax_extension *extension,
287
- cmark_open_block_func func);
288
-
289
- /** See the documentation for 'cmark_syntax_extension'
290
- */
291
- CMARK_GFM_EXPORT
292
- void cmark_syntax_extension_set_match_block_func(cmark_syntax_extension *extension,
293
- cmark_match_block_func func);
294
-
295
- /** See the documentation for 'cmark_syntax_extension'
296
- */
297
- CMARK_GFM_EXPORT
298
- void cmark_syntax_extension_set_match_inline_func(cmark_syntax_extension *extension,
299
- cmark_match_inline_func func);
300
-
301
- /** See the documentation for 'cmark_syntax_extension'
302
- */
303
- CMARK_GFM_EXPORT
304
- void cmark_syntax_extension_set_inline_from_delim_func(cmark_syntax_extension *extension,
305
- cmark_inline_from_delim_func func);
306
-
307
- /** See the documentation for 'cmark_syntax_extension'
308
- */
309
- CMARK_GFM_EXPORT
310
- void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *extension,
311
- cmark_llist *special_chars);
312
-
313
- /** See the documentation for 'cmark_syntax_extension'
314
- */
315
- CMARK_GFM_EXPORT
316
- void cmark_syntax_extension_set_get_type_string_func(cmark_syntax_extension *extension,
317
- cmark_get_type_string_func func);
318
-
319
- /** See the documentation for 'cmark_syntax_extension'
320
- */
321
- CMARK_GFM_EXPORT
322
- void cmark_syntax_extension_set_can_contain_func(cmark_syntax_extension *extension,
323
- cmark_can_contain_func func);
324
-
325
- /** See the documentation for 'cmark_syntax_extension'
326
- */
327
- CMARK_GFM_EXPORT
328
- void cmark_syntax_extension_set_contains_inlines_func(cmark_syntax_extension *extension,
329
- cmark_contains_inlines_func func);
330
-
331
- /** See the documentation for 'cmark_syntax_extension'
332
- */
333
- CMARK_GFM_EXPORT
334
- void cmark_syntax_extension_set_commonmark_render_func(cmark_syntax_extension *extension,
335
- cmark_common_render_func func);
336
-
337
- /** See the documentation for 'cmark_syntax_extension'
338
- */
339
- CMARK_GFM_EXPORT
340
- void cmark_syntax_extension_set_plaintext_render_func(cmark_syntax_extension *extension,
341
- cmark_common_render_func func);
342
-
343
- /** See the documentation for 'cmark_syntax_extension'
344
- */
345
- CMARK_GFM_EXPORT
346
- void cmark_syntax_extension_set_latex_render_func(cmark_syntax_extension *extension,
347
- cmark_common_render_func func);
348
-
349
- /** See the documentation for 'cmark_syntax_extension'
350
- */
351
- CMARK_GFM_EXPORT
352
- void cmark_syntax_extension_set_xml_attr_func(cmark_syntax_extension *extension,
353
- cmark_xml_attr_func func);
354
-
355
- /** See the documentation for 'cmark_syntax_extension'
356
- */
357
- CMARK_GFM_EXPORT
358
- void cmark_syntax_extension_set_man_render_func(cmark_syntax_extension *extension,
359
- cmark_common_render_func func);
360
-
361
- /** See the documentation for 'cmark_syntax_extension'
362
- */
363
- CMARK_GFM_EXPORT
364
- void cmark_syntax_extension_set_html_render_func(cmark_syntax_extension *extension,
365
- cmark_html_render_func func);
366
-
367
- /** See the documentation for 'cmark_syntax_extension'
368
- */
369
- CMARK_GFM_EXPORT
370
- void cmark_syntax_extension_set_html_filter_func(cmark_syntax_extension *extension,
371
- cmark_html_filter_func func);
372
-
373
- /** See the documentation for 'cmark_syntax_extension'
374
- */
375
- CMARK_GFM_EXPORT
376
- void cmark_syntax_extension_set_commonmark_escape_func(cmark_syntax_extension *extension,
377
- cmark_commonmark_escape_func func);
378
-
379
- /** See the documentation for 'cmark_syntax_extension'
380
- */
381
- CMARK_GFM_EXPORT
382
- void cmark_syntax_extension_set_private(cmark_syntax_extension *extension,
383
- void *priv,
384
- cmark_free_func free_func);
385
-
386
- /** See the documentation for 'cmark_syntax_extension'
387
- */
388
- CMARK_GFM_EXPORT
389
- void *cmark_syntax_extension_get_private(cmark_syntax_extension *extension);
390
-
391
- /** See the documentation for 'cmark_syntax_extension'
392
- */
393
- CMARK_GFM_EXPORT
394
- void cmark_syntax_extension_set_postprocess_func(cmark_syntax_extension *extension,
395
- cmark_postprocess_func func);
396
-
397
- /** See the documentation for 'cmark_syntax_extension'
398
- */
399
- CMARK_GFM_EXPORT
400
- void cmark_syntax_extension_set_opaque_alloc_func(cmark_syntax_extension *extension,
401
- cmark_opaque_alloc_func func);
402
-
403
- /** See the documentation for 'cmark_syntax_extension'
404
- */
405
- CMARK_GFM_EXPORT
406
- void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
407
- cmark_opaque_free_func func);
408
-
409
- /** See the documentation for 'cmark_syntax_extension'
410
- */
411
- CMARK_GFM_EXPORT
412
- void cmark_parser_set_backslash_ispunct_func(cmark_parser *parser,
413
- cmark_ispunct_func func);
414
-
415
- /** Return the index of the line currently being parsed, starting with 1.
416
- */
417
- CMARK_GFM_EXPORT
418
- int cmark_parser_get_line_number(cmark_parser *parser);
419
-
420
- /** Return the offset in bytes in the line being processed.
421
- *
422
- * Example:
423
- *
424
- * ### foo
425
- *
426
- * Here, offset will first be 0, then 5 (the index of the 'f' character).
427
- */
428
- CMARK_GFM_EXPORT
429
- int cmark_parser_get_offset(cmark_parser *parser);
430
-
431
- /**
432
- * Return the offset in 'columns' in the line being processed.
433
- *
434
- * This value may differ from the value returned by
435
- * cmark_parser_get_offset() in that it accounts for tabs,
436
- * and as such should not be used as an index in the current line's
437
- * buffer.
438
- *
439
- * Example:
440
- *
441
- * cmark_parser_advance_offset() can be called to advance the
442
- * offset by a number of columns, instead of a number of bytes.
443
- *
444
- * In that case, if offset falls "in the middle" of a tab
445
- * character, 'column' and offset will differ.
446
- *
447
- * ```
448
- * foo \t bar
449
- * ^ ^^
450
- * offset (0) 20
451
- * ```
452
- *
453
- * If cmark_parser_advance_offset is called here with 'columns'
454
- * set to 'true' and 'offset' set to 22, cmark_parser_get_offset()
455
- * will return 20, whereas cmark_parser_get_column() will return
456
- * 22.
457
- *
458
- * Additionally, as tabs expand to the next multiple of 4 column,
459
- * cmark_parser_has_partially_consumed_tab() will now return
460
- * 'true'.
461
- */
462
- CMARK_GFM_EXPORT
463
- int cmark_parser_get_column(cmark_parser *parser);
464
-
465
- /** Return the absolute index in bytes of the first nonspace
466
- * character coming after the offset as returned by
467
- * cmark_parser_get_offset() in the line currently being processed.
468
- *
469
- * Example:
470
- *
471
- * ```
472
- * foo bar baz \n
473
- * ^ ^ ^
474
- * 0 offset (16) first_nonspace (28)
475
- * ```
476
- */
477
- CMARK_GFM_EXPORT
478
- int cmark_parser_get_first_nonspace(cmark_parser *parser);
479
-
480
- /** Return the absolute index of the first nonspace column coming after 'offset'
481
- * in the line currently being processed, counting tabs as multiple
482
- * columns as appropriate.
483
- *
484
- * See the documentation for cmark_parser_get_first_nonspace() and
485
- * cmark_parser_get_column() for more information.
486
- */
487
- CMARK_GFM_EXPORT
488
- int cmark_parser_get_first_nonspace_column(cmark_parser *parser);
489
-
490
- /** Return the difference between the values returned by
491
- * cmark_parser_get_first_nonspace_column() and
492
- * cmark_parser_get_column().
493
- *
494
- * This is not a byte offset, as it can count one tab as multiple
495
- * characters.
496
- */
497
- CMARK_GFM_EXPORT
498
- int cmark_parser_get_indent(cmark_parser *parser);
499
-
500
- /** Return 'true' if the line currently being processed has been entirely
501
- * consumed, 'false' otherwise.
502
- *
503
- * Example:
504
- *
505
- * ```
506
- * foo bar baz \n
507
- * ^
508
- * offset
509
- * ```
510
- *
511
- * This function will return 'false' here.
512
- *
513
- * ```
514
- * foo bar baz \n
515
- * ^
516
- * offset
517
- * ```
518
- * This function will still return 'false'.
519
- *
520
- * ```
521
- * foo bar baz \n
522
- * ^
523
- * offset
524
- * ```
525
- *
526
- * At this point, this function will now return 'true'.
527
- */
528
- CMARK_GFM_EXPORT
529
- int cmark_parser_is_blank(cmark_parser *parser);
530
-
531
- /** Return 'true' if the value returned by cmark_parser_get_offset()
532
- * is 'inside' an expanded tab.
533
- *
534
- * See the documentation for cmark_parser_get_column() for more
535
- * information.
536
- */
537
- CMARK_GFM_EXPORT
538
- int cmark_parser_has_partially_consumed_tab(cmark_parser *parser);
539
-
540
- /** Return the length in bytes of the previously processed line, excluding potential
541
- * newline (\n) and carriage return (\r) trailing characters.
542
- */
543
- CMARK_GFM_EXPORT
544
- int cmark_parser_get_last_line_length(cmark_parser *parser);
545
-
546
- /** Add a child to 'parent' during the parsing process.
547
- *
548
- * If 'parent' isn't the kind of node that can accept this child,
549
- * this function will back up till it hits a node that can, closing
550
- * blocks as appropriate.
551
- */
552
- CMARK_GFM_EXPORT
553
- cmark_node*cmark_parser_add_child(cmark_parser *parser,
554
- cmark_node *parent,
555
- cmark_node_type block_type,
556
- int start_column);
557
-
558
- /** Advance the 'offset' of the parser in the current line.
559
- *
560
- * See the documentation of cmark_parser_get_offset() and
561
- * cmark_parser_get_column() for more information.
562
- */
563
- CMARK_GFM_EXPORT
564
- void cmark_parser_advance_offset(cmark_parser *parser,
565
- const char *input,
566
- int count,
567
- int columns);
568
-
569
-
570
- CMARK_GFM_EXPORT
571
- void cmark_parser_feed_reentrant(cmark_parser *parser, const char *buffer, size_t len);
572
-
573
- /** Attach the syntax 'extension' to the 'parser', to provide extra syntax
574
- * rules.
575
- * See the documentation for cmark_syntax_extension for more information.
576
- *
577
- * Returns 'true' if the 'extension' was successfully attached,
578
- * 'false' otherwise.
579
- */
580
- CMARK_GFM_EXPORT
581
- int cmark_parser_attach_syntax_extension(cmark_parser *parser, cmark_syntax_extension *extension);
582
-
583
- /** Change the type of 'node'.
584
- *
585
- * Return 0 if the type could be changed, 1 otherwise.
586
- */
587
- CMARK_GFM_EXPORT int cmark_node_set_type(cmark_node *node, cmark_node_type type);
588
-
589
- /** Return the string content for all types of 'node'.
590
- * The pointer stays valid as long as 'node' isn't freed.
591
- */
592
- CMARK_GFM_EXPORT const char *cmark_node_get_string_content(cmark_node *node);
593
-
594
- /** Set the string 'content' for all types of 'node'.
595
- * Copies 'content'.
596
- */
597
- CMARK_GFM_EXPORT int cmark_node_set_string_content(cmark_node *node, const char *content);
598
-
599
- /** Get the syntax extension responsible for the creation of 'node'.
600
- * Return NULL if 'node' was created because it matched standard syntax rules.
601
- */
602
- CMARK_GFM_EXPORT cmark_syntax_extension *cmark_node_get_syntax_extension(cmark_node *node);
603
-
604
- /** Set the syntax extension responsible for creating 'node'.
605
- */
606
- CMARK_GFM_EXPORT int cmark_node_set_syntax_extension(cmark_node *node,
607
- cmark_syntax_extension *extension);
608
-
609
- /**
610
- * ## Inline syntax extension helpers
611
- *
612
- * The inline parsing process is described in detail at
613
- * <http://spec.commonmark.org/0.24/#phase-2-inline-structure>
614
- */
615
-
616
- /** Should return 'true' if the predicate matches 'c', 'false' otherwise
617
- */
618
- typedef int (*cmark_inline_predicate)(int c);
619
-
620
- /** Advance the current inline parsing offset */
621
- CMARK_GFM_EXPORT
622
- void cmark_inline_parser_advance_offset(cmark_inline_parser *parser);
623
-
624
- /** Get the current inline parsing offset */
625
- CMARK_GFM_EXPORT
626
- int cmark_inline_parser_get_offset(cmark_inline_parser *parser);
627
-
628
- /** Set the offset in bytes in the chunk being processed by the given inline parser.
629
- */
630
- CMARK_GFM_EXPORT
631
- void cmark_inline_parser_set_offset(cmark_inline_parser *parser, int offset);
632
-
633
- /** Gets the cmark_chunk being operated on by the given inline parser.
634
- * Use cmark_inline_parser_get_offset to get our current position in the chunk.
635
- */
636
- CMARK_GFM_EXPORT
637
- struct cmark_chunk *cmark_inline_parser_get_chunk(cmark_inline_parser *parser);
638
-
639
- /** Returns 1 if the inline parser is currently in a bracket; pass 1 for 'image'
640
- * if you want to know about an image-type bracket, 0 for link-type. */
641
- CMARK_GFM_EXPORT
642
- int cmark_inline_parser_in_bracket(cmark_inline_parser *parser, int image);
643
-
644
- /** Remove the last n characters from the last child of the given node.
645
- * This only works where all n characters are in the single last child, and the last
646
- * child is CMARK_NODE_TEXT.
647
- */
648
- CMARK_GFM_EXPORT
649
- void cmark_node_unput(cmark_node *node, int n);
650
-
651
-
652
- /** Get the character located at the current inline parsing offset
653
- */
654
- CMARK_GFM_EXPORT
655
- unsigned char cmark_inline_parser_peek_char(cmark_inline_parser *parser);
656
-
657
- /** Get the character located 'pos' bytes in the current line.
658
- */
659
- CMARK_GFM_EXPORT
660
- unsigned char cmark_inline_parser_peek_at(cmark_inline_parser *parser, int pos);
661
-
662
- /** Whether the inline parser has reached the end of the current line
663
- */
664
- CMARK_GFM_EXPORT
665
- int cmark_inline_parser_is_eof(cmark_inline_parser *parser);
666
-
667
- /** Get the characters located after the current inline parsing offset
668
- * while 'pred' matches. Free after usage.
669
- */
670
- CMARK_GFM_EXPORT
671
- char *cmark_inline_parser_take_while(cmark_inline_parser *parser, cmark_inline_predicate pred);
672
-
673
- /** Push a delimiter on the delimiter stack.
674
- * See <<http://spec.commonmark.org/0.24/#phase-2-inline-structure> for
675
- * more information on the parameters
676
- */
677
- CMARK_GFM_EXPORT
678
- void cmark_inline_parser_push_delimiter(cmark_inline_parser *parser,
679
- unsigned char c,
680
- int can_open,
681
- int can_close,
682
- cmark_node *inl_text);
683
-
684
- /** Remove 'delim' from the delimiter stack
685
- */
686
- CMARK_GFM_EXPORT
687
- void cmark_inline_parser_remove_delimiter(cmark_inline_parser *parser, delimiter *delim);
688
-
689
- CMARK_GFM_EXPORT
690
- delimiter *cmark_inline_parser_get_last_delimiter(cmark_inline_parser *parser);
691
-
692
- CMARK_GFM_EXPORT
693
- int cmark_inline_parser_get_line(cmark_inline_parser *parser);
694
-
695
- CMARK_GFM_EXPORT
696
- int cmark_inline_parser_get_column(cmark_inline_parser *parser);
697
-
698
- /** Convenience function to scan a given delimiter.
699
- *
700
- * 'left_flanking' and 'right_flanking' will be set to true if they
701
- * respectively precede and follow a non-space, non-punctuation
702
- * character.
703
- *
704
- * Additionally, 'punct_before' and 'punct_after' will respectively be set
705
- * if the preceding or following character is a punctuation character.
706
- *
707
- * Note that 'left_flanking' and 'right_flanking' can both be 'true'.
708
- *
709
- * Returns the number of delimiters encountered, in the limit
710
- * of 'max_delims', and advances the inline parsing offset.
711
- */
712
- CMARK_GFM_EXPORT
713
- int cmark_inline_parser_scan_delimiters(cmark_inline_parser *parser,
714
- int max_delims,
715
- unsigned char c,
716
- int *left_flanking,
717
- int *right_flanking,
718
- int *punct_before,
719
- int *punct_after);
720
-
721
- CMARK_GFM_EXPORT
722
- void cmark_manage_extensions_special_characters(cmark_parser *parser, int add);
723
-
724
- CMARK_GFM_EXPORT
725
- cmark_llist *cmark_parser_get_syntax_extensions(cmark_parser *parser);
726
-
727
- CMARK_GFM_EXPORT
728
- void cmark_arena_push(void);
729
-
730
- CMARK_GFM_EXPORT
731
- int cmark_arena_pop(void);
732
-
733
- #ifdef __cplusplus
734
- }
735
- #endif
736
-
737
- #endif