marked.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Type definitions for Marked
  2. // Project: https://github.com/chjj/marked
  3. // Definitions by: William Orr <https://github.com/worr>
  4. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  5. interface MarkedStatic {
  6. /**
  7. * Compiles markdown to HTML.
  8. *
  9. * @param src String of markdown source to be compiled
  10. * @param callback Function called when the markdownString has been fully parsed when using async highlighting
  11. * @return String of compiled HTML
  12. */
  13. (src: string, callback: Function): string;
  14. /**
  15. * Compiles markdown to HTML.
  16. *
  17. * @param src String of markdown source to be compiled
  18. * @param options Hash of options
  19. * @param callback Function called when the markdownString has been fully parsed when using async highlighting
  20. * @return String of compiled HTML
  21. */
  22. (src: string, options?: MarkedOptions, callback?: Function): string;
  23. /**
  24. * @param src String of markdown source to be compiled
  25. * @param options Hash of options
  26. */
  27. lexer(src: string, options?: MarkedOptions): any[];
  28. /**
  29. * Compiles markdown to HTML.
  30. *
  31. * @param src String of markdown source to be compiled
  32. * @param callback Function called when the markdownString has been fully parsed when using async highlighting
  33. * @return String of compiled HTML
  34. */
  35. parse(src: string, callback: Function): string;
  36. /**
  37. * Compiles markdown to HTML.
  38. *
  39. * @param src String of markdown source to be compiled
  40. * @param options Hash of options
  41. * @param callback Function called when the markdownString has been fully parsed when using async highlighting
  42. * @return String of compiled HTML
  43. */
  44. parse(src: string, options?: MarkedOptions, callback?: Function): string;
  45. /**
  46. * @param options Hash of options
  47. */
  48. parser(src: any[], options?: MarkedOptions): string;
  49. /**
  50. * Sets the default options.
  51. *
  52. * @param options Hash of options
  53. */
  54. setOptions(options: MarkedOptions): void;
  55. }
  56. interface MarkedOptions {
  57. /**
  58. * Type: object Default: new Renderer()
  59. *
  60. * An object containing functions to render tokens to HTML.
  61. */
  62. renderer?: Object;
  63. /**
  64. * Enable GitHub flavored markdown.
  65. */
  66. gfm?: boolean;
  67. /**
  68. * Enable GFM tables. This option requires the gfm option to be true.
  69. */
  70. tables?: boolean;
  71. /**
  72. * Enable GFM line breaks. This option requires the gfm option to be true.
  73. */
  74. breaks?: boolean;
  75. /**
  76. * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
  77. */
  78. pedantic?: boolean;
  79. /**
  80. * Sanitize the output. Ignore any HTML that has been input.
  81. */
  82. sanitize?: boolean;
  83. /**
  84. * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
  85. */
  86. smartLists?: boolean;
  87. /**
  88. * Shows an HTML error message when rendering fails.
  89. */
  90. silent?: boolean;
  91. /**
  92. * A function to highlight code blocks. The function takes three arguments: code, lang, and callback.
  93. */
  94. highlight? (code: string, lang: string, callback?: Function): string;
  95. /**
  96. * Set the prefix for code block classes.
  97. */
  98. langPrefix?: string;
  99. /**
  100. * Use "smart" typograhic punctuation for things like quotes and dashes.
  101. */
  102. smartypants?: boolean;
  103. }
  104. declare module "marked" {
  105. export = marked;
  106. }
  107. declare var marked: MarkedStatic;