mkdio.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #ifndef _MKDIO_D
  2. #define _MKDIO_D
  3. #include <stdio.h>
  4. #include <inttypes.h>
  5. typedef void MMIOT;
  6. /* special flags for markdown() and mkd_text()
  7. */
  8. enum { MKD_NOLINKS=0, /* don't do link processing, block <a> tags */
  9. MKD_NOIMAGE, /* don't do image processing, block <img> */
  10. MKD_NOPANTS, /* don't run smartypants() */
  11. MKD_NOHTML, /* don't allow raw html through AT ALL */
  12. MKD_NORMAL_LISTITEM, /* disable github-style checkbox lists */
  13. MKD_TAGTEXT, /* process text inside an html tag */
  14. MKD_NO_EXT, /* don't allow pseudo-protocols */
  15. #define MKD_NOEXT MKD_NO_EXT
  16. MKD_EXPLICITLIST, /* don't combine numbered/bulletted lists */
  17. MKD_CDATA, /* generate code for xml ![CDATA[...]] */
  18. MKD_NOSUPERSCRIPT, /* no A^B */
  19. MKD_NORELAXED, /* emphasis happens /everywhere/ */
  20. MKD_NOTABLES, /* disallow tables */
  21. MKD_NOSTRIKETHROUGH, /* forbid ~~strikethrough~~ */
  22. MKD_1_COMPAT, /* compatibility with MarkdownTest_1.0 */
  23. MKD_TOC, /* do table-of-contents processing */
  24. MKD_AUTOLINK, /* make http://foo.com link even without <>s */
  25. MKD_NOHEADER, /* don't process header blocks */
  26. MKD_TABSTOP, /* expand tabs to 4 spaces */
  27. MKD_SAFELINK, /* paranoid check for link protocol */
  28. MKD_NODIVQUOTE, /* forbid >%class% blocks */
  29. MKD_NOALPHALIST, /* forbid alphabetic lists */
  30. MKD_EXTRA_FOOTNOTE, /* enable markdown extra-style footnotes */
  31. MKD_NOSTYLE, /* don't extract <style> blocks */
  32. MKD_DLDISCOUNT, /* enable discount-style definition lists */
  33. MKD_DLEXTRA, /* enable extra-style definition lists */
  34. MKD_FENCEDCODE, /* enabled fenced code blocks */
  35. MKD_IDANCHOR, /* use id= anchors for TOC links */
  36. MKD_GITHUBTAGS, /* allow dash and underscore in element names */
  37. MKD_URLENCODEDANCHOR, /* urlencode non-identifier chars instead of replacing with dots */
  38. MKD_LATEX, /* handle embedded LaTeX escapes */
  39. MKD_NR_FLAGS };
  40. /* abstract flag type */
  41. typedef void mkd_flag_t;
  42. int mkd_flag_isset(mkd_flag_t*, int); /* check a flag status */
  43. mkd_flag_t *mkd_flags(); /* create a flag blob */
  44. void mkd_free_flags(mkd_flag_t*); /* delete a flag blob */
  45. char *mkd_set_flag_string(mkd_flag_t*, char*); /* set named flags */
  46. void mkd_set_flag_num(mkd_flag_t*, unsigned long);/* set a specific flag */
  47. void mkd_clr_flag_num(mkd_flag_t*, unsigned long);/* clear a specific flag */
  48. void mkd_set_flag_bitmap(mkd_flag_t*,long); /* set a bunch of flags */
  49. /*
  50. * sneakily back-define the published interface (leaving the old functions for v2 compatibility)
  51. */
  52. #define mkd_in mkd3_in
  53. #define mkd_string mkd3_string
  54. #define gfm_in gfm3_in
  55. #define gfm_string gfm3_string
  56. #define mkd_compile mkd3_compile
  57. #define mkd_dump mkd3_dump
  58. #define markdown markdown3
  59. #define mkd_line mkd3_line
  60. #define mkd_xhtmlpage mkd3_xhtmlpage
  61. #define mkd_generateline mkd3_generateline
  62. #define mkd_flags_are mkd3_flags_are
  63. /* line builder for markdown()
  64. */
  65. MMIOT *mkd_in(FILE*,mkd_flag_t*); /* assemble input from a file */
  66. MMIOT *mkd_string(const char*,int,mkd_flag_t*); /* assemble input from a buffer */
  67. /* line builder for github flavoured markdown
  68. */
  69. MMIOT *gfm_in(FILE*,mkd_flag_t*); /* assemble input from a file */
  70. MMIOT *gfm_string(const char*,int,mkd_flag_t*); /* assemble input from a buffer */
  71. void mkd_basename(MMIOT*,char*);
  72. void mkd_initialize();
  73. void mkd_with_html5_tags();
  74. void mkd_shlib_destructor();
  75. /* compilation, debugging, cleanup
  76. */
  77. int mkd_compile(MMIOT*, mkd_flag_t*);
  78. void mkd_cleanup(MMIOT*);
  79. /* markup functions
  80. */
  81. int mkd_dump(MMIOT*, FILE*, mkd_flag_t*, char*);
  82. int markdown(MMIOT*, FILE*, mkd_flag_t*);
  83. int mkd_line(char *, int, char **, mkd_flag_t*);
  84. int mkd_xhtmlpage(MMIOT*,mkd_flag_t*,FILE*);
  85. /* header block access
  86. */
  87. char* mkd_doc_title(MMIOT*);
  88. char* mkd_doc_author(MMIOT*);
  89. char* mkd_doc_date(MMIOT*);
  90. /* compiled data access
  91. */
  92. int mkd_document(MMIOT*, char**);
  93. int mkd_toc(MMIOT*, char**);
  94. int mkd_css(MMIOT*, char **);
  95. int mkd_xml(char *, int, char **);
  96. /* write-to-file functions
  97. */
  98. int mkd_generatehtml(MMIOT*,FILE*);
  99. int mkd_generatetoc(MMIOT*,FILE*);
  100. int mkd_generatexml(char *, int,FILE*);
  101. int mkd_generatecss(MMIOT*,FILE*);
  102. #define mkd_style mkd_generatecss
  103. int mkd_generateline(char *, int, FILE*, mkd_flag_t*);
  104. #define mkd_text mkd_generateline
  105. /* url generator callbacks
  106. */
  107. typedef char * (*mkd_callback_t)(const char*, const int, void*);
  108. typedef void (*mkd_free_t)(char*, void*);
  109. void mkd_e_url(void *, mkd_callback_t);
  110. void mkd_e_flags(void *, mkd_callback_t);
  111. void mkd_e_anchor(void *, mkd_callback_t);
  112. void mkd_e_code_format(void*, mkd_callback_t);
  113. void mkd_e_free(void *, mkd_free_t );
  114. void mkd_e_data(void *, void *);
  115. /* version#.
  116. */
  117. extern char markdown_version[];
  118. void mkd_mmiot_flags(FILE *, MMIOT *, int);
  119. void mkd_flags_are(FILE*, mkd_flag_t*, int);
  120. void mkd_ref_prefix(MMIOT*, char*);
  121. #endif/*_MKDIO_D*/