UNPKG

@benrbray/mdast-util-cite

Version:

Converts a `micromark` token stream into an `mdast` syntax tree.

82 lines (70 loc) 2.08 kB
import { Data } from 'mdast'; import { Extension } from 'mdast-util-from-markdown'; import { Handle } from 'mdast-util-to-markdown'; import * as Uni from 'unist'; import { Unsafe } from 'mdast-util-to-markdown'; export declare const citeFromMarkdown: Extension; export declare interface CiteItem { prefix?: string; key: string; suffix?: string; suppressAuthor?: true | undefined; } /** * @warning Does no validation. Garbage in, garbage out. */ export declare function citeToMarkdown(options?: Partial<CiteToMarkdownOptions>): { unsafe: Unsafe[]; handlers: { cite: Handle; }; }; export declare interface CiteToMarkdownOptions { /** * When `true`, nodes with `altSyntax: true` will be rendered in standard * pandoc syntax `[@cite]` rather than alternative syntax `@[cite]`. * * @default false */ standardizeAltSyntax: boolean; /** * When `false`, will not suppress authors in the output. * * @default true */ enableAuthorSuppression: boolean; /** * `micromark-extension-cite` stores the original Markdown source for each * citation in the `value` property of each `InlineCiteNode`. When this * option is `true`, every citation node serializes to its `value`, rather * than being reconstructed from `data.citeItems`. * * This setting overrides all other options. * * @default false */ useNodeValue: boolean; } export declare interface InlineCiteNode extends Uni.Literal { type: "cite"; value: string; data: Data & { altSyntax?: true | undefined; citeItems: CiteItem[]; }; } export { } declare module 'mdast' { interface PhrasingContentMap { inlineCiteNode: InlineCiteNode; } interface RootContentMap { inlineCiteNode: InlineCiteNode; } } declare module 'mdast-util-to-markdown' { interface ConstructNameMap { citation: 'citation'; citationKey: 'citationKey'; } }