diff --git a/types/markdown-it/index.d.mts b/types/markdown-it/index.d.mts index 21578d54ab7e71..25f78406da6e4f 100644 --- a/types/markdown-it/index.d.mts +++ b/types/markdown-it/index.d.mts @@ -1 +1,20 @@ -export { default, Options, PluginSimple, PluginWithOptions, PluginWithParams, PresetName } from "./lib/index.mjs"; +export { + default, + type default as MarkdownIt, + Options, + type Options as MarkdownItOptions, + PluginSimple, + PluginWithOptions, + PluginWithParams, + PresetName, + type PresetName as MarkdownItPresetName, +} from "./lib/index.mjs"; +export type { default as ParserBlock } from "./lib/parser_block.mts"; +export type { default as ParserCore } from "./lib/parser_core.mts"; +export type { default as ParserInline } from "./lib/parser_inline.mts"; +export type { default as Renderer, RenderRule as RendererRule } from "./lib/renderer.mts"; +export type { default as Ruler } from "./lib/ruler.mts"; +export type { default as StateBlock } from "./lib/rules_block/state_block.mts"; +export type { default as StateCore } from "./lib/rules_core/state_core.mts"; +export type { default as StateInline, Delimiter } from "./lib/rules_inline/state_inline.mts"; +export type { default as Token } from "./lib/token.mts"; diff --git a/types/markdown-it/lib/common/utils.d.mts b/types/markdown-it/lib/common/utils.d.mts index fced9e814cab5b..c013a5de0aae74 100644 --- a/types/markdown-it/lib/common/utils.d.mts +++ b/types/markdown-it/lib/common/utils.d.mts @@ -39,21 +39,37 @@ export function isSpace(code: number): boolean; export function isWhiteSpace(code: number): boolean; /** - * Markdown ASCII punctuation characters. + * Markdown [ASCII punctuation characters](https://spec.commonmark.org/0.31.2/#ascii-punctuation-character). * - * !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~ + * !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, \@, [, \\, ], ^, _, `, {, |, }, or ~ * - * Don't confuse with unicode punctuation !!! It lacks some chars in ascii range. + * {@link isPunctChar} is missing some ASCII punctuation chars in < 14.1.0. + * This is consistent with CommonMark 0.30 and older behavior, where the range of ASCII punctuation + * characters was not fully contained in that of + * [Unicode punctuation characters](https://spec.commonmark.org/0.31.2/#unicode-punctuation-character). * - * @see http://spec.commonmark.org/0.15/#ascii-punctuation-character + * In >= 14.1.0 (compliant with CommonMark 0.31.2), {@link isPunctChar} includes all ASCII punctuation characters, + * so combining {@link isMdAsciiPunct} with {@link isPunctChar} is only for backwards compatibility or + * to try to provide a fast path for ASCII ranges. + * + * @see https://spec.commonmark.org/0.31.2/changes.html#part-4 */ export function isMdAsciiPunct(code: number): boolean; /** - * Currently without astral characters support. + * [Unicode punctuation characters](https://spec.commonmark.org/0.31.2/#unicode-punctuation-character). + * + * Astral (supplementary) characters support requires >= 14.2.0. */ export function isPunctChar(ch: string): boolean; +/** + * [Unicode punctuation characters](https://spec.commonmark.org/0.31.2/#unicode-punctuation-character). + * + * Added in 14.2.0. Supports astral (supplementary) characters. + */ +export function isPunctCharCode(code: number): boolean; + export function escapeRE(str: string): string; /** diff --git a/types/markdown-it/markdown-it-tests.mts b/types/markdown-it/markdown-it-tests.mts index 897c530491f07f..39ee8389ec5f37 100644 --- a/types/markdown-it/markdown-it-tests.mts +++ b/types/markdown-it/markdown-it-tests.mts @@ -4,14 +4,22 @@ import LinkifyIt from "linkify-it"; import MarkdownIt, { Options, PresetName } from "markdown-it"; // eslint-disable-next-line no-duplicate-imports import MarkdownIt1 from "markdown-it"; +// eslint-disable-next-line no-duplicate-imports +import type { + Delimiter, + MarkdownIt as MarkdownIt2, + MarkdownItOptions as Options2, + MarkdownItPresetName as PresetName2, + Renderer, + StateBlock, + StateCore, + StateInline, + Token, +} from "markdown-it"; import { RuleBlock } from "markdown-it/lib/parser_block.mjs"; import { RuleCore } from "markdown-it/lib/parser_core.mjs"; import { RuleInline, RuleInline2 } from "markdown-it/lib/parser_inline.mjs"; -import Renderer from "markdown-it/lib/renderer.mjs"; -import StateBlock from "markdown-it/lib/rules_block/state_block.mjs"; -import StateCore from "markdown-it/lib/rules_core/state_core.mjs"; -import StateInline, { Delimiter, Scanned, TokenMeta } from "markdown-it/lib/rules_inline/state_inline.mjs"; -import Token from "markdown-it/lib/token.mjs"; +import { Scanned, TokenMeta } from "markdown-it/lib/rules_inline/state_inline.mjs"; // stub highlight-js interaction declare const hljs: { @@ -519,3 +527,20 @@ let md: MarkdownIt; const href: string | null = token.attrGet("href"); token.attrJoin("class", "foobar"); } + +{ + // Minimal compatibility with built-in types in v15 + + const options: Options2 = { html: true, linkify: true }; + const preset: PresetName2 = "default"; + + const md2: MarkdownIt2 = new MarkdownIt(); + const md3: MarkdownIt2 = new MarkdownIt(options); + const md4: MarkdownIt2 = new MarkdownIt(preset); + const md5: MarkdownIt2 = new MarkdownIt(preset, options); + + md2.render("# Example"); + md3.renderInline("**Example**"); + md4.render("[link](https://example.com)"); + md5.render("---\n\nA paragraph"); +} diff --git a/types/markdown-it/package.json b/types/markdown-it/package.json index 98095dfe7e6dde..e8a9d3f36b33ea 100644 --- a/types/markdown-it/package.json +++ b/types/markdown-it/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/markdown-it", - "version": "14.1.9999", + "version": "14.2.9999", "projects": [ "https://github.com/markdown-it/markdown-it" ],