mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Update MarkedOptions for 0.4.
Alphabetised options to bring in line with package docs. Also updated tests to pass, and be a bit clearer.
This commit is contained in:
Vendored
+49
-38
@@ -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 <https://github.com/worr>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// CrossR <https://github.com/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 (<email@domain.com>).
|
||||
*/
|
||||
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 (<email@domain.com>).
|
||||
*/
|
||||
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 (<br/> instead of <br>)
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user