Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion types/markdown-it/index.d.mts
Original file line number Diff line number Diff line change
@@ -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";
26 changes: 21 additions & 5 deletions types/markdown-it/lib/common/utils.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
35 changes: 30 additions & 5 deletions types/markdown-it/markdown-it-tests.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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");
}
2 changes: 1 addition & 1 deletion types/markdown-it/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down