micromark-extension-directive
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -95,3 +95,3 @@ /** | ||
if (code === codes.eof) { | ||
return afterOpening(code) | ||
return after(code) | ||
} | ||
@@ -104,3 +104,3 @@ | ||
return effects.attempt(nonLazyLine, contentStart, afterOpening)(code) | ||
return effects.attempt(nonLazyLine, contentStart, after)(code) | ||
} | ||
@@ -112,14 +112,15 @@ | ||
/** @type {State} */ | ||
function afterOpening(code) { | ||
effects.exit('directiveContainer') | ||
return ok(code) | ||
} | ||
/** @type {State} */ | ||
function contentStart(code) { | ||
if (code === codes.eof) { | ||
effects.exit('directiveContainer') | ||
return ok(code) | ||
return after(code) | ||
} | ||
if (markdownLineEnding(code)) { | ||
return effects.check( | ||
nonLazyLine, | ||
emptyContentNonLazyLineAfter, | ||
after | ||
)(code) | ||
} | ||
effects.enter('directiveContainerContent') | ||
@@ -131,9 +132,5 @@ return lineStart(code) | ||
function lineStart(code) { | ||
if (code === codes.eof) { | ||
return after(code) | ||
} | ||
return effects.attempt( | ||
{tokenize: tokenizeClosingFence, partial: true}, | ||
after, | ||
afterContent, | ||
initialSize | ||
@@ -148,12 +145,10 @@ ? factorySpace(effects, chunkStart, types.linePrefix, initialSize + 1) | ||
if (code === codes.eof) { | ||
return after(code) | ||
return afterContent(code) | ||
} | ||
const token = effects.enter(types.chunkDocument, { | ||
contentType: constants.contentTypeDocument, | ||
previous | ||
}) | ||
if (previous) previous.next = token | ||
previous = token | ||
return contentContinue(code) | ||
if (markdownLineEnding(code)) { | ||
return effects.check(nonLazyLine, chunkNonLazyStart, afterContent)(code) | ||
} | ||
return chunkNonLazyStart(code) | ||
} | ||
@@ -166,3 +161,3 @@ | ||
self.parser.lazy[t.start.line] = false | ||
return after(code) | ||
return afterContent(code) | ||
} | ||
@@ -179,2 +174,19 @@ | ||
/** @type {State} */ | ||
function chunkNonLazyStart(code) { | ||
const token = effects.enter(types.chunkDocument, { | ||
contentType: constants.contentTypeDocument, | ||
previous | ||
}) | ||
if (previous) previous.next = token | ||
previous = token | ||
return contentContinue(code) | ||
} | ||
/** @type {State} */ | ||
function emptyContentNonLazyLineAfter(code) { | ||
effects.enter('directiveContainerContent') | ||
return lineStart(code) | ||
} | ||
/** @type {State} */ | ||
function nonLazyLineAfter(code) { | ||
@@ -191,2 +203,8 @@ effects.consume(code) | ||
self.parser.lazy[t.start.line] = false | ||
return afterContent(code) | ||
} | ||
/** @type {State} */ | ||
function afterContent(code) { | ||
effects.exit('directiveContainerContent') | ||
return after(code) | ||
@@ -197,3 +215,2 @@ } | ||
function after(code) { | ||
effects.exit('directiveContainerContent') | ||
effects.exit('directiveContainer') | ||
@@ -200,0 +217,0 @@ return ok(code) |
@@ -83,3 +83,3 @@ /** | ||
if (code === null) { | ||
return afterOpening(code); | ||
return after(code); | ||
} | ||
@@ -90,3 +90,3 @@ if (markdownLineEnding(code)) { | ||
} | ||
return effects.attempt(nonLazyLine, contentStart, afterOpening)(code); | ||
return effects.attempt(nonLazyLine, contentStart, after)(code); | ||
} | ||
@@ -97,13 +97,9 @@ return nok(code); | ||
/** @type {State} */ | ||
function afterOpening(code) { | ||
effects.exit('directiveContainer'); | ||
return ok(code); | ||
} | ||
/** @type {State} */ | ||
function contentStart(code) { | ||
if (code === null) { | ||
effects.exit('directiveContainer'); | ||
return ok(code); | ||
return after(code); | ||
} | ||
if (markdownLineEnding(code)) { | ||
return effects.check(nonLazyLine, emptyContentNonLazyLineAfter, after)(code); | ||
} | ||
effects.enter('directiveContainerContent'); | ||
@@ -115,9 +111,6 @@ return lineStart(code); | ||
function lineStart(code) { | ||
if (code === null) { | ||
return after(code); | ||
} | ||
return effects.attempt({ | ||
tokenize: tokenizeClosingFence, | ||
partial: true | ||
}, after, initialSize ? factorySpace(effects, chunkStart, "linePrefix", initialSize + 1) : chunkStart)(code); | ||
}, afterContent, initialSize ? factorySpace(effects, chunkStart, "linePrefix", initialSize + 1) : chunkStart)(code); | ||
} | ||
@@ -128,11 +121,8 @@ | ||
if (code === null) { | ||
return after(code); | ||
return afterContent(code); | ||
} | ||
const token = effects.enter("chunkDocument", { | ||
contentType: "document", | ||
previous | ||
}); | ||
if (previous) previous.next = token; | ||
previous = token; | ||
return contentContinue(code); | ||
if (markdownLineEnding(code)) { | ||
return effects.check(nonLazyLine, chunkNonLazyStart, afterContent)(code); | ||
} | ||
return chunkNonLazyStart(code); | ||
} | ||
@@ -145,3 +135,3 @@ | ||
self.parser.lazy[t.start.line] = false; | ||
return after(code); | ||
return afterContent(code); | ||
} | ||
@@ -156,2 +146,19 @@ if (markdownLineEnding(code)) { | ||
/** @type {State} */ | ||
function chunkNonLazyStart(code) { | ||
const token = effects.enter("chunkDocument", { | ||
contentType: "document", | ||
previous | ||
}); | ||
if (previous) previous.next = token; | ||
previous = token; | ||
return contentContinue(code); | ||
} | ||
/** @type {State} */ | ||
function emptyContentNonLazyLineAfter(code) { | ||
effects.enter('directiveContainerContent'); | ||
return lineStart(code); | ||
} | ||
/** @type {State} */ | ||
function nonLazyLineAfter(code) { | ||
@@ -168,2 +175,8 @@ effects.consume(code); | ||
self.parser.lazy[t.start.line] = false; | ||
return afterContent(code); | ||
} | ||
/** @type {State} */ | ||
function afterContent(code) { | ||
effects.exit('directiveContainerContent'); | ||
return after(code); | ||
@@ -174,3 +187,2 @@ } | ||
function after(code) { | ||
effects.exit('directiveContainerContent'); | ||
effects.exit('directiveContainer'); | ||
@@ -177,0 +189,0 @@ return ok(code); |
{ | ||
"name": "micromark-extension-directive", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "micromark extension to support generic directives (`:cite[smith04]`)", | ||
@@ -48,3 +48,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^20.0.0", | ||
"@types/node": "^22.0.0", | ||
"c8": "^10.0.0", | ||
@@ -59,3 +59,3 @@ "html-void-elements": "^3.0.0", | ||
"typescript": "^5.0.0", | ||
"xo": "^0.58.0" | ||
"xo": "^0.59.0" | ||
}, | ||
@@ -62,0 +62,0 @@ "scripts": { |
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
99423
2626