File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ typedef struct cmark_plugin cmark_plugin;
9797 *
9898 * Finally, the extension should return NULL if its scan didn't
9999 * 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.
100104 */
101105typedef struct cmark_syntax_extension cmark_syntax_extension ;
102106
@@ -249,6 +253,13 @@ CMARK_EXPORT
249253void cmark_syntax_extension_set_special_inline_chars (cmark_syntax_extension * extension ,
250254 cmark_llist * special_chars );
251255
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+
252263/** Return the index of the line currently being parsed, starting with 1.
253264 */
254265CMARK_EXPORT
Original file line number Diff line number Diff line change 55#include "buffer.h"
66
77void cmark_syntax_extension_free (cmark_syntax_extension * extension ) {
8+ if (extension -> free_function && extension -> priv ) {
9+ extension -> free_function (extension -> priv );
10+ }
11+
812 cmark_llist_free (extension -> special_inline_chars );
913 free (extension -> name );
1014 free (extension );
@@ -42,3 +46,10 @@ void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *ext
4246 cmark_llist * special_chars ) {
4347 extension -> special_inline_chars = special_chars ;
4448}
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 {
1111 cmark_inline_from_delim_func insert_inline_from_delim ;
1212 cmark_llist * special_inline_chars ;
1313 char * name ;
14+ void * priv ;
15+ cmark_free_func free_function ;
1416};
1517
1618#endif
You can’t perform that action at this time.
0 commit comments