import { Rules, Rule, RuleFilter } from './rules.cjs'; import { ExtendedNode } from './node.cjs'; export { Rules } from './rules.cjs'; export type { Rule, RuleFilter, RuleFilterFunction } from './rules.cjs'; export { isCodeBlock, wrapInlineContent } from './utilities.cjs'; export { NodeTypes } from './node.cjs'; export type { ExtendedNode, NodeType } from './node.cjs'; export type Plugin = (service: Turnish) => void; export interface TurnishOptions { rules: { [key: string]: Rule; }; headingStyle: 'setext' | 'atx'; hr: string; bulletListMarker: '*' | '-' | '+'; listMarkerSpaceCount: 1 | 2 | 3 | 4; listItemIndent: 'tab' | 'space'; listItemIndentSpaceCount: 2 | 4; codeBlockStyle: 'indented' | 'fenced'; fence: string; emDelimiter: '_' | '*'; strongDelimiter: '**' | '__'; linkStyle: 'inlined' | 'referenced'; linkReferenceStyle: 'full' | 'collapsed' | 'shortcut'; linkReferenceDeduplication: 'none' | 'full'; br: string; preformattedCode: boolean; htmlRetentionMode: 'standard' | 'preserveAll' | 'markdownIncludingHtml'; blankReplacement: (content: string, node: ExtendedNode) => string; keepReplacement: (content: string, node: ExtendedNode) => string; markdownIncludingHtmlReplacement: (content: string, node: ExtendedNode) => string; defaultReplacement: (content: string, node: ExtendedNode) => string; [key: string]: any; } export default class Turnish { options: TurnishOptions; rules: Rules; constructor(options?: Partial); /** * The entry point for converting a string or DOM node to Markdown * @public * @param {InputType} input The string or DOM node to convert * @returns A Markdown representation of the input * @type string */ render(input: InputType): string; /** * Add one or more plugins * @public * @param {Plugin|Plugin[]} plugin The plugin or array of plugins to add * @returns The Turnish instance for chaining * @type Object */ use(plugin: Plugin | Plugin[]): Turnish; /** * Adds a rule * @public * @param {string} key The unique key of the rule * @param {Object} rule The rule * @returns The Turnish instance for chaining * @type Object */ addRule(key: string, rule: Rule): Turnish; /** * Keep a node (as HTML) that matches the filter * @public * @param {RuleFilter} filter The unique key of the rule * @returns The Turnish instance for chaining * @type Object */ keep(filter: RuleFilter): Turnish; /** * Remove a node that matches the filter * @public * @param {string|Array|Function} filter The unique key of the rule * @returns The Turnish instance for chaining * @type Object */ remove(filter: RuleFilter): Turnish; /** * Escapes Markdown syntax * @public * @param {string} string The string to escape * @returns A string with Markdown syntax escaped * @type string */ escape(string: string): string; /** * Reduces a DOM node down to its Markdown string equivalent * @private * @param {HTMLElement} parentNode The node to convert * @returns A Markdown representation of the node * @type string */ process(this: Turnish, parentNode: Node): string; /** * Appends strings as each rule requires and trims the output * @private * @param {string} output The conversion output * @returns A trimmed version of the ouput * @type string */ postProcess(output: string): string; /** * Converts an element node to its Markdown equivalent * @private * @param {ExtendedNode} node The node to convert * @returns A Markdown representation of the node * @type string */ replacementForNode(node: ExtendedNode): string; } /** * Determines whether an input can be converted * @private * @param {string|HTMLElement} input Describe this parameter * @returns Describe what it returns * @type string|Object|Array|Boolean|Number */ type InputType = string | HTMLElement | Document | DocumentFragment;