Socket
Socket
Sign inDemoInstall

micromark-extension-gfm-table

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-extension-gfm-table - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

116

dev/lib/syntax.js

@@ -29,6 +29,2 @@ /**

const setextUnderlineMini = {
tokenize: tokenizeSetextUnderlineMini,
partial: true
}
const nextPrefixedOrBlank = {

@@ -281,6 +277,15 @@ tokenize: tokenizeNextPrefixedOrBlank,

effects.exit('tableHead')
const originalInterrupt = self.interrupt
self.interrupt = true
return effects.attempt(
{tokenize: tokenizeRowEnd, partial: true},
atDelimiterLineStart,
nok
function (code) {
self.interrupt = originalInterrupt
effects.enter('tableDelimiterRow')
return atDelimiterRowBreak(code)
},
function (code) {
self.interrupt = originalInterrupt
return nok(code)
}
)(code)

@@ -290,28 +295,2 @@ }

/** @type {State} */
function atDelimiterLineStart(code) {
return effects.check(
setextUnderlineMini,
nok,
// Support an indent before the delimiter row.
factorySpace(
effects,
rowStartDelimiter,
types.linePrefix,
constants.tabSize
)
)(code)
}
/** @type {State} */
function rowStartDelimiter(code) {
// If there’s another space, or we’re at the EOL/EOF, exit.
if (code === codes.eof || markdownLineEndingOrSpace(code)) {
return nok(code)
}
effects.enter('tableDelimiterRow')
return atDelimiterRowBreak(code)
}
/** @type {State} */
function atDelimiterRowBreak(code) {

@@ -588,52 +567,43 @@ if (code === codes.eof || markdownLineEnding(code)) {

effects.exit(types.lineEnding)
return lineStart
return factorySpace(effects, prefixed, types.linePrefix)
}
/** @type {State} */
function lineStart(code) {
return self.parser.lazy[self.now().line] ? nok(code) : ok(code)
}
}
}
function prefixed(code) {
// Blank or interrupting line.
if (
self.parser.lazy[self.now().line] ||
code === codes.eof ||
markdownLineEnding(code)
) {
return nok(code)
}
// Based on micromark, but that won’t work as we’re in a table, and that expects
// content.
// <https://github.com/micromark/micromark/blob/main/lib/tokenize/setext-underline.js>
/** @type {Tokenizer} */
function tokenizeSetextUnderlineMini(effects, ok, nok) {
return start
const tail = self.events[self.events.length - 1]
/** @type {State} */
function start(code) {
if (code !== codes.dash) {
return nok(code)
}
// Indented code can interrupt delimiter and body rows.
if (
!self.parser.constructs.disable.null.includes('codeIndented') &&
tail &&
tail[1].type === types.linePrefix &&
tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize
) {
return nok(code)
}
effects.enter('setextUnderline')
return sequence(code)
}
self._gfmTableDynamicInterruptHack = true
/** @type {State} */
function sequence(code) {
if (code === codes.dash) {
effects.consume(code)
return sequence
return effects.check(
self.parser.constructs.flow,
function (code) {
self._gfmTableDynamicInterruptHack = false
return nok(code)
},
function (code) {
self._gfmTableDynamicInterruptHack = false
return ok(code)
}
)(code)
}
return whitespace(code)
}
/** @type {State} */
function whitespace(code) {
if (code === codes.eof || markdownLineEnding(code)) {
return ok(code)
}
if (markdownSpace(code)) {
effects.consume(code)
return whitespace
}
return nok(code)
}
}

@@ -640,0 +610,0 @@

@@ -28,6 +28,2 @@ /**

}
const setextUnderlineMini = {
tokenize: tokenizeSetextUnderlineMini,
partial: true
}
const nextPrefixedOrBlank = {

@@ -267,2 +263,4 @@ tokenize: tokenizeNextPrefixedOrBlank,

effects.exit('tableHead')
const originalInterrupt = self.interrupt
self.interrupt = true
return effects.attempt(

@@ -273,4 +271,11 @@ {

},
atDelimiterLineStart,
nok
function (code) {
self.interrupt = originalInterrupt
effects.enter('tableDelimiterRow')
return atDelimiterRowBreak(code)
},
function (code) {
self.interrupt = originalInterrupt
return nok(code)
}
)(code)

@@ -280,22 +285,2 @@ }

function atDelimiterLineStart(code) {
return effects.check(
setextUnderlineMini,
nok, // Support an indent before the delimiter row.
factorySpace(effects, rowStartDelimiter, 'linePrefix', 4)
)(code)
}
/** @type {State} */
function rowStartDelimiter(code) {
// If there’s another space, or we’re at the EOL/EOF, exit.
if (code === null || markdownLineEndingOrSpace(code)) {
return nok(code)
}
effects.enter('tableDelimiterRow')
return atDelimiterRowBreak(code)
}
/** @type {State} */
function atDelimiterRowBreak(code) {

@@ -554,52 +539,41 @@ if (code === null || markdownLineEnding(code)) {

effects.exit('lineEnding')
return lineStart
return factorySpace(effects, prefixed, 'linePrefix')
}
/** @type {State} */
function lineStart(code) {
return self.parser.lazy[self.now().line] ? nok(code) : ok(code)
}
}
} // Based on micromark, but that won’t work as we’re in a table, and that expects
// content.
// <https://github.com/micromark/micromark/blob/main/lib/tokenize/setext-underline.js>
function prefixed(code) {
// Blank or interrupting line.
if (
self.parser.lazy[self.now().line] ||
code === null ||
markdownLineEnding(code)
) {
return nok(code)
}
/** @type {Tokenizer} */
const tail = self.events[self.events.length - 1] // Indented code can interrupt delimiter and body rows.
function tokenizeSetextUnderlineMini(effects, ok, nok) {
return start
/** @type {State} */
if (
!self.parser.constructs.disable.null.includes('codeIndented') &&
tail &&
tail[1].type === 'linePrefix' &&
tail[2].sliceSerialize(tail[1], true).length >= 4
) {
return nok(code)
}
function start(code) {
if (code !== 45) {
return nok(code)
self._gfmTableDynamicInterruptHack = true
return effects.check(
self.parser.constructs.flow,
function (code) {
self._gfmTableDynamicInterruptHack = false
return nok(code)
},
function (code) {
self._gfmTableDynamicInterruptHack = false
return ok(code)
}
)(code)
}
effects.enter('setextUnderline')
return sequence(code)
}
/** @type {State} */
function sequence(code) {
if (code === 45) {
effects.consume(code)
return sequence
}
return whitespace(code)
}
/** @type {State} */
function whitespace(code) {
if (code === null || markdownLineEnding(code)) {
return ok(code)
}
if (markdownSpace(code)) {
effects.consume(code)
return whitespace
}
return nok(code)
}
}

@@ -606,0 +580,0 @@ /** @type {Tokenizer} */

{
"name": "micromark-extension-gfm-table",
"version": "1.0.3",
"version": "1.0.4",
"description": "micromark extension to support GFM tables",

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

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

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

@@ -64,3 +64,3 @@ # micromark-extension-gfm-table

The export map supports the endorsed
[`development` condition](https://nodejs.org/api/packages.html#packages\_resolving\_user\_conditions).
[`development` condition](https://nodejs.org/api/packages.html#packages_resolving_user_conditions).
Run `node --conditions development module.js` to get instrumented dev code.

@@ -67,0 +67,0 @@ Without this condition, production code is loaded.

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