render.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef CMARK_RENDER_H
  2. #define CMARK_RENDER_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdlib.h>
  7. #include "buffer.h"
  8. #include "chunk.h"
  9. typedef enum { LITERAL, NORMAL, TITLE, URL } cmark_escaping;
  10. struct cmark_renderer {
  11. cmark_mem *mem;
  12. cmark_strbuf *buffer;
  13. cmark_strbuf *prefix;
  14. int column;
  15. int width;
  16. int need_cr;
  17. bufsize_t last_breakable;
  18. bool begin_line;
  19. bool begin_content;
  20. bool no_linebreaks;
  21. bool in_tight_list_item;
  22. void (*outc)(struct cmark_renderer *, cmark_escaping, int32_t, unsigned char);
  23. void (*cr)(struct cmark_renderer *);
  24. void (*blankline)(struct cmark_renderer *);
  25. void (*out)(struct cmark_renderer *, const char *, bool, cmark_escaping);
  26. };
  27. typedef struct cmark_renderer cmark_renderer;
  28. void cmark_render_ascii(cmark_renderer *renderer, const char *s);
  29. void cmark_render_code_point(cmark_renderer *renderer, uint32_t c);
  30. char *cmark_render(cmark_node *root, int options, int width,
  31. void (*outc)(cmark_renderer *, cmark_escaping, int32_t,
  32. unsigned char),
  33. int (*render_node)(cmark_renderer *renderer,
  34. cmark_node *node,
  35. cmark_event_type ev_type, int options));
  36. #ifdef __cplusplus
  37. }
  38. #endif
  39. #endif