File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ typedef struct cmark_plugin cmark_plugin;
97
97
*
98
98
* Finally, the extension should return NULL if its scan didn't
99
99
* match its syntax rules.
100
+ *
101
+ * The extension can store whatever private data it might need
102
+ * with 'cmark_syntax_extension_set_private',
103
+ * and optionally define a free function for this data.
100
104
*/
101
105
typedef struct cmark_syntax_extension cmark_syntax_extension ;
102
106
@@ -249,6 +253,13 @@ CMARK_EXPORT
249
253
void cmark_syntax_extension_set_special_inline_chars (cmark_syntax_extension * extension ,
250
254
cmark_llist * special_chars );
251
255
256
+ /** See the documentation for 'cmark_syntax_extension'
257
+ */
258
+ CMARK_EXPORT
259
+ void cmark_syntax_extension_set_private (cmark_syntax_extension * extension ,
260
+ void * priv ,
261
+ cmark_free_func free_func );
262
+
252
263
/** Return the index of the line currently being parsed, starting with 1.
253
264
*/
254
265
CMARK_EXPORT
Original file line number Diff line number Diff line change 5
5
#include "buffer.h"
6
6
7
7
void cmark_syntax_extension_free (cmark_syntax_extension * extension ) {
8
+ if (extension -> free_function && extension -> priv ) {
9
+ extension -> free_function (extension -> priv );
10
+ }
11
+
8
12
cmark_llist_free (extension -> special_inline_chars );
9
13
free (extension -> name );
10
14
free (extension );
@@ -42,3 +46,10 @@ void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *ext
42
46
cmark_llist * special_chars ) {
43
47
extension -> special_inline_chars = special_chars ;
44
48
}
49
+
50
+ void cmark_syntax_extension_set_private (cmark_syntax_extension * extension ,
51
+ void * priv ,
52
+ cmark_free_func free_func ) {
53
+ extension -> priv = priv ;
54
+ extension -> free_function = free_func ;
55
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ struct cmark_syntax_extension {
11
11
cmark_inline_from_delim_func insert_inline_from_delim ;
12
12
cmark_llist * special_inline_chars ;
13
13
char * name ;
14
+ void * priv ;
15
+ cmark_free_func free_function ;
14
16
};
15
17
16
18
#endif
You can’t perform that action at this time.
0 commit comments