Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

micromark-extension-directive

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-extension-directive - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

1

dev/lib/factory-label.d.ts

@@ -23,1 +23,2 @@ /**

export type State = import('micromark-util-types').State
export type Token = import('micromark-util-types').Token

80

dev/lib/factory-label.js
/**
* @typedef {import('micromark-util-types').Effects} Effects
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').Token} Token
*/

@@ -38,2 +39,4 @@

let balance = 0
/** @type {Token|undefined} */
let previous

@@ -63,39 +66,24 @@ return start

effects.enter(stringType)
return atBreak(code)
return lineStart(code)
}
/** @type {State} */
function atBreak(code) {
if (code === codes.eof || size > constants.linkReferenceSizeMax) {
return nok(code)
}
if (code === codes.rightSquareBracket && !balance--) {
function lineStart(code) {
if (code === codes.rightSquareBracket && !balance) {
return atClosingBrace(code)
}
if (markdownLineEnding(code)) {
if (disallowEol) {
return nok(code)
}
effects.enter(types.lineEnding)
effects.consume(code)
effects.exit(types.lineEnding)
return atBreak
}
effects.enter(types.chunkText, {contentType: constants.contentTypeText})
return label(code)
const token = effects.enter(types.chunkText, {
contentType: constants.contentTypeText,
previous
})
if (previous) previous.next = token
previous = token
return data(code)
}
/** @type {State} */
function label(code) {
if (
code === codes.eof ||
markdownLineEnding(code) ||
size > constants.linkReferenceSizeMax
) {
effects.exit(types.chunkText)
return atBreak(code)
function data(code) {
if (code === codes.eof || size > constants.linkReferenceSizeMax) {
return nok(code)
}

@@ -115,18 +103,18 @@

effects.consume(code)
return code === codes.backslash ? labelEscape : label
}
if (markdownLineEnding(code)) {
if (disallowEol) {
return nok(code)
}
/** @type {State} */
function atClosingBrace(code) {
effects.exit(stringType)
effects.enter(markerType)
effects.consume(code)
effects.exit(types.chunkText)
return lineStart
}
effects.consume(code)
effects.exit(markerType)
effects.exit(type)
return ok
return code === codes.backslash ? dataEscape : data
}
/** @type {State} */
function labelEscape(code) {
function dataEscape(code) {
if (

@@ -139,7 +127,17 @@ code === codes.leftSquareBracket ||

size++
return label
return data
}
return label(code)
return data(code)
}
/** @type {State} */
function atClosingBrace(code) {
effects.exit(stringType)
effects.enter(markerType)
effects.consume(code)
effects.exit(markerType)
effects.exit(type)
return ok
}
}

@@ -23,1 +23,2 @@ /**

export type State = import('micromark-util-types').State
export type Token = import('micromark-util-types').Token
/**
* @typedef {import('micromark-util-types').Effects} Effects
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').Token} Token
*/

@@ -32,2 +33,5 @@ import {markdownLineEnding} from 'micromark-util-character'

let balance = 0
/** @type {Token|undefined} */
let previous
return start

@@ -55,7 +59,22 @@ /** @type {State} */

effects.enter(stringType)
return atBreak(code)
return lineStart(code)
}
/** @type {State} */
function atBreak(code) {
function lineStart(code) {
if (code === 93 && !balance) {
return atClosingBrace(code)
}
const token = effects.enter('chunkText', {
contentType: 'text',
previous
})
if (previous) previous.next = token
previous = token
return data(code)
}
/** @type {State} */
function data(code) {
if (code === null || size > 999) {

@@ -65,3 +84,8 @@ return nok(code)

if (code === 91 && ++balance > 32) {
return nok(code)
}
if (code === 93 && !balance--) {
effects.exit('chunkText')
return atClosingBrace(code)

@@ -75,32 +99,20 @@ }

effects.enter('lineEnding')
effects.consume(code)
effects.exit('lineEnding')
return atBreak
effects.exit('chunkText')
return lineStart
}
effects.enter('chunkText', {
contentType: 'text'
})
return label(code)
effects.consume(code)
return code === 92 ? dataEscape : data
}
/** @type {State} */
function label(code) {
if (code === null || markdownLineEnding(code) || size > 999) {
effects.exit('chunkText')
return atBreak(code)
function dataEscape(code) {
if (code === 91 || code === 92 || code === 93) {
effects.consume(code)
size++
return data
}
if (code === 91 && ++balance > 3) {
return nok(code)
}
if (code === 93 && !balance--) {
effects.exit('chunkText')
return atClosingBrace(code)
}
effects.consume(code)
return code === 92 ? labelEscape : label
return data(code)
}

@@ -117,13 +129,2 @@ /** @type {State} */

}
/** @type {State} */
function labelEscape(code) {
if (code === 91 || code === 92 || code === 93) {
effects.consume(code)
size++
return label
}
return label(code)
}
}
{
"name": "micromark-extension-directive",
"version": "2.1.0",
"version": "2.1.1",
"description": "micromark extension to support generic directives (`:cite[smith04]`)",

@@ -62,3 +62,3 @@ "license": "MIT",

"typescript": "^4.0.0",
"xo": "^0.46.0"
"xo": "^0.47.0"
},

@@ -65,0 +65,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc