Comparing version 3.2.0 to 4.0.0
@@ -10,4 +10,8 @@ export function micromark( | ||
): string | ||
export {compile} from './lib/compile.js' | ||
export {parse} from './lib/parse.js' | ||
export {postprocess} from './lib/postprocess.js' | ||
export {preprocess} from './lib/preprocess.js' | ||
export type Encoding = import('micromark-util-types').Encoding | ||
export type Options = import('micromark-util-types').Options | ||
export type Value = import('micromark-util-types').Value |
@@ -12,10 +12,19 @@ /** | ||
export {compile} from './lib/compile.js' | ||
export {parse} from './lib/parse.js' | ||
export {postprocess} from './lib/postprocess.js' | ||
export {preprocess} from './lib/preprocess.js' | ||
/** | ||
* Compile markdown to HTML. | ||
* | ||
* > Note: which encodings are supported depends on the engine. | ||
* > For info on Node.js, see: | ||
* > <https://nodejs.org/api/util.html#whatwg-supported-encodings>. | ||
* | ||
* @overload | ||
* @param {Value} value | ||
* Markdown to parse (`string` or `Buffer`). | ||
* Markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | null | undefined} encoding | ||
* Character encoding to understand `value` as when it’s a `Buffer` | ||
* Character encoding to understand `value` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -29,3 +38,3 @@ * @param {Options | null | undefined} [options] | ||
* @param {Value} value | ||
* Markdown to parse (`string` or `Buffer`). | ||
* Markdown to parse (`string` or `Uint8Array`). | ||
* @param {Options | null | undefined} [options] | ||
@@ -37,5 +46,5 @@ * Configuration. | ||
* @param {Value} value | ||
* Markdown to parse (`string` or `Buffer`). | ||
* @param {Options | Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `value` as when it’s a `Buffer` | ||
* Markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | Options | null | undefined} [encoding] | ||
* Character encoding to understand `value` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -42,0 +51,0 @@ * @param {Options | null | undefined} [options] |
@@ -45,6 +45,4 @@ /** | ||
import {sanitizeUri} from 'micromark-util-sanitize-uri' | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {constants} from 'micromark-util-symbol/constants.js' | ||
import {types} from 'micromark-util-symbol/types.js' | ||
import {ok as assert} from 'uvu/assert' | ||
import {codes, constants, types} from 'micromark-util-symbol' | ||
import {ok as assert} from 'devlop' | ||
@@ -158,3 +156,3 @@ const hasOwnProperty = {}.hasOwnProperty | ||
codeFencedFenceInfo: onexitcodefencedfenceinfo, | ||
codeFencedFenceMeta: resume, | ||
codeFencedFenceMeta: onresumedrop, | ||
codeFlowValue: onexitcodeflowvalue, | ||
@@ -184,5 +182,5 @@ codeIndented: onexitflowcode, | ||
paragraph: onexitparagraph, | ||
reference: resume, | ||
reference: onresumedrop, | ||
referenceString: onexitreferencestring, | ||
resource: resume, | ||
resource: onresumedrop, | ||
resourceDestinationString: onexitresourcedestinationstring, | ||
@@ -352,3 +350,3 @@ resourceTitleString: onexitresourcetitlestring, | ||
* @param {Array<Event>} slice | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -455,3 +453,3 @@ function prepareList(slice) { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -489,2 +487,9 @@ function lineEnding() { | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onresumedrop() { | ||
resume() | ||
} | ||
/** | ||
* @this {CompileContext} | ||
@@ -528,2 +533,5 @@ * @type {Handle} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterlistitemmarker() { | ||
@@ -543,2 +551,5 @@ if (getData('expectFirstItem')) { | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitlistordered() { | ||
@@ -551,2 +562,5 @@ onexitlistitem() | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitlistunordered() { | ||
@@ -559,2 +573,5 @@ onexitlistitem() | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitlistitem() { | ||
@@ -1010,2 +1027,5 @@ if (getData('lastWasTag') && !getData('slurpAllLineEndings')) { | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterhtmlflow() { | ||
@@ -1016,2 +1036,5 @@ lineEndingIfNeeded() | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexithtml() { | ||
@@ -1021,2 +1044,5 @@ setData('ignoreEncode') | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterhtml() { | ||
@@ -1028,2 +1054,5 @@ if (settings.allowDangerousHtml) { | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenteremphasis() { | ||
@@ -1033,2 +1062,5 @@ tag('<em>') | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterstrong() { | ||
@@ -1038,2 +1070,5 @@ tag('<strong>') | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onentercodetext() { | ||
@@ -1044,2 +1079,5 @@ setData('inCodeText', true) | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitcodetext() { | ||
@@ -1050,2 +1088,5 @@ setData('inCodeText') | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitemphasis() { | ||
@@ -1055,2 +1096,5 @@ tag('</em>') | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitstrong() { | ||
@@ -1060,2 +1104,5 @@ tag('</strong>') | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitthematicbreak() { | ||
@@ -1069,2 +1116,3 @@ lineEndingIfNeeded() | ||
* @param {Token} token | ||
* @returns {undefined} | ||
*/ | ||
@@ -1071,0 +1119,0 @@ function onexitcharacterreferencemarker(token) { |
@@ -60,3 +60,3 @@ /** @satisfies {Extension['document']} */ | ||
export namespace insideSpan { | ||
const _null: ( | ||
let _null: ( | ||
| import('micromark-util-types').Construct | ||
@@ -70,9 +70,9 @@ | { | ||
export namespace attentionMarkers { | ||
const _null_1: (42 | 95)[] | ||
let _null_1: (42 | 95)[] | ||
export {_null_1 as null} | ||
} | ||
export namespace disable { | ||
const _null_2: never[] | ||
let _null_2: never[] | ||
export {_null_2 as null} | ||
} | ||
export type Extension = import('micromark-util-types').Extension |
@@ -27,3 +27,3 @@ /** | ||
} from 'micromark-core-commonmark' | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {codes} from 'micromark-util-symbol' | ||
import {resolver as resolveText} from './initialize/text.js' | ||
@@ -30,0 +30,0 @@ |
@@ -32,3 +32,3 @@ /** | ||
export type TokenizeContext = import('micromark-util-types').TokenizeContext | ||
export type Restore = () => void | ||
export type Restore = () => undefined | ||
export type Info = { | ||
@@ -41,2 +41,2 @@ restore: Restore | ||
*/ | ||
export type ReturnHandle = (construct: Construct, info: Info) => void | ||
export type ReturnHandle = (construct: Construct, info: Info) => undefined |
@@ -18,3 +18,3 @@ /** | ||
* @callback Restore | ||
* @returns {void} | ||
* @returns {undefined} | ||
* | ||
@@ -29,3 +29,3 @@ * @typedef Info | ||
* @param {Info} info | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -37,5 +37,4 @@ | ||
import {resolveAll} from 'micromark-util-resolve-all' | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {values} from 'micromark-util-symbol/values.js' | ||
import {ok as assert} from 'uvu/assert' | ||
import {codes, values} from 'micromark-util-symbol' | ||
import {ok as assert} from 'devlop' | ||
@@ -110,3 +109,3 @@ const debug = createDebug('micromark') | ||
* | ||
* @type {State | void} | ||
* @type {State | undefined} | ||
*/ | ||
@@ -187,3 +186,3 @@ let state = initialize.tokenize.call(context, effects) | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -221,3 +220,3 @@ function main() { | ||
* @param {Code} code | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -497,3 +496,3 @@ function go(code) { | ||
* @param {number} from | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -543,3 +542,3 @@ function addResult(construct, from) { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -561,3 +560,3 @@ function restore() { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -564,0 +563,0 @@ function accountForPotentialSkip() { |
@@ -11,6 +11,4 @@ /** | ||
import {markdownLineEnding} from 'micromark-util-character' | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {constants} from 'micromark-util-symbol/constants.js' | ||
import {types} from 'micromark-util-symbol/types.js' | ||
import {ok as assert} from 'uvu/assert' | ||
import {codes, constants, types} from 'micromark-util-symbol' | ||
import {ok as assert} from 'devlop' | ||
@@ -17,0 +15,0 @@ /** @type {InitialConstruct} */ |
@@ -20,6 +20,4 @@ /** | ||
import {splice} from 'micromark-util-chunked' | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {constants} from 'micromark-util-symbol/constants.js' | ||
import {types} from 'micromark-util-symbol/types.js' | ||
import {ok as assert} from 'uvu/assert' | ||
import {codes, constants, types} from 'micromark-util-symbol' | ||
import {ok as assert} from 'devlop' | ||
@@ -272,3 +270,3 @@ /** @type {InitialConstruct} */ | ||
* @param {boolean | undefined} [eof] | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -387,3 +385,3 @@ function writeToChild(token, eof) { | ||
* @param {number} size | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -390,0 +388,0 @@ function exitContainers(size) { |
@@ -11,5 +11,4 @@ /** | ||
import {markdownLineEnding} from 'micromark-util-character' | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {types} from 'micromark-util-symbol/types.js' | ||
import {ok as assert} from 'uvu/assert' | ||
import {codes, types} from 'micromark-util-symbol' | ||
import {ok as assert} from 'devlop' | ||
@@ -16,0 +15,0 @@ /** @type {InitialConstruct} */ |
export namespace resolver { | ||
const resolveAll: import('micromark-util-types').Resolver | ||
let resolveAll: import('micromark-util-types').Resolver | ||
} | ||
@@ -4,0 +4,0 @@ export const string: import('micromark-util-types').InitialConstruct |
@@ -10,6 +10,4 @@ /** | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {constants} from 'micromark-util-symbol/constants.js' | ||
import {types} from 'micromark-util-symbol/types.js' | ||
import {ok as assert} from 'uvu/assert' | ||
import {codes, constants, types} from 'micromark-util-symbol' | ||
import {ok as assert} from 'devlop' | ||
@@ -16,0 +14,0 @@ export const resolver = {resolveAll: createResolver()} |
@@ -13,3 +13,3 @@ /** | ||
import {flow} from './initialize/flow.js' | ||
import {text, string} from './initialize/text.js' | ||
import {string, text} from './initialize/text.js' | ||
import {createTokenizer} from './create-tokenizer.js' | ||
@@ -16,0 +16,0 @@ import * as defaultConstructs from './constructs.js' |
@@ -16,4 +16,3 @@ /** | ||
import {codes} from 'micromark-util-symbol/codes.js' | ||
import {constants} from 'micromark-util-symbol/constants.js' | ||
import {codes, constants} from 'micromark-util-symbol' | ||
@@ -36,2 +35,3 @@ const search = /[\0\t\n\r]/g | ||
/** @type {Preprocessor} */ | ||
// eslint-disable-next-line complexity | ||
function preprocessor(value, encoding, end) { | ||
@@ -51,4 +51,8 @@ /** @type {Array<Chunk>} */ | ||
// @ts-expect-error `Buffer` does allow an encoding. | ||
value = buffer + value.toString(encoding) | ||
value = | ||
buffer + | ||
(typeof value === 'string' | ||
? value.toString() | ||
: new TextDecoder(encoding || undefined).decode(value)) | ||
startPosition = 0 | ||
@@ -55,0 +59,0 @@ buffer = '' |
@@ -23,3 +23,6 @@ /** | ||
*/ | ||
export type Callback = () => void | ||
export type Callback = () => undefined | ||
export type PipeOptions = { | ||
end?: boolean | null | undefined | ||
} | ||
export type MinimalDuplex = Omit< | ||
@@ -26,0 +29,0 @@ NodeJS.ReadableStream & NodeJS.WritableStream, |
@@ -10,9 +10,12 @@ /** | ||
* Function called when write was successful. | ||
* @returns {void} | ||
* @returns {undefined} | ||
* Nothing. | ||
* | ||
* @typedef PipeOptions | ||
* @property {boolean | null | undefined} [end] | ||
* | ||
* @typedef {Omit<NodeJS.ReadableStream & NodeJS.WritableStream, 'isPaused' | 'pause' | 'read' | 'resume' | 'setEncoding' | 'unpipe' | 'unshift' | 'wrap'>} MinimalDuplex | ||
*/ | ||
import {EventEmitter} from 'events' | ||
import {EventEmitter} from 'node:events' | ||
import {compile} from './lib/compile.js' | ||
@@ -62,5 +65,5 @@ import {parse} from './lib/parse.js' | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -74,3 +77,3 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | null | undefined} [callback] | ||
@@ -82,5 +85,5 @@ * Function called when write was successful. | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -119,5 +122,5 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -131,3 +134,3 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | null | undefined} [callback] | ||
@@ -144,5 +147,5 @@ * Function called when write was successful. | ||
* @param {Callback | Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -183,3 +186,3 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Stream} dest | ||
* @param {{end?: boolean | null | undefined}} [options] | ||
* @param {PipeOptions | null | undefined} [options] | ||
* @returns {Stream} | ||
@@ -210,3 +213,3 @@ */ | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -223,3 +226,3 @@ function onend() { | ||
* @param {string} chunk | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -235,3 +238,3 @@ function ondata(chunk) { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -253,3 +256,3 @@ function cleanup() { | ||
* @param {Error | null | undefined} [error] | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -256,0 +259,0 @@ function onerror(error) { |
@@ -10,4 +10,8 @@ export function micromark( | ||
): string | ||
export {compile} from './lib/compile.js' | ||
export {parse} from './lib/parse.js' | ||
export {postprocess} from './lib/postprocess.js' | ||
export {preprocess} from './lib/preprocess.js' | ||
export type Encoding = import('micromark-util-types').Encoding | ||
export type Options = import('micromark-util-types').Options | ||
export type Value = import('micromark-util-types').Value |
20
index.js
@@ -11,2 +11,6 @@ /** | ||
import {preprocess} from './lib/preprocess.js' | ||
export {compile} from './lib/compile.js' | ||
export {parse} from './lib/parse.js' | ||
export {postprocess} from './lib/postprocess.js' | ||
export {preprocess} from './lib/preprocess.js' | ||
@@ -16,7 +20,11 @@ /** | ||
* | ||
* > Note: which encodings are supported depends on the engine. | ||
* > For info on Node.js, see: | ||
* > <https://nodejs.org/api/util.html#whatwg-supported-encodings>. | ||
* | ||
* @overload | ||
* @param {Value} value | ||
* Markdown to parse (`string` or `Buffer`). | ||
* Markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | null | undefined} encoding | ||
* Character encoding to understand `value` as when it’s a `Buffer` | ||
* Character encoding to understand `value` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -30,3 +38,3 @@ * @param {Options | null | undefined} [options] | ||
* @param {Value} value | ||
* Markdown to parse (`string` or `Buffer`). | ||
* Markdown to parse (`string` or `Uint8Array`). | ||
* @param {Options | null | undefined} [options] | ||
@@ -38,5 +46,5 @@ * Configuration. | ||
* @param {Value} value | ||
* Markdown to parse (`string` or `Buffer`). | ||
* @param {Options | Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `value` as when it’s a `Buffer` | ||
* Markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | Options | null | undefined} [encoding] | ||
* Character encoding to understand `value` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -43,0 +51,0 @@ * @param {Options | null | undefined} [options] |
@@ -152,3 +152,3 @@ /** | ||
codeFencedFenceInfo: onexitcodefencedfenceinfo, | ||
codeFencedFenceMeta: resume, | ||
codeFencedFenceMeta: onresumedrop, | ||
codeFlowValue: onexitcodeflowvalue, | ||
@@ -178,5 +178,5 @@ codeIndented: onexitflowcode, | ||
paragraph: onexitparagraph, | ||
reference: resume, | ||
reference: onresumedrop, | ||
referenceString: onexitreferencestring, | ||
resource: resume, | ||
resource: onresumedrop, | ||
resourceDestinationString: onexitresourcedestinationstring, | ||
@@ -344,3 +344,3 @@ resourceTitleString: onexitresourcetitlestring, | ||
* @param {Array<Event>} slice | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -437,3 +437,3 @@ function prepareList(slice) { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -465,2 +465,9 @@ function lineEnding() { | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onresumedrop() { | ||
resume() | ||
} | ||
/** | ||
* @this {CompileContext} | ||
@@ -499,2 +506,6 @@ * @type {Handle} | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterlistitemmarker() { | ||
@@ -512,2 +523,6 @@ if (getData('expectFirstItem')) { | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitlistordered() { | ||
@@ -519,2 +534,6 @@ onexitlistitem() | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitlistunordered() { | ||
@@ -526,2 +545,6 @@ onexitlistitem() | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitlistitem() { | ||
@@ -958,2 +981,6 @@ if (getData('lastWasTag') && !getData('slurpAllLineEndings')) { | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterhtmlflow() { | ||
@@ -963,5 +990,13 @@ lineEndingIfNeeded() | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexithtml() { | ||
setData('ignoreEncode') | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterhtml() { | ||
@@ -972,8 +1007,20 @@ if (settings.allowDangerousHtml) { | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenteremphasis() { | ||
tag('<em>') | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onenterstrong() { | ||
tag('<strong>') | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onentercodetext() { | ||
@@ -983,2 +1030,6 @@ setData('inCodeText', true) | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitcodetext() { | ||
@@ -988,8 +1039,20 @@ setData('inCodeText') | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitemphasis() { | ||
tag('</em>') | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitstrong() { | ||
tag('</strong>') | ||
} | ||
/** | ||
* @returns {undefined} | ||
*/ | ||
function onexitthematicbreak() { | ||
@@ -1003,2 +1066,3 @@ lineEndingIfNeeded() | ||
* @param {Token} token | ||
* @returns {undefined} | ||
*/ | ||
@@ -1005,0 +1069,0 @@ function onexitcharacterreferencemarker(token) { |
@@ -60,3 +60,3 @@ /** @satisfies {Extension['document']} */ | ||
export namespace insideSpan { | ||
const _null: ( | ||
let _null: ( | ||
| import('micromark-util-types').Construct | ||
@@ -70,9 +70,9 @@ | { | ||
export namespace attentionMarkers { | ||
const _null_1: (42 | 95)[] | ||
let _null_1: (42 | 95)[] | ||
export {_null_1 as null} | ||
} | ||
export namespace disable { | ||
const _null_2: never[] | ||
let _null_2: never[] | ||
export {_null_2 as null} | ||
} | ||
export type Extension = import('micromark-util-types').Extension |
@@ -32,3 +32,3 @@ /** | ||
export type TokenizeContext = import('micromark-util-types').TokenizeContext | ||
export type Restore = () => void | ||
export type Restore = () => undefined | ||
export type Info = { | ||
@@ -41,2 +41,2 @@ restore: Restore | ||
*/ | ||
export type ReturnHandle = (construct: Construct, info: Info) => void | ||
export type ReturnHandle = (construct: Construct, info: Info) => undefined |
@@ -18,3 +18,3 @@ /** | ||
* @callback Restore | ||
* @returns {void} | ||
* @returns {undefined} | ||
* | ||
@@ -29,3 +29,3 @@ * @typedef Info | ||
* @param {Info} info | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -113,3 +113,3 @@ | ||
* | ||
* @type {State | void} | ||
* @type {State | undefined} | ||
*/ | ||
@@ -190,3 +190,3 @@ let state = initialize.tokenize.call(context, effects) | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -221,3 +221,3 @@ function main() { | ||
* @param {Code} code | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -437,3 +437,3 @@ function go(code) { | ||
* @param {number} from | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -476,3 +476,3 @@ function addResult(construct, from) { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -493,3 +493,3 @@ function restore() { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -496,0 +496,0 @@ function accountForPotentialSkip() { |
@@ -241,3 +241,3 @@ /** | ||
* @param {boolean | undefined} [eof] | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -349,3 +349,3 @@ function writeToChild(token, eof) { | ||
* @param {number} size | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -352,0 +352,0 @@ function exitContainers(size) { |
export namespace resolver { | ||
const resolveAll: import('micromark-util-types').Resolver | ||
let resolveAll: import('micromark-util-types').Resolver | ||
} | ||
@@ -4,0 +4,0 @@ export const string: import('micromark-util-types').InitialConstruct |
@@ -13,3 +13,3 @@ /** | ||
import {flow} from './initialize/flow.js' | ||
import {text, string} from './initialize/text.js' | ||
import {string, text} from './initialize/text.js' | ||
import {createTokenizer} from './create-tokenizer.js' | ||
@@ -16,0 +16,0 @@ import * as defaultConstructs from './constructs.js' |
@@ -31,2 +31,3 @@ /** | ||
/** @type {Preprocessor} */ | ||
// eslint-disable-next-line complexity | ||
function preprocessor(value, encoding, end) { | ||
@@ -45,5 +46,7 @@ /** @type {Array<Chunk>} */ | ||
let code | ||
// @ts-expect-error `Buffer` does allow an encoding. | ||
value = buffer + value.toString(encoding) | ||
value = | ||
buffer + | ||
(typeof value === 'string' | ||
? value.toString() | ||
: new TextDecoder(encoding || undefined).decode(value)) | ||
startPosition = 0 | ||
@@ -50,0 +53,0 @@ buffer = '' |
{ | ||
"name": "micromark", | ||
"version": "3.2.0", | ||
"version": "4.0.0", | ||
"description": "small commonmark compliant markdown parser with positional info and concrete tokens", | ||
@@ -44,4 +44,2 @@ "license": "MIT", | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "dev/index.d.ts", | ||
"files": [ | ||
@@ -57,3 +55,2 @@ "dev/", | ||
".": { | ||
"types": "./dev/index.d.ts", | ||
"development": "./dev/index.js", | ||
@@ -63,50 +60,4 @@ "default": "./index.js" | ||
"./stream": { | ||
"types": "./dev/stream.d.ts", | ||
"development": "./dev/stream.js", | ||
"default": "./stream.js" | ||
}, | ||
"./stream.js": { | ||
"types": "./dev/stream.d.ts", | ||
"development": "./dev/stream.js", | ||
"default": "./stream.js" | ||
}, | ||
"./lib/compile": { | ||
"types": "./dev/lib/compile.d.ts", | ||
"development": "./dev/lib/compile.js", | ||
"default": "./lib/compile.js" | ||
}, | ||
"./lib/compile.js": { | ||
"types": "./dev/lib/compile.d.ts", | ||
"development": "./dev/lib/compile.js", | ||
"default": "./lib/compile.js" | ||
}, | ||
"./lib/parse": { | ||
"types": "./dev/lib/parse.d.ts", | ||
"development": "./dev/lib/parse.js", | ||
"default": "./lib/parse.js" | ||
}, | ||
"./lib/parse.js": { | ||
"types": "./dev/lib/parse.d.ts", | ||
"development": "./dev/lib/parse.js", | ||
"default": "./lib/parse.js" | ||
}, | ||
"./lib/postprocess": { | ||
"types": "./dev/lib/postprocess.d.ts", | ||
"development": "./dev/lib/postprocess.js", | ||
"default": "./lib/postprocess.js" | ||
}, | ||
"./lib/postprocess.js": { | ||
"types": "./dev/lib/postprocess.d.ts", | ||
"development": "./dev/lib/postprocess.js", | ||
"default": "./lib/postprocess.js" | ||
}, | ||
"./lib/preprocess": { | ||
"types": "./dev/lib/preprocess.d.ts", | ||
"development": "./dev/lib/preprocess.js", | ||
"default": "./lib/preprocess.js" | ||
}, | ||
"./lib/preprocess.js": { | ||
"types": "./dev/lib/preprocess.d.ts", | ||
"development": "./dev/lib/preprocess.js", | ||
"default": "./lib/preprocess.js" | ||
} | ||
@@ -117,17 +68,17 @@ }, | ||
"debug": "^4.0.0", | ||
"micromark-core-commonmark": "^1.0.1", | ||
"micromark-factory-space": "^1.0.0", | ||
"micromark-util-character": "^1.0.0", | ||
"micromark-util-chunked": "^1.0.0", | ||
"micromark-util-combine-extensions": "^1.0.0", | ||
"micromark-util-decode-numeric-character-reference": "^1.0.0", | ||
"micromark-util-encode": "^1.0.0", | ||
"micromark-util-normalize-identifier": "^1.0.0", | ||
"micromark-util-resolve-all": "^1.0.0", | ||
"micromark-util-sanitize-uri": "^1.0.0", | ||
"micromark-util-subtokenize": "^1.0.0", | ||
"micromark-util-symbol": "^1.0.0", | ||
"micromark-util-types": "^1.0.1", | ||
"decode-named-character-reference": "^1.0.0", | ||
"uvu": "^0.5.0" | ||
"devlop": "^1.0.0", | ||
"micromark-core-commonmark": "^2.0.0", | ||
"micromark-factory-space": "^2.0.0", | ||
"micromark-util-character": "^2.0.0", | ||
"micromark-util-chunked": "^2.0.0", | ||
"micromark-util-combine-extensions": "^2.0.0", | ||
"micromark-util-decode-numeric-character-reference": "^2.0.0", | ||
"micromark-util-encode": "^2.0.0", | ||
"micromark-util-normalize-identifier": "^2.0.0", | ||
"micromark-util-resolve-all": "^2.0.0", | ||
"micromark-util-sanitize-uri": "^2.0.0", | ||
"micromark-util-subtokenize": "^2.0.0", | ||
"micromark-util-symbol": "^2.0.0", | ||
"micromark-util-types": "^2.0.0" | ||
}, | ||
@@ -137,9 +88,3 @@ "scripts": { | ||
}, | ||
"xo": false, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true | ||
} | ||
"xo": false | ||
} |
@@ -26,3 +26,3 @@ # micromark | ||
* [x] **[robust][test]** (±2k tests, 100% coverage, fuzz testing) | ||
* [x] **[small][size-debug]** (smallest CM parser at ±15kb) | ||
* [x] **[small][size-debug]** (smallest CM parser at ±14kb) | ||
@@ -184,9 +184,12 @@ ## Contents | ||
> Note: which encodings are supported depends on the engine. | ||
> For info on Node.js, see *[WHATWG supported encodings][encoding]*. | ||
###### Parameters | ||
* `value` (`string` or [`Buffer`][buffer]) | ||
* `value` (`string` or [`Uint8Array`][uint8-array]) | ||
— markdown to parse | ||
* `encoding` (`string`, default: `'utf8'`) | ||
— [character encoding][encoding] to understand `value` as when it’s a | ||
`Buffer` | ||
[`Uint8Array`][uint8-array] | ||
* `options` ([`Options`][api-options], optional) | ||
@@ -284,7 +287,10 @@ — configuration | ||
Projects maintained by the unified collective are compatible with all maintained | ||
Projects maintained by the unified collective are compatible with maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 16+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, `micromark@^4`, compatible | ||
with Node.js 16. | ||
## Security | ||
@@ -450,5 +456,5 @@ | ||
[encoding]: https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings | ||
[uint8-array]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array | ||
[buffer]: https://nodejs.org/api/buffer.html | ||
[encoding]: https://nodejs.org/api/util.html#whatwg-supported-encodings | ||
@@ -455,0 +461,0 @@ [commonmark]: https://commonmark.org |
@@ -23,3 +23,6 @@ /** | ||
*/ | ||
export type Callback = () => void | ||
export type Callback = () => undefined | ||
export type PipeOptions = { | ||
end?: boolean | null | undefined | ||
} | ||
export type MinimalDuplex = Omit< | ||
@@ -26,0 +29,0 @@ NodeJS.ReadableStream & NodeJS.WritableStream, |
@@ -10,9 +10,12 @@ /** | ||
* Function called when write was successful. | ||
* @returns {void} | ||
* @returns {undefined} | ||
* Nothing. | ||
* | ||
* @typedef PipeOptions | ||
* @property {boolean | null | undefined} [end] | ||
* | ||
* @typedef {Omit<NodeJS.ReadableStream & NodeJS.WritableStream, 'isPaused' | 'pause' | 'read' | 'resume' | 'setEncoding' | 'unpipe' | 'unshift' | 'wrap'>} MinimalDuplex | ||
*/ | ||
import {EventEmitter} from 'events' | ||
import {EventEmitter} from 'node:events' | ||
import {compile} from './lib/compile.js' | ||
@@ -61,5 +64,5 @@ import {parse} from './lib/parse.js' | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -73,3 +76,3 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | null | undefined} [callback] | ||
@@ -81,5 +84,5 @@ * Function called when write was successful. | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -115,5 +118,5 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -127,3 +130,3 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | null | undefined} [callback] | ||
@@ -140,5 +143,5 @@ * Function called when write was successful. | ||
* @param {Callback | Value | null | undefined} [chunk] | ||
* Slice of markdown to parse (`string` or `Buffer`). | ||
* Slice of markdown to parse (`string` or `Uint8Array`). | ||
* @param {Callback | Encoding | null | undefined} [encoding] | ||
* Character encoding to understand `chunk` as when it’s a `Buffer` | ||
* Character encoding to understand `chunk` as when it’s a `Uint8Array` | ||
* (`string`, default: `'utf8'`). | ||
@@ -175,3 +178,3 @@ * @param {Callback | null | undefined} [callback] | ||
* @param {Stream} dest | ||
* @param {{end?: boolean | null | undefined}} [options] | ||
* @param {PipeOptions | null | undefined} [options] | ||
* @returns {Stream} | ||
@@ -199,3 +202,3 @@ */ | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -212,3 +215,3 @@ function onend() { | ||
* @param {string} chunk | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -224,3 +227,3 @@ function ondata(chunk) { | ||
* | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -241,3 +244,3 @@ function cleanup() { | ||
* @param {Error | null | undefined} [error] | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -244,0 +247,0 @@ function onerror(error) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202448
6190
492
50
+ Addeddevlop@^1.0.0
+ Addeddevlop@1.1.0(transitive)
+ Addedmicromark-core-commonmark@2.0.1(transitive)
+ Addedmicromark-factory-destination@2.0.0(transitive)
+ Addedmicromark-factory-label@2.0.0(transitive)
+ Addedmicromark-factory-space@2.0.0(transitive)
+ Addedmicromark-factory-title@2.0.0(transitive)
+ Addedmicromark-factory-whitespace@2.0.0(transitive)
+ Addedmicromark-util-character@2.1.0(transitive)
+ Addedmicromark-util-chunked@2.0.0(transitive)
+ Addedmicromark-util-classify-character@2.0.0(transitive)
+ Addedmicromark-util-combine-extensions@2.0.0(transitive)
+ Addedmicromark-util-decode-numeric-character-reference@2.0.1(transitive)
+ Addedmicromark-util-encode@2.0.0(transitive)
+ Addedmicromark-util-html-tag-name@2.0.0(transitive)
+ Addedmicromark-util-normalize-identifier@2.0.0(transitive)
+ Addedmicromark-util-resolve-all@2.0.0(transitive)
+ Addedmicromark-util-sanitize-uri@2.0.0(transitive)
+ Addedmicromark-util-subtokenize@2.0.1(transitive)
+ Addedmicromark-util-symbol@2.0.0(transitive)
+ Addedmicromark-util-types@2.0.0(transitive)
- Removeduvu@^0.5.0
- Removeddiff@5.2.0(transitive)
- Removedkleur@4.1.5(transitive)
- Removedmicromark-core-commonmark@1.1.0(transitive)
- Removedmicromark-factory-destination@1.1.0(transitive)
- Removedmicromark-factory-label@1.1.0(transitive)
- Removedmicromark-factory-space@1.1.0(transitive)
- Removedmicromark-factory-title@1.1.0(transitive)
- Removedmicromark-factory-whitespace@1.1.0(transitive)
- Removedmicromark-util-character@1.2.0(transitive)
- Removedmicromark-util-chunked@1.1.0(transitive)
- Removedmicromark-util-classify-character@1.1.0(transitive)
- Removedmicromark-util-combine-extensions@1.1.0(transitive)
- Removedmicromark-util-decode-numeric-character-reference@1.1.0(transitive)
- Removedmicromark-util-encode@1.1.0(transitive)
- Removedmicromark-util-html-tag-name@1.2.0(transitive)
- Removedmicromark-util-normalize-identifier@1.1.0(transitive)
- Removedmicromark-util-resolve-all@1.1.0(transitive)
- Removedmicromark-util-sanitize-uri@1.2.0(transitive)
- Removedmicromark-util-subtokenize@1.1.0(transitive)
- Removedmicromark-util-symbol@1.1.0(transitive)
- Removedmicromark-util-types@1.1.0(transitive)
- Removedmri@1.2.0(transitive)
- Removedsade@1.8.1(transitive)
- Removeduvu@0.5.6(transitive)
Updatedmicromark-util-decode-numeric-character-reference@^2.0.0
Updatedmicromark-util-encode@^2.0.0
Updatedmicromark-util-symbol@^2.0.0
Updatedmicromark-util-types@^2.0.0