cmark.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. #ifndef CMARK_H
  2. #define CMARK_H
  3. #include <stdio.h>
  4. #include <cmark_export.h>
  5. #include <cmark_version.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /** # NAME
  10. *
  11. * **cmark** - CommonMark parsing, manipulating, and rendering
  12. */
  13. /** # DESCRIPTION
  14. *
  15. * ## Simple Interface
  16. */
  17. /** Convert 'text' (assumed to be a UTF-8 encoded string with length
  18. * 'len') from CommonMark Markdown to HTML, returning a null-terminated,
  19. * UTF-8-encoded string. It is the caller's responsibility
  20. * to free the returned buffer.
  21. */
  22. CMARK_EXPORT
  23. char *cmark_markdown_to_html(const char *text, size_t len, int options);
  24. /** ## Node Structure
  25. */
  26. typedef enum {
  27. /* Error status */
  28. CMARK_NODE_NONE,
  29. /* Block */
  30. CMARK_NODE_DOCUMENT,
  31. CMARK_NODE_BLOCK_QUOTE,
  32. CMARK_NODE_LIST,
  33. CMARK_NODE_ITEM,
  34. CMARK_NODE_CODE_BLOCK,
  35. CMARK_NODE_HTML_BLOCK,
  36. CMARK_NODE_CUSTOM_BLOCK,
  37. CMARK_NODE_PARAGRAPH,
  38. CMARK_NODE_HEADING,
  39. CMARK_NODE_THEMATIC_BREAK,
  40. CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
  41. CMARK_NODE_LAST_BLOCK = CMARK_NODE_THEMATIC_BREAK,
  42. /* Inline */
  43. CMARK_NODE_TEXT,
  44. CMARK_NODE_SOFTBREAK,
  45. CMARK_NODE_LINEBREAK,
  46. CMARK_NODE_CODE,
  47. CMARK_NODE_HTML_INLINE,
  48. CMARK_NODE_CUSTOM_INLINE,
  49. CMARK_NODE_EMPH,
  50. CMARK_NODE_STRONG,
  51. CMARK_NODE_LINK,
  52. CMARK_NODE_IMAGE,
  53. CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
  54. CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
  55. } cmark_node_type;
  56. /* For backwards compatibility: */
  57. #define CMARK_NODE_HEADER CMARK_NODE_HEADING
  58. #define CMARK_NODE_HRULE CMARK_NODE_THEMATIC_BREAK
  59. #define CMARK_NODE_HTML CMARK_NODE_HTML_BLOCK
  60. #define CMARK_NODE_INLINE_HTML CMARK_NODE_HTML_INLINE
  61. typedef enum {
  62. CMARK_NO_LIST,
  63. CMARK_BULLET_LIST,
  64. CMARK_ORDERED_LIST
  65. } cmark_list_type;
  66. typedef enum {
  67. CMARK_NO_DELIM,
  68. CMARK_PERIOD_DELIM,
  69. CMARK_PAREN_DELIM
  70. } cmark_delim_type;
  71. typedef struct cmark_node cmark_node;
  72. typedef struct cmark_parser cmark_parser;
  73. typedef struct cmark_iter cmark_iter;
  74. /**
  75. * ## Custom memory allocator support
  76. */
  77. /** Defines the memory allocation functions to be used by CMark
  78. * when parsing and allocating a document tree
  79. */
  80. typedef struct cmark_mem {
  81. void *(*calloc)(size_t, size_t);
  82. void *(*realloc)(void *, size_t);
  83. void (*free)(void *);
  84. } cmark_mem;
  85. /**
  86. * ## Creating and Destroying Nodes
  87. */
  88. /** Creates a new node of type 'type'. Note that the node may have
  89. * other required properties, which it is the caller's responsibility
  90. * to assign.
  91. */
  92. CMARK_EXPORT cmark_node *cmark_node_new(cmark_node_type type);
  93. /** Same as `cmark_node_new`, but explicitly listing the memory
  94. * allocator used to allocate the node. Note: be sure to use the same
  95. * allocator for every node in a tree, or bad things can happen.
  96. */
  97. CMARK_EXPORT cmark_node *cmark_node_new_with_mem(cmark_node_type type,
  98. cmark_mem *mem);
  99. /** Frees the memory allocated for a node and any children.
  100. */
  101. CMARK_EXPORT void cmark_node_free(cmark_node *node);
  102. /**
  103. * ## Tree Traversal
  104. */
  105. /** Returns the next node in the sequence after 'node', or NULL if
  106. * there is none.
  107. */
  108. CMARK_EXPORT cmark_node *cmark_node_next(cmark_node *node);
  109. /** Returns the previous node in the sequence after 'node', or NULL if
  110. * there is none.
  111. */
  112. CMARK_EXPORT cmark_node *cmark_node_previous(cmark_node *node);
  113. /** Returns the parent of 'node', or NULL if there is none.
  114. */
  115. CMARK_EXPORT cmark_node *cmark_node_parent(cmark_node *node);
  116. /** Returns the first child of 'node', or NULL if 'node' has no children.
  117. */
  118. CMARK_EXPORT cmark_node *cmark_node_first_child(cmark_node *node);
  119. /** Returns the last child of 'node', or NULL if 'node' has no children.
  120. */
  121. CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
  122. /**
  123. * ## Iterator
  124. *
  125. * An iterator will walk through a tree of nodes, starting from a root
  126. * node, returning one node at a time, together with information about
  127. * whether the node is being entered or exited. The iterator will
  128. * first descend to a child node, if there is one. When there is no
  129. * child, the iterator will go to the next sibling. When there is no
  130. * next sibling, the iterator will return to the parent (but with
  131. * a 'cmark_event_type' of `CMARK_EVENT_EXIT`). The iterator will
  132. * return `CMARK_EVENT_DONE` when it reaches the root node again.
  133. * One natural application is an HTML renderer, where an `ENTER` event
  134. * outputs an open tag and an `EXIT` event outputs a close tag.
  135. * An iterator might also be used to transform an AST in some systematic
  136. * way, for example, turning all level-3 headings into regular paragraphs.
  137. *
  138. * void
  139. * usage_example(cmark_node *root) {
  140. * cmark_event_type ev_type;
  141. * cmark_iter *iter = cmark_iter_new(root);
  142. *
  143. * while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
  144. * cmark_node *cur = cmark_iter_get_node(iter);
  145. * // Do something with `cur` and `ev_type`
  146. * }
  147. *
  148. * cmark_iter_free(iter);
  149. * }
  150. *
  151. * Iterators will never return `EXIT` events for leaf nodes, which are nodes
  152. * of type:
  153. *
  154. * * CMARK_NODE_HTML_BLOCK
  155. * * CMARK_NODE_THEMATIC_BREAK
  156. * * CMARK_NODE_CODE_BLOCK
  157. * * CMARK_NODE_TEXT
  158. * * CMARK_NODE_SOFTBREAK
  159. * * CMARK_NODE_LINEBREAK
  160. * * CMARK_NODE_CODE
  161. * * CMARK_NODE_HTML_INLINE
  162. *
  163. * Nodes must only be modified after an `EXIT` event, or an `ENTER` event for
  164. * leaf nodes.
  165. */
  166. typedef enum {
  167. CMARK_EVENT_NONE,
  168. CMARK_EVENT_DONE,
  169. CMARK_EVENT_ENTER,
  170. CMARK_EVENT_EXIT
  171. } cmark_event_type;
  172. /** Creates a new iterator starting at 'root'. The current node and event
  173. * type are undefined until 'cmark_iter_next' is called for the first time.
  174. * The memory allocated for the iterator should be released using
  175. * 'cmark_iter_free' when it is no longer needed.
  176. */
  177. CMARK_EXPORT
  178. cmark_iter *cmark_iter_new(cmark_node *root);
  179. /** Frees the memory allocated for an iterator.
  180. */
  181. CMARK_EXPORT
  182. void cmark_iter_free(cmark_iter *iter);
  183. /** Advances to the next node and returns the event type (`CMARK_EVENT_ENTER`,
  184. * `CMARK_EVENT_EXIT` or `CMARK_EVENT_DONE`).
  185. */
  186. CMARK_EXPORT
  187. cmark_event_type cmark_iter_next(cmark_iter *iter);
  188. /** Returns the current node.
  189. */
  190. CMARK_EXPORT
  191. cmark_node *cmark_iter_get_node(cmark_iter *iter);
  192. /** Returns the current event type.
  193. */
  194. CMARK_EXPORT
  195. cmark_event_type cmark_iter_get_event_type(cmark_iter *iter);
  196. /** Returns the root node.
  197. */
  198. CMARK_EXPORT
  199. cmark_node *cmark_iter_get_root(cmark_iter *iter);
  200. /** Resets the iterator so that the current node is 'current' and
  201. * the event type is 'event_type'. The new current node must be a
  202. * descendant of the root node or the root node itself.
  203. */
  204. CMARK_EXPORT
  205. void cmark_iter_reset(cmark_iter *iter, cmark_node *current,
  206. cmark_event_type event_type);
  207. /**
  208. * ## Accessors
  209. */
  210. /** Returns the user data of 'node'.
  211. */
  212. CMARK_EXPORT void *cmark_node_get_user_data(cmark_node *node);
  213. /** Sets arbitrary user data for 'node'. Returns 1 on success,
  214. * 0 on failure.
  215. */
  216. CMARK_EXPORT int cmark_node_set_user_data(cmark_node *node, void *user_data);
  217. /** Returns the type of 'node', or `CMARK_NODE_NONE` on error.
  218. */
  219. CMARK_EXPORT cmark_node_type cmark_node_get_type(cmark_node *node);
  220. /** Like 'cmark_node_get_type', but returns a string representation
  221. of the type, or `"<unknown>"`.
  222. */
  223. CMARK_EXPORT
  224. const char *cmark_node_get_type_string(cmark_node *node);
  225. /** Returns the string contents of 'node', or an empty
  226. string if none is set. Returns NULL if called on a
  227. node that does not have string content.
  228. */
  229. CMARK_EXPORT const char *cmark_node_get_literal(cmark_node *node);
  230. /** Sets the string contents of 'node'. Returns 1 on success,
  231. * 0 on failure.
  232. */
  233. CMARK_EXPORT int cmark_node_set_literal(cmark_node *node, const char *content);
  234. /** Returns the heading level of 'node', or 0 if 'node' is not a heading.
  235. */
  236. CMARK_EXPORT int cmark_node_get_heading_level(cmark_node *node);
  237. /* For backwards compatibility */
  238. #define cmark_node_get_header_level cmark_node_get_heading_level
  239. #define cmark_node_set_header_level cmark_node_set_heading_level
  240. /** Sets the heading level of 'node', returning 1 on success and 0 on error.
  241. */
  242. CMARK_EXPORT int cmark_node_set_heading_level(cmark_node *node, int level);
  243. /** Returns the list type of 'node', or `CMARK_NO_LIST` if 'node'
  244. * is not a list.
  245. */
  246. CMARK_EXPORT cmark_list_type cmark_node_get_list_type(cmark_node *node);
  247. /** Sets the list type of 'node', returning 1 on success and 0 on error.
  248. */
  249. CMARK_EXPORT int cmark_node_set_list_type(cmark_node *node,
  250. cmark_list_type type);
  251. /** Returns the list delimiter type of 'node', or `CMARK_NO_DELIM` if 'node'
  252. * is not a list.
  253. */
  254. CMARK_EXPORT cmark_delim_type cmark_node_get_list_delim(cmark_node *node);
  255. /** Sets the list delimiter type of 'node', returning 1 on success and 0
  256. * on error.
  257. */
  258. CMARK_EXPORT int cmark_node_set_list_delim(cmark_node *node,
  259. cmark_delim_type delim);
  260. /** Returns starting number of 'node', if it is an ordered list, otherwise 0.
  261. */
  262. CMARK_EXPORT int cmark_node_get_list_start(cmark_node *node);
  263. /** Sets starting number of 'node', if it is an ordered list. Returns 1
  264. * on success, 0 on failure.
  265. */
  266. CMARK_EXPORT int cmark_node_set_list_start(cmark_node *node, int start);
  267. /** Returns 1 if 'node' is a tight list, 0 otherwise.
  268. */
  269. CMARK_EXPORT int cmark_node_get_list_tight(cmark_node *node);
  270. /** Sets the "tightness" of a list. Returns 1 on success, 0 on failure.
  271. */
  272. CMARK_EXPORT int cmark_node_set_list_tight(cmark_node *node, int tight);
  273. /** Returns the info string from a fenced code block.
  274. */
  275. CMARK_EXPORT const char *cmark_node_get_fence_info(cmark_node *node);
  276. /** Sets the info string in a fenced code block, returning 1 on
  277. * success and 0 on failure.
  278. */
  279. CMARK_EXPORT int cmark_node_set_fence_info(cmark_node *node, const char *info);
  280. /** Returns the URL of a link or image 'node', or an empty string
  281. if no URL is set. Returns NULL if called on a node that is
  282. not a link or image.
  283. */
  284. CMARK_EXPORT const char *cmark_node_get_url(cmark_node *node);
  285. /** Sets the URL of a link or image 'node'. Returns 1 on success,
  286. * 0 on failure.
  287. */
  288. CMARK_EXPORT int cmark_node_set_url(cmark_node *node, const char *url);
  289. /** Returns the title of a link or image 'node', or an empty
  290. string if no title is set. Returns NULL if called on a node
  291. that is not a link or image.
  292. */
  293. CMARK_EXPORT const char *cmark_node_get_title(cmark_node *node);
  294. /** Sets the title of a link or image 'node'. Returns 1 on success,
  295. * 0 on failure.
  296. */
  297. CMARK_EXPORT int cmark_node_set_title(cmark_node *node, const char *title);
  298. /** Returns the literal "on enter" text for a custom 'node', or
  299. an empty string if no on_enter is set. Returns NULL if called
  300. on a non-custom node.
  301. */
  302. CMARK_EXPORT const char *cmark_node_get_on_enter(cmark_node *node);
  303. /** Sets the literal text to render "on enter" for a custom 'node'.
  304. Any children of the node will be rendered after this text.
  305. Returns 1 on success 0 on failure.
  306. */
  307. CMARK_EXPORT int cmark_node_set_on_enter(cmark_node *node,
  308. const char *on_enter);
  309. /** Returns the literal "on exit" text for a custom 'node', or
  310. an empty string if no on_exit is set. Returns NULL if
  311. called on a non-custom node.
  312. */
  313. CMARK_EXPORT const char *cmark_node_get_on_exit(cmark_node *node);
  314. /** Sets the literal text to render "on exit" for a custom 'node'.
  315. Any children of the node will be rendered before this text.
  316. Returns 1 on success 0 on failure.
  317. */
  318. CMARK_EXPORT int cmark_node_set_on_exit(cmark_node *node, const char *on_exit);
  319. /** Returns the line on which 'node' begins.
  320. */
  321. CMARK_EXPORT int cmark_node_get_start_line(cmark_node *node);
  322. /** Returns the column at which 'node' begins.
  323. */
  324. CMARK_EXPORT int cmark_node_get_start_column(cmark_node *node);
  325. /** Returns the line on which 'node' ends.
  326. */
  327. CMARK_EXPORT int cmark_node_get_end_line(cmark_node *node);
  328. /** Returns the column at which 'node' ends.
  329. */
  330. CMARK_EXPORT int cmark_node_get_end_column(cmark_node *node);
  331. /**
  332. * ## Tree Manipulation
  333. */
  334. /** Unlinks a 'node', removing it from the tree, but not freeing its
  335. * memory. (Use 'cmark_node_free' for that.)
  336. */
  337. CMARK_EXPORT void cmark_node_unlink(cmark_node *node);
  338. /** Inserts 'sibling' before 'node'. Returns 1 on success, 0 on failure.
  339. */
  340. CMARK_EXPORT int cmark_node_insert_before(cmark_node *node,
  341. cmark_node *sibling);
  342. /** Inserts 'sibling' after 'node'. Returns 1 on success, 0 on failure.
  343. */
  344. CMARK_EXPORT int cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
  345. /** Replaces 'oldnode' with 'newnode' and unlinks 'oldnode' (but does
  346. * not free its memory).
  347. * Returns 1 on success, 0 on failure.
  348. */
  349. CMARK_EXPORT int cmark_node_replace(cmark_node *oldnode, cmark_node *newnode);
  350. /** Adds 'child' to the beginning of the children of 'node'.
  351. * Returns 1 on success, 0 on failure.
  352. */
  353. CMARK_EXPORT int cmark_node_prepend_child(cmark_node *node, cmark_node *child);
  354. /** Adds 'child' to the end of the children of 'node'.
  355. * Returns 1 on success, 0 on failure.
  356. */
  357. CMARK_EXPORT int cmark_node_append_child(cmark_node *node, cmark_node *child);
  358. /** Consolidates adjacent text nodes.
  359. */
  360. CMARK_EXPORT void cmark_consolidate_text_nodes(cmark_node *root);
  361. /**
  362. * ## Parsing
  363. *
  364. * Simple interface:
  365. *
  366. * cmark_node *document = cmark_parse_document("Hello *world*", 13,
  367. * CMARK_OPT_DEFAULT);
  368. *
  369. * Streaming interface:
  370. *
  371. * cmark_parser *parser = cmark_parser_new(CMARK_OPT_DEFAULT);
  372. * FILE *fp = fopen("myfile.md", "rb");
  373. * while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
  374. * cmark_parser_feed(parser, buffer, bytes);
  375. * if (bytes < sizeof(buffer)) {
  376. * break;
  377. * }
  378. * }
  379. * document = cmark_parser_finish(parser);
  380. * cmark_parser_free(parser);
  381. */
  382. /** Creates a new parser object.
  383. */
  384. CMARK_EXPORT
  385. cmark_parser *cmark_parser_new(int options);
  386. /** Creates a new parser object with the given memory allocator
  387. */
  388. CMARK_EXPORT
  389. cmark_parser *cmark_parser_new_with_mem(int options, cmark_mem *mem);
  390. /** Frees memory allocated for a parser object.
  391. */
  392. CMARK_EXPORT
  393. void cmark_parser_free(cmark_parser *parser);
  394. /** Feeds a string of length 'len' to 'parser'.
  395. */
  396. CMARK_EXPORT
  397. void cmark_parser_feed(cmark_parser *parser, const char *buffer, size_t len);
  398. /** Finish parsing and return a pointer to a tree of nodes.
  399. */
  400. CMARK_EXPORT
  401. cmark_node *cmark_parser_finish(cmark_parser *parser);
  402. /** Parse a CommonMark document in 'buffer' of length 'len'.
  403. * Returns a pointer to a tree of nodes. The memory allocated for
  404. * the node tree should be released using 'cmark_node_free'
  405. * when it is no longer needed.
  406. */
  407. CMARK_EXPORT
  408. cmark_node *cmark_parse_document(const char *buffer, size_t len, int options);
  409. /** Parse a CommonMark document in file 'f', returning a pointer to
  410. * a tree of nodes. The memory allocated for the node tree should be
  411. * released using 'cmark_node_free' when it is no longer needed.
  412. */
  413. CMARK_EXPORT
  414. cmark_node *cmark_parse_file(FILE *f, int options);
  415. /**
  416. * ## Rendering
  417. */
  418. /** Render a 'node' tree as XML. It is the caller's responsibility
  419. * to free the returned buffer.
  420. */
  421. CMARK_EXPORT
  422. char *cmark_render_xml(cmark_node *root, int options);
  423. /** Render a 'node' tree as an HTML fragment. It is up to the user
  424. * to add an appropriate header and footer. It is the caller's
  425. * responsibility to free the returned buffer.
  426. */
  427. CMARK_EXPORT
  428. char *cmark_render_html(cmark_node *root, int options);
  429. /** Render a 'node' tree as a groff man page, without the header.
  430. * It is the caller's responsibility to free the returned buffer.
  431. */
  432. CMARK_EXPORT
  433. char *cmark_render_man(cmark_node *root, int options, int width);
  434. /** Render a 'node' tree as a commonmark document.
  435. * It is the caller's responsibility to free the returned buffer.
  436. */
  437. CMARK_EXPORT
  438. char *cmark_render_commonmark(cmark_node *root, int options, int width);
  439. /** Render a 'node' tree as a LaTeX document.
  440. * It is the caller's responsibility to free the returned buffer.
  441. */
  442. CMARK_EXPORT
  443. char *cmark_render_latex(cmark_node *root, int options, int width);
  444. /**
  445. * ## Options
  446. */
  447. /** Default options.
  448. */
  449. #define CMARK_OPT_DEFAULT 0
  450. /**
  451. * ### Options affecting rendering
  452. */
  453. /** Include a `data-sourcepos` attribute on all block elements.
  454. */
  455. #define CMARK_OPT_SOURCEPOS (1 << 1)
  456. /** Render `softbreak` elements as hard line breaks.
  457. */
  458. #define CMARK_OPT_HARDBREAKS (1 << 2)
  459. /** `CMARK_OPT_SAFE` is defined here for API compatibility,
  460. but it no longer has any effect. "Safe" mode is now the default:
  461. set `CMARK_OPT_UNSAFE` to disable it.
  462. */
  463. #define CMARK_OPT_SAFE (1 << 3)
  464. /** Render raw HTML and unsafe links (`javascript:`, `vbscript:`,
  465. * `file:`, and `data:`, except for `image/png`, `image/gif`,
  466. * `image/jpeg`, or `image/webp` mime types). By default,
  467. * raw HTML is replaced by a placeholder HTML comment. Unsafe
  468. * links are replaced by empty strings.
  469. */
  470. #define CMARK_OPT_UNSAFE (1 << 17)
  471. /** Render `softbreak` elements as spaces.
  472. */
  473. #define CMARK_OPT_NOBREAKS (1 << 4)
  474. /**
  475. * ### Options affecting parsing
  476. */
  477. /** Legacy option (no effect).
  478. */
  479. #define CMARK_OPT_NORMALIZE (1 << 8)
  480. /** Validate UTF-8 in the input before parsing, replacing illegal
  481. * sequences with the replacement character U+FFFD.
  482. */
  483. #define CMARK_OPT_VALIDATE_UTF8 (1 << 9)
  484. /** Convert straight quotes to curly, --- to em dashes, -- to en dashes.
  485. */
  486. #define CMARK_OPT_SMART (1 << 10)
  487. /**
  488. * ## Version information
  489. */
  490. /** The library version as integer for runtime checks. Also available as
  491. * macro CMARK_VERSION for compile time checks.
  492. *
  493. * * Bits 16-23 contain the major version.
  494. * * Bits 8-15 contain the minor version.
  495. * * Bits 0-7 contain the patchlevel.
  496. *
  497. * In hexadecimal format, the number 0x010203 represents version 1.2.3.
  498. */
  499. CMARK_EXPORT
  500. int cmark_version(void);
  501. /** The library version string for runtime checks. Also available as
  502. * macro CMARK_VERSION_STRING for compile time checks.
  503. */
  504. CMARK_EXPORT
  505. const char *cmark_version_string(void);
  506. /** # AUTHORS
  507. *
  508. * John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
  509. */
  510. #ifndef CMARK_NO_SHORT_NAMES
  511. #define NODE_DOCUMENT CMARK_NODE_DOCUMENT
  512. #define NODE_BLOCK_QUOTE CMARK_NODE_BLOCK_QUOTE
  513. #define NODE_LIST CMARK_NODE_LIST
  514. #define NODE_ITEM CMARK_NODE_ITEM
  515. #define NODE_CODE_BLOCK CMARK_NODE_CODE_BLOCK
  516. #define NODE_HTML_BLOCK CMARK_NODE_HTML_BLOCK
  517. #define NODE_CUSTOM_BLOCK CMARK_NODE_CUSTOM_BLOCK
  518. #define NODE_PARAGRAPH CMARK_NODE_PARAGRAPH
  519. #define NODE_HEADING CMARK_NODE_HEADING
  520. #define NODE_HEADER CMARK_NODE_HEADER
  521. #define NODE_THEMATIC_BREAK CMARK_NODE_THEMATIC_BREAK
  522. #define NODE_HRULE CMARK_NODE_HRULE
  523. #define NODE_TEXT CMARK_NODE_TEXT
  524. #define NODE_SOFTBREAK CMARK_NODE_SOFTBREAK
  525. #define NODE_LINEBREAK CMARK_NODE_LINEBREAK
  526. #define NODE_CODE CMARK_NODE_CODE
  527. #define NODE_HTML_INLINE CMARK_NODE_HTML_INLINE
  528. #define NODE_CUSTOM_INLINE CMARK_NODE_CUSTOM_INLINE
  529. #define NODE_EMPH CMARK_NODE_EMPH
  530. #define NODE_STRONG CMARK_NODE_STRONG
  531. #define NODE_LINK CMARK_NODE_LINK
  532. #define NODE_IMAGE CMARK_NODE_IMAGE
  533. #define BULLET_LIST CMARK_BULLET_LIST
  534. #define ORDERED_LIST CMARK_ORDERED_LIST
  535. #define PERIOD_DELIM CMARK_PERIOD_DELIM
  536. #define PAREN_DELIM CMARK_PAREN_DELIM
  537. #endif
  538. #ifdef __cplusplus
  539. }
  540. #endif
  541. #endif