micromark-factory-title
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -32,13 +32,6 @@ /** | ||
*/ | ||
export function factoryTitle( | ||
effects: Effects, | ||
ok: State, | ||
nok: State, | ||
type: TokenType, | ||
markerType: TokenType, | ||
stringType: TokenType | ||
): State | ||
export type Code = import('micromark-util-types').Code | ||
export type Effects = import('micromark-util-types').Effects | ||
export type State = import('micromark-util-types').State | ||
export type TokenType = import('micromark-util-types').TokenType | ||
export function factoryTitle(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'; | ||
//# sourceMappingURL=index.d.ts.map |
/** | ||
* @typedef {import('micromark-util-types').Code} Code | ||
* @typedef {import('micromark-util-types').Effects} Effects | ||
* @typedef {import('micromark-util-types').State} State | ||
* @typedef {import('micromark-util-types').TokenType} TokenType | ||
* @import { | ||
* Code, | ||
* Effects, | ||
* State, | ||
* TokenType | ||
* } from 'micromark-util-types' | ||
*/ | ||
@@ -43,3 +45,2 @@ | ||
*/ | ||
// eslint-disable-next-line max-params | ||
export function factoryTitle(effects, ok, nok, type, markerType, stringType) { | ||
@@ -46,0 +47,0 @@ /** @type {NonNullable<Code>} */ |
@@ -32,13 +32,6 @@ /** | ||
*/ | ||
export function factoryTitle( | ||
effects: Effects, | ||
ok: State, | ||
nok: State, | ||
type: TokenType, | ||
markerType: TokenType, | ||
stringType: TokenType | ||
): State | ||
export type Code = import('micromark-util-types').Code | ||
export type Effects = import('micromark-util-types').Effects | ||
export type State = import('micromark-util-types').State | ||
export type TokenType = import('micromark-util-types').TokenType | ||
export function factoryTitle(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'; | ||
//# sourceMappingURL=index.d.ts.map |
86
index.js
/** | ||
* @typedef {import('micromark-util-types').Code} Code | ||
* @typedef {import('micromark-util-types').Effects} Effects | ||
* @typedef {import('micromark-util-types').State} State | ||
* @typedef {import('micromark-util-types').TokenType} TokenType | ||
* @import { | ||
* Code, | ||
* Effects, | ||
* State, | ||
* TokenType | ||
* } from 'micromark-util-types' | ||
*/ | ||
import {factorySpace} from 'micromark-factory-space' | ||
import {markdownLineEnding} from 'micromark-util-character' | ||
import { factorySpace } from 'micromark-factory-space'; | ||
import { markdownLineEnding } from 'micromark-util-character'; | ||
/** | ||
@@ -40,7 +42,7 @@ * Parse titles. | ||
* Start state. | ||
*/ // eslint-disable-next-line max-params | ||
*/ | ||
export function factoryTitle(effects, ok, nok, type, markerType, stringType) { | ||
/** @type {NonNullable<Code>} */ | ||
let marker | ||
return start | ||
let marker; | ||
return start; | ||
@@ -59,10 +61,10 @@ /** | ||
if (code === 34 || code === 39 || code === 40) { | ||
effects.enter(type) | ||
effects.enter(markerType) | ||
effects.consume(code) | ||
effects.exit(markerType) | ||
marker = code === 40 ? 41 : code | ||
return begin | ||
effects.enter(type); | ||
effects.enter(markerType); | ||
effects.consume(code); | ||
effects.exit(markerType); | ||
marker = code === 40 ? 41 : code; | ||
return begin; | ||
} | ||
return nok(code) | ||
return nok(code); | ||
} | ||
@@ -84,10 +86,10 @@ | ||
if (code === marker) { | ||
effects.enter(markerType) | ||
effects.consume(code) | ||
effects.exit(markerType) | ||
effects.exit(type) | ||
return ok | ||
effects.enter(markerType); | ||
effects.consume(code); | ||
effects.exit(markerType); | ||
effects.exit(type); | ||
return ok; | ||
} | ||
effects.enter(stringType) | ||
return atBreak(code) | ||
effects.enter(stringType); | ||
return atBreak(code); | ||
} | ||
@@ -107,7 +109,7 @@ | ||
if (code === marker) { | ||
effects.exit(stringType) | ||
return begin(marker) | ||
effects.exit(stringType); | ||
return begin(marker); | ||
} | ||
if (code === null) { | ||
return nok(code) | ||
return nok(code); | ||
} | ||
@@ -118,11 +120,11 @@ | ||
// To do: use `space_or_tab_eol_with_options`, connect. | ||
effects.enter('lineEnding') | ||
effects.consume(code) | ||
effects.exit('lineEnding') | ||
return factorySpace(effects, atBreak, 'linePrefix') | ||
effects.enter("lineEnding"); | ||
effects.consume(code); | ||
effects.exit("lineEnding"); | ||
return factorySpace(effects, atBreak, "linePrefix"); | ||
} | ||
effects.enter('chunkString', { | ||
contentType: 'string' | ||
}) | ||
return inside(code) | ||
effects.enter("chunkString", { | ||
contentType: "string" | ||
}); | ||
return inside(code); | ||
} | ||
@@ -137,7 +139,7 @@ | ||
if (code === marker || code === null || markdownLineEnding(code)) { | ||
effects.exit('chunkString') | ||
return atBreak(code) | ||
effects.exit("chunkString"); | ||
return atBreak(code); | ||
} | ||
effects.consume(code) | ||
return code === 92 ? escape : inside | ||
effects.consume(code); | ||
return code === 92 ? escape : inside; | ||
} | ||
@@ -157,7 +159,7 @@ | ||
if (code === marker || code === 92) { | ||
effects.consume(code) | ||
return inside | ||
effects.consume(code); | ||
return inside; | ||
} | ||
return inside(code) | ||
return inside(code); | ||
} | ||
} | ||
} |
{ | ||
"name": "micromark-factory-title", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "micromark factory to parse markdown titles (found in resources, definitions)", | ||
@@ -31,2 +31,3 @@ "license": "MIT", | ||
"dev/", | ||
"index.d.ts.map", | ||
"index.d.ts", | ||
@@ -48,3 +49,12 @@ "index.js" | ||
}, | ||
"xo": false | ||
"xo": { | ||
"envs": [ | ||
"shared-node-browser" | ||
], | ||
"prettier": true, | ||
"rules": { | ||
"max-params": "off", | ||
"unicorn/prefer-code-point": "off" | ||
} | ||
} | ||
} |
@@ -16,13 +16,13 @@ # micromark-factory-title | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`factoryTitle(…)`](#factorytitle) | ||
* [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) | ||
* [`factoryTitle(…)`](#factorytitle) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
@@ -69,2 +69,3 @@ ## What is this? | ||
* @this {TokenizeContext} | ||
* Context. | ||
* @type {Tokenizer} | ||
@@ -125,14 +126,14 @@ */ | ||
* `effects` (`Effects`) | ||
— context | ||
* `ok` (`State`) | ||
— state switched to when successful | ||
* `nok` (`State`) | ||
— state switched to when unsuccessful | ||
* `type` (`string`) | ||
— type of the whole title (`"a"`, `'b'`, `(c)`) | ||
* `markerType` (`string`) | ||
— type for the markers (`"`, `'`, `(`, and `)`) | ||
* `stringType` (`string`) | ||
— type for the value (`a`) | ||
* `effects` (`Effects`) | ||
— context | ||
* `ok` (`State`) | ||
— state switched to when successful | ||
* `nok` (`State`) | ||
— state switched to when unsuccessful | ||
* `type` (`string`) | ||
— type of the whole title (`"a"`, `'b'`, `(c)`) | ||
* `markerType` (`string`) | ||
— type for the markers (`"`, `'`, `(`, and `)`) | ||
* `stringType` (`string`) | ||
— type for the value (`a`) | ||
@@ -156,4 +157,4 @@ ###### Returns | ||
This means we try to keep the current release line, | ||
`micromark-factory-title@^2`, compatible with Node.js 16. | ||
This package works with `micromark@^3`. | ||
`micromark-factory-title@2`, compatible with Node.js 16. | ||
This package works with `micromark@3`. | ||
@@ -160,0 +161,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
16527
9
230
374