remark-sort-definitions
Version:
remark plugin that reorders reference-style link definitions by id at the end of a document
29 lines • 1.08 kB
TypeScript
import type { Root } from 'mdast';
import type { Plugin } from 'unified';
/**
* Options type for the remark-sort-definitions plugin.
*/
export type Options = {
/**
* This option determines the sorting preference used when reordering
* definitions.
*
* `numeric-first` will put definitions with purely numeric ids first, sorted
* from least (i.e. 1) to greatest, followed by any remaining definitions
* sorted [naturally][5].
*
* `alphanumeric-first` will put definitions with alphanumeric ids (i.e. any
* id that cannot be parsed into an integer) first, sorted naturally, followed
* by any remaining definitions sorted from least (i.e. 1) to greatest.
*
* @default "alphanumeric-first"
*/
algorithm?: 'numeric-first' | 'alphanumeric-first';
};
/**
* A remark plugin that takes a Root node as input and returns the same node
* with all definition nodes ordered with respect to the chosen
* `Options.algorithm`.
*/
declare const remarkSortDefinitions: Plugin<[options: Options] | void[], Root>;
export default remarkSortDefinitions;