node.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef CMARK_NODE_H
  2. #define CMARK_NODE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdio.h>
  7. #include <stdint.h>
  8. #include "cmark.h"
  9. #include "buffer.h"
  10. #include "chunk.h"
  11. typedef struct {
  12. cmark_list_type list_type;
  13. int marker_offset;
  14. int padding;
  15. int start;
  16. cmark_delim_type delimiter;
  17. unsigned char bullet_char;
  18. bool tight;
  19. } cmark_list;
  20. typedef struct {
  21. cmark_chunk info;
  22. cmark_chunk literal;
  23. uint8_t fence_length;
  24. uint8_t fence_offset;
  25. unsigned char fence_char;
  26. int8_t fenced;
  27. } cmark_code;
  28. typedef struct {
  29. int level;
  30. bool setext;
  31. } cmark_heading;
  32. typedef struct {
  33. cmark_chunk url;
  34. cmark_chunk title;
  35. } cmark_link;
  36. typedef struct {
  37. cmark_chunk on_enter;
  38. cmark_chunk on_exit;
  39. } cmark_custom;
  40. enum cmark_node__internal_flags {
  41. CMARK_NODE__OPEN = (1 << 0),
  42. CMARK_NODE__LAST_LINE_BLANK = (1 << 1),
  43. CMARK_NODE__LAST_LINE_CHECKED = (1 << 2),
  44. };
  45. struct cmark_node {
  46. cmark_strbuf content;
  47. struct cmark_node *next;
  48. struct cmark_node *prev;
  49. struct cmark_node *parent;
  50. struct cmark_node *first_child;
  51. struct cmark_node *last_child;
  52. void *user_data;
  53. int start_line;
  54. int start_column;
  55. int end_line;
  56. int end_column;
  57. int internal_offset;
  58. uint16_t type;
  59. uint16_t flags;
  60. union {
  61. cmark_chunk literal;
  62. cmark_list list;
  63. cmark_code code;
  64. cmark_heading heading;
  65. cmark_link link;
  66. cmark_custom custom;
  67. int html_block_type;
  68. } as;
  69. };
  70. static CMARK_INLINE cmark_mem *cmark_node_mem(cmark_node *node) {
  71. return node->content.mem;
  72. }
  73. CMARK_EXPORT int cmark_node_check(cmark_node *node, FILE *out);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif