aboutsummaryrefslogtreecommitdiff
path: root/src/scanners.h
blob: 86dbcf51f5f56230bbefeb1d091fcb53c91c3272 (plain)
  1. #include "cmark.h"
  2. extern int _scan_autolink_uri(const unsigned char *p);
  3. extern int _scan_autolink_email(const unsigned char *p);
  4. extern int _scan_html_tag(const unsigned char *p);
  5. extern int _scan_html_block_tag(const unsigned char *p);
  6. extern int _scan_link_url(const unsigned char *p);
  7. extern int _scan_link_title(const unsigned char *p);
  8. extern int _scan_spacechars(const unsigned char *p);
  9. extern int _scan_atx_header_start(const unsigned char *p);
  10. extern int _scan_setext_header_line(const unsigned char *p);
  11. extern int _scan_hrule(const unsigned char *p);
  12. extern int _scan_open_code_fence(const unsigned char *p);
  13. extern int _scan_close_code_fence(const unsigned char *p);
  14. extern int _scan_entity(const unsigned char *p);
  15. static int scan_at(int (*scanner)(const unsigned char *), chunk *c, int offset)
  16. {
  17. int res;
  18. unsigned char *ptr = (unsigned char *)c->data;
  19. unsigned char lim = ptr[c->len];
  20. ptr[c->len] = '\0';
  21. res = scanner(ptr + offset);
  22. ptr[c->len] = lim;
  23. return res;
  24. }
  25. #define scan_autolink_uri(c, n) scan_at(&_scan_autolink_uri, c, n)
  26. #define scan_autolink_email(c, n) scan_at(&_scan_autolink_email, c, n)
  27. #define scan_html_tag(c, n) scan_at(&_scan_html_tag, c, n)
  28. #define scan_html_block_tag(c, n) scan_at(&_scan_html_block_tag, c, n)
  29. #define scan_link_url(c, n) scan_at(&_scan_link_url, c, n)
  30. #define scan_link_title(c, n) scan_at(&_scan_link_title, c, n)
  31. #define scan_spacechars(c, n) scan_at(&_scan_spacechars, c, n)
  32. #define scan_atx_header_start(c, n) scan_at(&_scan_atx_header_start, c, n)
  33. #define scan_setext_header_line(c, n) scan_at(&_scan_setext_header_line, c, n)
  34. #define scan_hrule(c, n) scan_at(&_scan_hrule, c, n)
  35. #define scan_open_code_fence(c, n) scan_at(&_scan_open_code_fence, c, n)
  36. #define scan_close_code_fence(c, n) scan_at(&_scan_close_code_fence, c, n)
  37. #define scan_entity(c, n) scan_at(&_scan_entity, c, n)