diff --git a/types/marked/index.d.ts b/types/marked/index.d.ts index a4dc048cc8..034c0cca18 100644 --- a/types/marked/index.d.ts +++ b/types/marked/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Marked 0.3 +// Type definitions for Marked 0.4 // Project: https://github.com/chjj/marked // Definitions by: William Orr // BendingBender +// CrossR // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace marked; @@ -202,21 +203,9 @@ declare namespace marked { interface MarkedOptions { /** - * Type: object Default: new Renderer() - * - * An object containing functions to render tokens to HTML. + * A prefix URL for any relative link. */ - renderer?: Renderer; - - /** - * Enable GitHub flavored markdown. - */ - gfm?: boolean; - - /** - * Enable GFM tables. This option requires the gfm option to be true. - */ - tables?: boolean; + baseUrl?: string; /** * Enable GFM line breaks. This option requires the gfm option to be true. @@ -224,34 +213,19 @@ declare namespace marked { breaks?: boolean; /** - * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior. + * Enable GitHub flavored markdown. */ - pedantic?: boolean; + gfm?: boolean; /** - * Sanitize the output. Ignore any HTML that has been input. + * Include an id attribute when emitting headings. */ - sanitize?: boolean; + headerIds?: boolean; /** - * Optionally sanitize found HTML with a sanitizer function. + * Set the prefix for header tag ids. */ - sanitizer?(html: string): string; - - /** - * Mangle autolinks (). - */ - mangle?: boolean; - - /** - * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic. - */ - smartLists?: boolean; - - /** - * Shows an HTML error message when rendering fails. - */ - silent?: boolean; + headerPrefix?: string; /** * A function to highlight code blocks. The function takes three arguments: code, lang, and callback. @@ -263,15 +237,52 @@ declare namespace marked { */ langPrefix?: string; + /** + * Mangle autolinks (). + */ + mangle?: boolean; + + /** + * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior. + */ + pedantic?: boolean; + + /** + * Type: object Default: new Renderer() + * + * An object containing functions to render tokens to HTML. + */ + renderer?: Renderer; + + /** + * Sanitize the output. Ignore any HTML that has been input. + */ + sanitize?: boolean; + + /** + * Optionally sanitize found HTML with a sanitizer function. + */ + sanitizer?(html: string): string; + + /** + * Shows an HTML error message when rendering fails. + */ + silent?: boolean; + + /** + * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic. + */ + smartLists?: boolean; + /** * Use "smart" typograhic punctuation for things like quotes and dashes. */ smartypants?: boolean; /** - * Set the prefix for header tag ids. + * Enable GFM tables. This option requires the gfm option to be true. */ - headerPrefix?: string; + tables?: boolean; /** * Generate closing slash for self-closing tags (
instead of
) diff --git a/types/marked/marked-tests.ts b/types/marked/marked-tests.ts index 9499de3a56..8a80f2966c 100644 --- a/types/marked/marked-tests.ts +++ b/types/marked/marked-tests.ts @@ -1,6 +1,7 @@ import * as marked from 'marked'; const options: marked.MarkedOptions = { + baseUrl: '', gfm: true, tables: true, breaks: false, @@ -16,23 +17,24 @@ const options: marked.MarkedOptions = { renderer: new marked.Renderer() }; -function callback() { - console.log('callback called'); +function callback(err: string, markdown: string) { + console.log("Callback called!"); + return markdown } const myOldMarked: typeof marked = marked.setOptions(options); -console.log(marked('i am using __markdown__.')); -console.log(marked('i am using __markdown__.', options)); -console.log(marked('i am using __markdown__.', callback)); -console.log(marked('i am using __markdown__.', options, callback)); +console.log(marked('1) I am using __markdown__.')); +console.log(marked('2) I am using __markdown__.', options)); +console.log(marked('3) I am using __markdown__.', callback)); +console.log(marked('4) I am using __markdown__.', options, callback)); -console.log(marked.parse('i am using __markdown__.')); -console.log(marked.parse('i am using __markdown__.', options)); -console.log(marked.parse('i am using __markdown__.', callback)); -console.log(marked.parse('i am using __markdown__.', options, callback)); +console.log(marked.parse('5) I am using __markdown__.')); +console.log(marked.parse('6) I am using __markdown__.', options)); +console.log(marked.parse('7) I am using __markdown__.', callback)); +console.log(marked.parse('8) I am using __markdown__.', options, callback)); -const text = 'something'; +const text = 'Something'; const tokens: marked.TokensList = marked.lexer(text, options); console.log(marked.parser(tokens));