@@ -19,6 +19,9 @@ const markedInstance = new Marked();
1919/**
2020 * Compiles markdown to HTML asynchronously.
2121 *
22+ * To configure hooks, a renderer, or a tokenizer, create a `Marked` instance
23+ * and use `Marked#use` instead of passing them as options on each call.
24+ *
2225 * @param src String of markdown source to be compiled
2326 * @param options Hash of options, having async: true
2427 * @return Promise of string of compiled HTML
@@ -28,6 +31,9 @@ export function marked(src: string, options: MarkedOptions & { async: true }): P
2831/**
2932 * Compiles markdown to HTML.
3033 *
34+ * To configure hooks, a renderer, or a tokenizer, create a `Marked` instance
35+ * and use `Marked#use` instead of passing them as options on each call.
36+ *
3137 * @param src String of markdown source to be compiled
3238 * @param options Optional hash of options
3339 * @return String of compiled HTML. Will be a Promise of string if async is set to true by any extensions.
@@ -39,6 +45,27 @@ export function marked(src: string, opt?: MarkedOptions | null): string | Promis
3945 return markedInstance . parse ( src , opt ) ;
4046}
4147
48+ export declare namespace marked {
49+ /**
50+ * Compiles inline markdown to HTML.
51+ *
52+ * To configure hooks, a renderer, or a tokenizer, create a `Marked` instance
53+ * and use `Marked#use` instead of passing them as options on each call.
54+ */
55+ let parseInline : typeof markedInstance . parseInline ;
56+
57+ /**
58+ * Registers extensions with the default Marked instance.
59+ *
60+ * The `renderer`, `tokenizer`, and `hooks` objects may each contain only the
61+ * methods that should be overridden. Their methods are merged with built-in
62+ * behavior and extensions registered by earlier calls.
63+ *
64+ * Use this function when supplying only some hook methods.
65+ */
66+ let use : ( ...args : MarkedExtension [ ] ) => typeof marked ;
67+ }
68+
4269/**
4370 * Sets the default options.
4471 *
@@ -60,15 +87,25 @@ marked.getDefaults = _getDefaults;
6087marked . defaults = _defaults ;
6188
6289/**
63- * Use Extension
90+ * Registers extensions with the default Marked instance.
91+ *
92+ * The `renderer`, `tokenizer`, and `hooks` objects may each contain only the
93+ * methods that should be overridden. Their methods are merged with built-in
94+ * behavior and extensions registered by earlier calls.
95+ *
96+ * Use this function when supplying only some hook methods.
97+ *
98+ * @param args Extensions to register
99+ * @return The `marked` function
64100 */
65-
66- marked . use = function ( ...args : MarkedExtension [ ] ) {
101+ function useExtension ( ...args : MarkedExtension [ ] ) {
67102 markedInstance . use ( ...args ) ;
68103 marked . defaults = markedInstance . defaults ;
69104 changeDefaults ( marked . defaults ) ;
70105 return marked ;
71- } ;
106+ }
107+
108+ marked . use = useExtension ;
72109
73110/**
74111 * Run callback for every token
@@ -81,6 +118,9 @@ marked.walkTokens = function(tokens: Token[] | TokensList, callback: (token: Tok
81118/**
82119 * Compiles markdown to HTML without enclosing `p` tag.
83120 *
121+ * To configure hooks, a renderer, or a tokenizer, create a `Marked` instance
122+ * and use `Marked#use` instead of passing them as options on each call.
123+ *
84124 * @param src String of markdown source to be compiled
85125 * @param options Hash of options
86126 * @return String of compiled HTML
@@ -102,8 +142,13 @@ marked.parse = marked;
102142
103143export const options = marked . options ;
104144export const setOptions = marked . setOptions ;
105- export const use = marked . use ;
106145export const walkTokens = marked . walkTokens ;
146+ /**
147+ * Compiles inline markdown to HTML.
148+ *
149+ * To configure hooks, a renderer, or a tokenizer, create a `Marked` instance
150+ * and use `Marked#use` instead of passing them as options on each call.
151+ */
107152export const parseInline = marked . parseInline ;
108153export const parse = marked ;
109154export const parser = _Parser . parse ;
@@ -116,5 +161,6 @@ export { _Renderer as Renderer } from './Renderer.ts';
116161export { _TextRenderer as TextRenderer } from './TextRenderer.ts' ;
117162export { _Hooks as Hooks } from './Hooks.ts' ;
118163export { Marked } from './Instance.ts' ;
164+ export { useExtension as use } ;
119165export type * from './MarkedOptions.ts' ;
120166export type * from './Tokens.ts' ;
0 commit comments