micromark-factory-label
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -32,14 +32,7 @@ /** | ||
*/ | ||
export function factoryLabel( | ||
this: import('micromark-util-types').TokenizeContext, | ||
effects: Effects, | ||
ok: State, | ||
nok: State, | ||
type: TokenType, | ||
markerType: TokenType, | ||
stringType: TokenType | ||
): State | ||
export type Effects = import('micromark-util-types').Effects | ||
export type State = import('micromark-util-types').State | ||
export type TokenizeContext = import('micromark-util-types').TokenizeContext | ||
export type TokenType = import('micromark-util-types').TokenType | ||
export function factoryLabel(this: TokenizeContext, effects: Effects, ok: State, nok: State, type: TokenType, markerType: TokenType, stringType: TokenType): State; | ||
import type { Effects } from 'micromark-util-types'; | ||
import type { State } from 'micromark-util-types'; | ||
import type { TokenType } from 'micromark-util-types'; | ||
import type { TokenizeContext } from 'micromark-util-types'; | ||
//# sourceMappingURL=index.d.ts.map |
/** | ||
* @typedef {import('micromark-util-types').Effects} Effects | ||
* @typedef {import('micromark-util-types').State} State | ||
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext | ||
* @typedef {import('micromark-util-types').TokenType} TokenType | ||
* @import { | ||
* Effects, | ||
* State, | ||
* TokenizeContext, | ||
* TokenType | ||
* } from 'micromark-util-types' | ||
*/ | ||
import {ok as assert} from 'devlop' | ||
import {markdownLineEnding, markdownSpace} from 'micromark-util-character' | ||
import {codes, constants, types} from 'micromark-util-symbol' | ||
import {ok as assert} from 'devlop' | ||
@@ -43,3 +45,2 @@ /** | ||
*/ | ||
// eslint-disable-next-line max-params | ||
export function factoryLabel(effects, ok, nok, type, markerType, stringType) { | ||
@@ -46,0 +47,0 @@ const self = this |
@@ -32,14 +32,7 @@ /** | ||
*/ | ||
export function factoryLabel( | ||
this: import('micromark-util-types').TokenizeContext, | ||
effects: Effects, | ||
ok: State, | ||
nok: State, | ||
type: TokenType, | ||
markerType: TokenType, | ||
stringType: TokenType | ||
): State | ||
export type Effects = import('micromark-util-types').Effects | ||
export type State = import('micromark-util-types').State | ||
export type TokenizeContext = import('micromark-util-types').TokenizeContext | ||
export type TokenType = import('micromark-util-types').TokenType | ||
export function factoryLabel(this: TokenizeContext, effects: Effects, ok: State, nok: State, type: TokenType, markerType: TokenType, stringType: TokenType): State; | ||
import type { Effects } from 'micromark-util-types'; | ||
import type { State } from 'micromark-util-types'; | ||
import type { TokenType } from 'micromark-util-types'; | ||
import type { TokenizeContext } from 'micromark-util-types'; | ||
//# sourceMappingURL=index.d.ts.map |
113
index.js
/** | ||
* @typedef {import('micromark-util-types').Effects} Effects | ||
* @typedef {import('micromark-util-types').State} State | ||
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext | ||
* @typedef {import('micromark-util-types').TokenType} TokenType | ||
* @import { | ||
* Effects, | ||
* State, | ||
* TokenizeContext, | ||
* TokenType | ||
* } from 'micromark-util-types' | ||
*/ | ||
import {markdownLineEnding, markdownSpace} from 'micromark-util-character' | ||
import { markdownLineEnding, markdownSpace } from 'micromark-util-character'; | ||
/** | ||
@@ -39,9 +41,9 @@ * Parse labels. | ||
* Start state. | ||
*/ // eslint-disable-next-line max-params | ||
*/ | ||
export function factoryLabel(effects, ok, nok, type, markerType, stringType) { | ||
const self = this | ||
let size = 0 | ||
const self = this; | ||
let size = 0; | ||
/** @type {boolean} */ | ||
let seen | ||
return start | ||
let seen; | ||
return start; | ||
@@ -59,8 +61,8 @@ /** | ||
function start(code) { | ||
effects.enter(type) | ||
effects.enter(markerType) | ||
effects.consume(code) | ||
effects.exit(markerType) | ||
effects.enter(stringType) | ||
return atBreak | ||
effects.enter(type); | ||
effects.enter(markerType); | ||
effects.consume(code); | ||
effects.exit(markerType); | ||
effects.enter(stringType); | ||
return atBreak; | ||
} | ||
@@ -79,25 +81,18 @@ | ||
function atBreak(code) { | ||
if ( | ||
size > 999 || | ||
code === null || | ||
code === 91 || | ||
(code === 93 && !seen) || | ||
// To do: remove in the future once we’ve switched from | ||
// `micromark-extension-footnote` to `micromark-extension-gfm-footnote`, | ||
// which doesn’t need this. | ||
// Hidden footnotes hook. | ||
/* c8 ignore next 3 */ | ||
(code === 94 && | ||
!size && | ||
'_hiddenFootnoteSupport' in self.parser.constructs) | ||
) { | ||
return nok(code) | ||
if (size > 999 || code === null || code === 91 || code === 93 && !seen || | ||
// To do: remove in the future once we’ve switched from | ||
// `micromark-extension-footnote` to `micromark-extension-gfm-footnote`, | ||
// which doesn’t need this. | ||
// Hidden footnotes hook. | ||
/* c8 ignore next 3 */ | ||
code === 94 && !size && '_hiddenFootnoteSupport' in self.parser.constructs) { | ||
return nok(code); | ||
} | ||
if (code === 93) { | ||
effects.exit(stringType) | ||
effects.enter(markerType) | ||
effects.consume(code) | ||
effects.exit(markerType) | ||
effects.exit(type) | ||
return ok | ||
effects.exit(stringType); | ||
effects.enter(markerType); | ||
effects.consume(code); | ||
effects.exit(markerType); | ||
effects.exit(type); | ||
return ok; | ||
} | ||
@@ -107,11 +102,11 @@ | ||
if (markdownLineEnding(code)) { | ||
effects.enter('lineEnding') | ||
effects.consume(code) | ||
effects.exit('lineEnding') | ||
return atBreak | ||
effects.enter("lineEnding"); | ||
effects.consume(code); | ||
effects.exit("lineEnding"); | ||
return atBreak; | ||
} | ||
effects.enter('chunkString', { | ||
contentType: 'string' | ||
}) | ||
return labelInside(code) | ||
effects.enter("chunkString", { | ||
contentType: "string" | ||
}); | ||
return labelInside(code); | ||
} | ||
@@ -130,15 +125,9 @@ | ||
function labelInside(code) { | ||
if ( | ||
code === null || | ||
code === 91 || | ||
code === 93 || | ||
markdownLineEnding(code) || | ||
size++ > 999 | ||
) { | ||
effects.exit('chunkString') | ||
return atBreak(code) | ||
if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) { | ||
effects.exit("chunkString"); | ||
return atBreak(code); | ||
} | ||
effects.consume(code) | ||
if (!seen) seen = !markdownSpace(code) | ||
return code === 92 ? labelEscape : labelInside | ||
effects.consume(code); | ||
if (!seen) seen = !markdownSpace(code); | ||
return code === 92 ? labelEscape : labelInside; | ||
} | ||
@@ -158,8 +147,8 @@ | ||
if (code === 91 || code === 92 || code === 93) { | ||
effects.consume(code) | ||
size++ | ||
return labelInside | ||
effects.consume(code); | ||
size++; | ||
return labelInside; | ||
} | ||
return labelInside(code) | ||
return labelInside(code); | ||
} | ||
} | ||
} |
{ | ||
"name": "micromark-factory-label", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "micromark factory to parse labels (found in media, definitions)", | ||
@@ -31,2 +31,3 @@ "license": "MIT", | ||
"dev/", | ||
"index.d.ts.map", | ||
"index.d.ts", | ||
@@ -48,3 +49,14 @@ "index.js" | ||
}, | ||
"xo": false | ||
"xo": { | ||
"envs": [ | ||
"shared-node-browser" | ||
], | ||
"prettier": true, | ||
"rules": { | ||
"logical-assignment-operators": "off", | ||
"max-params": "off", | ||
"unicorn/no-this-assignment": "off", | ||
"unicorn/prefer-code-point": "off" | ||
} | ||
} | ||
} |
@@ -15,13 +15,13 @@ # micromark-factory-label | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`factoryLabel(…)`](#factorylabel) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`factoryLabel(…)`](#factorylabel) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
@@ -69,2 +69,3 @@ ## What is this? | ||
* @this {TokenizeContext} | ||
* Context. | ||
* @type {Tokenizer} | ||
@@ -118,16 +119,16 @@ */ | ||
* `this` (`TokenizeContext`) | ||
— tokenize context | ||
* `effects` (`Effects`) | ||
— context | ||
* `ok` (`State`) | ||
— state switched to when successful | ||
* `nok` (`State`) | ||
— state switched to when unsuccessful | ||
* `type` (`string`) | ||
— type of the whole label (`[a]`) | ||
* `markerType` (`string`) | ||
— type for the markers (`[` and `]`) | ||
* `stringType` (`string`) | ||
— type for the identifier (`a`) | ||
* `this` (`TokenizeContext`) | ||
— tokenize context | ||
* `effects` (`Effects`) | ||
— context | ||
* `ok` (`State`) | ||
— state switched to when successful | ||
* `nok` (`State`) | ||
— state switched to when unsuccessful | ||
* `type` (`string`) | ||
— type of the whole label (`[a]`) | ||
* `markerType` (`string`) | ||
— type for the markers (`[` and `]`) | ||
* `stringType` (`string`) | ||
— type for the identifier (`a`) | ||
@@ -151,4 +152,4 @@ ###### Returns | ||
This means we try to keep the current release line, | ||
`micromark-factory-label@^2`, compatible with Node.js 16. | ||
This package works with `micromark@^3`. | ||
`micromark-factory-label@2`, compatible with Node.js 16. | ||
This package works with `micromark@3`. | ||
@@ -155,0 +156,0 @@ ## Security |
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
17588
9
225
373