latex.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #ifndef __LATEX__
  2. #define __LATEX__
  3. #include <stdbool.h>
  4. #include <time.h>
  5. #include <hoedown/document.h>
  6. #include <hoedown/buffer.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /*********
  11. * TYPES *
  12. *********/
  13. struct hoedown_latex_title_data {
  14. char* title;
  15. char* author;
  16. char* date;
  17. bool date_given;
  18. };
  19. typedef struct hoedown_latex_title_data hoedown_latex_title_data;
  20. struct hoedown_latex_renderer_state {
  21. void *opaque;
  22. hoedown_latex_title_data titledata;
  23. bool use_minted;
  24. int column_number;
  25. };
  26. typedef struct hoedown_latex_renderer_state hoedown_latex_renderer_state;
  27. typedef struct latex_character_escape {
  28. char special;
  29. char* repl;
  30. } latex_character_escape;
  31. /*************
  32. * CONSTANTS *
  33. *************/
  34. static const latex_character_escape escapes[] = {
  35. {'\\', "\\backslash"},
  36. {'&', "\\&"},
  37. {'#', "\\#"},
  38. {'_', "\\_"},
  39. {'%', "\\%"},
  40. {'~', "$\\sim$"},
  41. {'{', "$\\{$"},
  42. {'}', "$\\}$"},
  43. {'^', "$\\wedge$"}
  44. };
  45. /* Partial list of languages supported by minted. */
  46. static const char* pygment_langs[] = {
  47. "ActionScript",
  48. "Ada",
  49. "ANTLR",
  50. "AppleScript",
  51. "Assembly",
  52. "Asymptote",
  53. "Awk",
  54. "Befunge",
  55. "Boo",
  56. "BrainFuck",
  57. "C",
  58. "C++",
  59. "C#",
  60. "Clojure",
  61. "CoffeeScript",
  62. "ColdFusion",
  63. "Common Lisp",
  64. "Coq",
  65. "Cryptol",
  66. "Cython",
  67. "D",
  68. "Dart",
  69. "Delphi",
  70. "Dylan",
  71. "Erlang",
  72. "Factor",
  73. "Fancy",
  74. "Fortran",
  75. "F#",
  76. "GAP",
  77. "Gherkin",
  78. "Groovy",
  79. "Haskell",
  80. "IDL",
  81. "Io",
  82. "Java",
  83. "JavaScript",
  84. "Lasso",
  85. "LLVM",
  86. "Logtalk",
  87. "Lua",
  88. "Matlab",
  89. "MiniD",
  90. "Modelica",
  91. "Modula-2",
  92. "MuPad",
  93. "Nemerle",
  94. "Nimrod",
  95. "Objective-C",
  96. "Objective-J",
  97. "Octave",
  98. "OCaml",
  99. "PHP",
  100. "Perl",
  101. "PovRay",
  102. "PostScript",
  103. "PowerShell",
  104. "Prolog",
  105. "Python",
  106. "REBOL",
  107. "Red",
  108. "Redcode",
  109. "Ruby",
  110. "Rust",
  111. "S",
  112. "S-Plus",
  113. "R",
  114. "Scala",
  115. "Scheme",
  116. "Scilab",
  117. "Smalltalk",
  118. "SNOBOL",
  119. "Tcl",
  120. "Vala",
  121. "Verilog",
  122. "VHDL",
  123. "XQuery",
  124. "Zephir",
  125. "Cheetah",
  126. "Django",
  127. "Jinja",
  128. "ERB",
  129. "Genshi",
  130. "JSP",
  131. "Myghty",
  132. "Mako",
  133. "Smarty",
  134. "Tea",
  135. "Bash",
  136. "BBCode",
  137. "CMake",
  138. "CSS",
  139. "Diff",
  140. "DTD",
  141. "Gnuplot",
  142. "Groff",
  143. "HTML",
  144. "INI",
  145. "IRC",
  146. "Makefiles",
  147. "MoinMoin",
  148. "Trac",
  149. "MySQL",
  150. "Nginx",
  151. "POV-Ray",
  152. "Ragel",
  153. "Redcode",
  154. "ReST",
  155. "Robot",
  156. "SQL",
  157. "SQLite",
  158. "Squid",
  159. "TeX",
  160. "tcsh",
  161. "Vim",
  162. "XML",
  163. "XSLT",
  164. "YAML"
  165. };
  166. /*************
  167. * FUNCTIONS *
  168. *************/
  169. /* hoedown_latex_renderer_new: allocates a regular LaTeX renderer */
  170. hoedown_renderer *hoedown_latex_renderer_new(hoedown_latex_title_data* td, bool mint)
  171. __attribute__ ((malloc));
  172. /* hoedown_latex_renderer_free: deallocate a LaTeX renderer */
  173. void hoedown_latex_renderer_free(hoedown_renderer * renderer);
  174. void hoedown_render(FILE* fp, hoedown_latex_title_data* td, bool mint);
  175. void free_title_data(hoedown_latex_title_data* td);
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif /** __LATEX__ **/