Introduce options.markdownItFactory (and remove options.markdownItPlugins) so the markdown-it parser can be removed as a direct dependency because it is no longer used by default.

This commit is contained in:
David Anson 2024-12-25 20:42:32 -08:00
parent 3cbe1cb6c5
commit d4b981bcb3
11 changed files with 172 additions and 67 deletions

View file

@ -357,6 +357,23 @@ export type Rule = {
*/
function: RuleFunction;
};
/**
* Method used by the markdown-it parser to parse input.
*/
export type MarkdownItParse = (src: string, env: any) => any[];
/**
* Instance of the markdown-it parser.
*/
export type MarkdownIt = {
/**
* Method to parse input.
*/
parse: MarkdownItParse;
};
/**
* Gets an instance of the markdown-it parser. Any plugins should already have been loaded.
*/
export type MarkdownItFactory = () => MarkdownIt;
/**
* Configuration options.
*/
@ -390,9 +407,9 @@ export type Options = {
*/
handleRuleFailures?: boolean;
/**
* Additional plugins.
* Function to create a markdown-it parser.
*/
markdownItPlugins?: Plugin[];
markdownItFactory?: MarkdownItFactory;
/**
* True to ignore HTML directives.
*/