UNPKG

micromark-extension-caml

Version:

Micromark syntax extension for caml (semantic) attributes.

85 lines 2.55 kB
import { Extension, CompileContext } from "micromark-util-types"; import { Token } from "micromark/lib/create-tokenizer"; // option types interface OptCssNames { attr: string; attrbox: string; attrboxTitle: string; // [[wikiattrs]]-related invalid: string; wiki: string; // types reftype: string; doctype: string; } interface OptAttr { render: boolean; title: string; } interface OptToMarkdown { format: "none" | "pad"; // | 'pretty'; // whitespace formatting type listKind: "comma" | "mkdn"; prefixed: boolean; // colon ':' prefix before linktype text for attr wikilinks } // 'mdast-toMarkdown' interface OptAttrToMkdn extends OptAttr { toMarkdown: Partial<OptToMarkdown>; } interface CamlOptions { attrs: Partial<OptAttr | OptAttrToMkdn>; cssNames: Partial<OptCssNames>; } // required options interface ReqSyntaxOpts { attrs: { render: boolean; title: string; }; } interface ReqHtmlOpts { attrs: { render: boolean; title: string; }; cssNames: OptCssNames; } // construct data types // (for html and ast) type AttrData = { [key: string]: (AttrDataPrimitive | WikiAttrData)[]; }; // same in remark-wikilinks // todo: link interface AttrDataItem { type: string; } // AttrItemPrimitive === CamlValData from 'caml' interface AttrDataPrimitive extends AttrDataItem { type: string; string: string; value: null | boolean | number | bigint | Date | string; // | NaN } // todo: link to micromark-extension-wikirefs instance // this interface is to help cut down on interdependencies between caml + wikirefs interface WikiAttrData extends AttrDataItem { type: "wiki"; doctype: string; filename: string; htmlHref: string; htmlText: string; baseUrl: string; // this is so remark-caml plugins can rebuild baseUrl + href } // eslint-disable-next-line @typescript-eslint/no-unused-vars declare const syntaxCaml: (opts?: Partial<CamlOptions>) => Extension; declare function htmlCaml(opts?: Partial<CamlOptions>): { enter: { attrBox: (this: CompileContext) => void; }; exit: { attrKey: (this: CompileContext, token: Token) => void; attrVal: (this: CompileContext, token: Token) => void; attrBox: (this: CompileContext) => void; }; }; export { syntaxCaml, htmlCaml, OptCssNames, OptAttr, OptToMarkdown, OptAttrToMkdn, CamlOptions, ReqSyntaxOpts, ReqHtmlOpts, AttrData, AttrDataItem, AttrDataPrimitive, WikiAttrData }; //# sourceMappingURL=index.d.ts.map