Comparing version 3.0.3 to 3.0.4
@@ -82,4 +82,59 @@ /** | ||
) | ||
if (self.containerState._closeFlow) closeFlow() | ||
continued++ | ||
// Note: this field is called `_closeFlow` but it also closes containers. | ||
// Perhaps a good idea to rename it but it’s already used in the wild by | ||
// extensions. | ||
if (self.containerState._closeFlow) { | ||
self.containerState._closeFlow = undefined | ||
if (childFlow) { | ||
closeFlow() | ||
} | ||
// Note: this algorithm for moving events around is similar to the | ||
// algorithm when dealing with lazy lines in `writeToChild`. | ||
const indexBeforeExits = self.events.length | ||
let indexBeforeFlow = indexBeforeExits | ||
/** @type {Point|undefined} */ | ||
let point | ||
// Find the flow chunk. | ||
while (indexBeforeFlow--) { | ||
if ( | ||
self.events[indexBeforeFlow][0] === 'exit' && | ||
self.events[indexBeforeFlow][1].type === types.chunkFlow | ||
) { | ||
point = self.events[indexBeforeFlow][1].end | ||
break | ||
} | ||
} | ||
assert(point, 'could not find previous flow chunk') | ||
exitContainers(continued) | ||
// Fix positions. | ||
let index = indexBeforeExits | ||
while (index < self.events.length) { | ||
self.events[index][1].end = Object.assign({}, point) | ||
index++ | ||
} | ||
// Inject the exits earlier (they’re still also at the end). | ||
splice( | ||
self.events, | ||
indexBeforeFlow + 1, | ||
0, | ||
self.events.slice(indexBeforeExits) | ||
) | ||
// Discard the duplicate exits. | ||
self.events.length = index | ||
return checkNewContainers(code) | ||
} | ||
return start(code) | ||
@@ -273,2 +328,4 @@ } | ||
// Note: this algorithm for moving events around is similar to the | ||
// algorithm when closing flow in `documentContinue`. | ||
const indexBeforeExits = self.events.length | ||
@@ -275,0 +332,0 @@ let indexBeforeFlow = indexBeforeExits |
@@ -75,4 +75,50 @@ /** | ||
function documentContinue(code) { | ||
if (self.containerState._closeFlow) closeFlow() | ||
continued++ | ||
continued++ // Note: this field is called `_closeFlow` but it also closes containers. | ||
// Perhaps a good idea to rename it but it’s already used in the wild by | ||
// extensions. | ||
if (self.containerState._closeFlow) { | ||
self.containerState._closeFlow = undefined | ||
if (childFlow) { | ||
closeFlow() | ||
} // Note: this algorithm for moving events around is similar to the | ||
// algorithm when dealing with lazy lines in `writeToChild`. | ||
const indexBeforeExits = self.events.length | ||
let indexBeforeFlow = indexBeforeExits | ||
/** @type {Point|undefined} */ | ||
let point // Find the flow chunk. | ||
while (indexBeforeFlow--) { | ||
if ( | ||
self.events[indexBeforeFlow][0] === 'exit' && | ||
self.events[indexBeforeFlow][1].type === 'chunkFlow' | ||
) { | ||
point = self.events[indexBeforeFlow][1].end | ||
break | ||
} | ||
} | ||
exitContainers(continued) // Fix positions. | ||
let index = indexBeforeExits | ||
while (index < self.events.length) { | ||
self.events[index][1].end = Object.assign({}, point) | ||
index++ | ||
} // Inject the exits earlier (they’re still also at the end). | ||
splice( | ||
self.events, | ||
indexBeforeFlow + 1, | ||
0, | ||
self.events.slice(indexBeforeExits) | ||
) // Discard the duplicate exits. | ||
self.events.length = index | ||
return checkNewContainers(code) | ||
} | ||
return start(code) | ||
@@ -248,3 +294,4 @@ } | ||
} | ||
} | ||
} // Note: this algorithm for moving events around is similar to the | ||
// algorithm when closing flow in `documentContinue`. | ||
@@ -251,0 +298,0 @@ const indexBeforeExits = self.events.length |
{ | ||
"name": "micromark", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "small commonmark compliant markdown parser with positional info and concrete tokens", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
228913
5433