Skip to content

Commit a600d16

Browse files
nodejs-github-botTrott
authored andcommitted
tools: update lint-md-dependencies to @rollup/plugin-node-resolve@15.0.2
1 parent 509b1eb commit a600d16

File tree

3 files changed

+119
-119
lines changed

3 files changed

+119
-119
lines changed

tools/lint-md/lint-md.mjs

+94-94
Original file line numberDiff line numberDiff line change
@@ -738,28 +738,39 @@ function looksLikeAVFileValue(value) {
738738
return typeof value === 'string' || isBuffer(value)
739739
}
740740

741+
const emptyOptions = {};
741742
function toString(value, options) {
742-
const includeImageAlt = (options || {}).includeImageAlt;
743-
return one(
744-
value,
745-
typeof includeImageAlt === 'boolean' ? includeImageAlt : true
746-
)
743+
const settings = options || emptyOptions;
744+
const includeImageAlt =
745+
typeof settings.includeImageAlt === 'boolean'
746+
? settings.includeImageAlt
747+
: true;
748+
const includeHtml =
749+
typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true;
750+
return one(value, includeImageAlt, includeHtml)
747751
}
748-
function one(value, includeImageAlt) {
749-
return (
750-
(node(value) &&
751-
(('value' in value && value.value) ||
752-
(includeImageAlt && 'alt' in value && value.alt) ||
753-
('children' in value && all(value.children, includeImageAlt)))) ||
754-
(Array.isArray(value) && all(value, includeImageAlt)) ||
755-
''
756-
)
752+
function one(value, includeImageAlt, includeHtml) {
753+
if (node(value)) {
754+
if ('value' in value) {
755+
return value.type === 'html' && !includeHtml ? '' : value.value
756+
}
757+
if (includeImageAlt && 'alt' in value && value.alt) {
758+
return value.alt
759+
}
760+
if ('children' in value) {
761+
return all(value.children, includeImageAlt, includeHtml)
762+
}
763+
}
764+
if (Array.isArray(value)) {
765+
return all(value, includeImageAlt, includeHtml)
766+
}
767+
return ''
757768
}
758-
function all(values, includeImageAlt) {
769+
function all(values, includeImageAlt, includeHtml) {
759770
const result = [];
760771
let index = -1;
761772
while (++index < values.length) {
762-
result[index] = one(values[index], includeImageAlt);
773+
result[index] = one(values[index], includeImageAlt, includeHtml);
763774
}
764775
return result.join('')
765776
}
@@ -9827,7 +9838,7 @@ function tokenizePotentialGfmFootnoteCall(effects, ok, nok) {
98279838
end: self.now()
98289839
})
98299840
);
9830-
if (id.charCodeAt(0) !== 94 || !defined.includes(id.slice(1))) {
9841+
if (id.codePointAt(0) !== 94 || !defined.includes(id.slice(1))) {
98319842
return nok(code)
98329843
}
98339844
effects.enter('gfmFootnoteCallLabelMarker');
@@ -9915,24 +9926,32 @@ function tokenizeGfmFootnoteCall(effects, ok, nok) {
99159926
return callData
99169927
}
99179928
function callData(code) {
9918-
let token;
9919-
if (code === null || code === 91 || size++ > 999) {
9929+
if (
9930+
size > 999 ||
9931+
(code === 93 && !data) ||
9932+
code === null ||
9933+
code === 91 ||
9934+
markdownLineEndingOrSpace(code)
9935+
) {
99209936
return nok(code)
99219937
}
99229938
if (code === 93) {
9923-
if (!data) {
9939+
effects.exit('chunkString');
9940+
const token = effects.exit('gfmFootnoteCallString');
9941+
if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) {
99249942
return nok(code)
99259943
}
9926-
effects.exit('chunkString');
9927-
token = effects.exit('gfmFootnoteCallString');
9928-
return defined.includes(normalizeIdentifier(self.sliceSerialize(token)))
9929-
? end(code)
9930-
: nok(code)
9944+
effects.enter('gfmFootnoteCallLabelMarker');
9945+
effects.consume(code);
9946+
effects.exit('gfmFootnoteCallLabelMarker');
9947+
effects.exit('gfmFootnoteCall');
9948+
return ok
99319949
}
9932-
effects.consume(code);
99339950
if (!markdownLineEndingOrSpace(code)) {
99349951
data = true;
99359952
}
9953+
size++;
9954+
effects.consume(code);
99369955
return code === 92 ? callEscape : callData
99379956
}
99389957
function callEscape(code) {
@@ -9943,13 +9962,6 @@ function tokenizeGfmFootnoteCall(effects, ok, nok) {
99439962
}
99449963
return callData(code)
99459964
}
9946-
function end(code) {
9947-
effects.enter('gfmFootnoteCallLabelMarker');
9948-
effects.consume(code);
9949-
effects.exit('gfmFootnoteCallLabelMarker');
9950-
effects.exit('gfmFootnoteCall');
9951-
return ok
9952-
}
99539965
}
99549966
function tokenizeDefinitionStart(effects, ok, nok) {
99559967
const self = this;
@@ -9964,84 +9976,71 @@ function tokenizeDefinitionStart(effects, ok, nok) {
99649976
effects.enter('gfmFootnoteDefinitionLabelMarker');
99659977
effects.consume(code);
99669978
effects.exit('gfmFootnoteDefinitionLabelMarker');
9967-
return labelStart
9979+
return labelAtMarker
99689980
}
9969-
function labelStart(code) {
9981+
function labelAtMarker(code) {
99709982
if (code === 94) {
99719983
effects.enter('gfmFootnoteDefinitionMarker');
99729984
effects.consume(code);
99739985
effects.exit('gfmFootnoteDefinitionMarker');
99749986
effects.enter('gfmFootnoteDefinitionLabelString');
9975-
return atBreak
9987+
effects.enter('chunkString').contentType = 'string';
9988+
return labelInside
99769989
}
99779990
return nok(code)
99789991
}
9979-
function atBreak(code) {
9980-
let token;
9981-
if (code === null || code === 91 || size > 999) {
9992+
function labelInside(code) {
9993+
if (
9994+
size > 999 ||
9995+
(code === 93 && !data) ||
9996+
code === null ||
9997+
code === 91 ||
9998+
markdownLineEndingOrSpace(code)
9999+
) {
998210000
return nok(code)
998310001
}
998410002
if (code === 93) {
9985-
if (!data) {
9986-
return nok(code)
9987-
}
9988-
token = effects.exit('gfmFootnoteDefinitionLabelString');
10003+
effects.exit('chunkString');
10004+
const token = effects.exit('gfmFootnoteDefinitionLabelString');
998910005
identifier = normalizeIdentifier(self.sliceSerialize(token));
999010006
effects.enter('gfmFootnoteDefinitionLabelMarker');
999110007
effects.consume(code);
999210008
effects.exit('gfmFootnoteDefinitionLabelMarker');
999310009
effects.exit('gfmFootnoteDefinitionLabel');
999410010
return labelAfter
999510011
}
9996-
if (markdownLineEnding(code)) {
9997-
effects.enter('lineEnding');
9998-
effects.consume(code);
9999-
effects.exit('lineEnding');
10000-
size++;
10001-
return atBreak
10002-
}
10003-
effects.enter('chunkString').contentType = 'string';
10004-
return label(code)
10005-
}
10006-
function label(code) {
10007-
if (
10008-
code === null ||
10009-
markdownLineEnding(code) ||
10010-
code === 91 ||
10011-
code === 93 ||
10012-
size > 999
10013-
) {
10014-
effects.exit('chunkString');
10015-
return atBreak(code)
10016-
}
1001710012
if (!markdownLineEndingOrSpace(code)) {
1001810013
data = true;
1001910014
}
1002010015
size++;
1002110016
effects.consume(code);
10022-
return code === 92 ? labelEscape : label
10017+
return code === 92 ? labelEscape : labelInside
1002310018
}
1002410019
function labelEscape(code) {
1002510020
if (code === 91 || code === 92 || code === 93) {
1002610021
effects.consume(code);
1002710022
size++;
10028-
return label
10023+
return labelInside
1002910024
}
10030-
return label(code)
10025+
return labelInside(code)
1003110026
}
1003210027
function labelAfter(code) {
1003310028
if (code === 58) {
1003410029
effects.enter('definitionMarker');
1003510030
effects.consume(code);
1003610031
effects.exit('definitionMarker');
10037-
return factorySpace(effects, done, 'gfmFootnoteDefinitionWhitespace')
10032+
if (!defined.includes(identifier)) {
10033+
defined.push(identifier);
10034+
}
10035+
return factorySpace(
10036+
effects,
10037+
whitespaceAfter,
10038+
'gfmFootnoteDefinitionWhitespace'
10039+
)
1003810040
}
1003910041
return nok(code)
1004010042
}
10041-
function done(code) {
10042-
if (!defined.includes(identifier)) {
10043-
defined.push(identifier);
10044-
}
10043+
function whitespaceAfter(code) {
1004510044
return ok(code)
1004610045
}
1004710046
}
@@ -10069,8 +10068,9 @@ function tokenizeIndent(effects, ok, nok) {
1006910068
}
1007010069
}
1007110070

10072-
function gfmStrikethrough(options = {}) {
10073-
let single = options.singleTilde;
10071+
function gfmStrikethrough(options) {
10072+
const options_ = options || {};
10073+
let single = options_.singleTilde;
1007410074
const tokenizer = {
1007510075
tokenize: tokenizeStrikethrough,
1007610076
resolveAll: resolveAllStrikethrough
@@ -10124,16 +10124,15 @@ function gfmStrikethrough(options = {}) {
1012410124
['exit', events[open][1], context],
1012510125
['enter', text, context]
1012610126
];
10127-
splice(
10128-
nextEvents,
10129-
nextEvents.length,
10130-
0,
10131-
resolveAll(
10132-
context.parser.constructs.insideSpan.null,
10133-
events.slice(open + 1, index),
10134-
context
10135-
)
10136-
);
10127+
const insideSpan = context.parser.constructs.insideSpan.null;
10128+
if (insideSpan) {
10129+
splice(
10130+
nextEvents,
10131+
nextEvents.length,
10132+
0,
10133+
resolveAll(insideSpan, events.slice(open + 1, index), context)
10134+
);
10135+
}
1013710136
splice(nextEvents, nextEvents.length, 0, [
1013810137
['exit', text, context],
1013910138
['enter', events[index][1], context],
@@ -10673,29 +10672,30 @@ function tokenizeTasklistCheck(effects, ok, nok) {
1067310672
effects.consume(code);
1067410673
effects.exit('taskListCheckMarker');
1067510674
effects.exit('taskListCheck');
10675+
return after
10676+
}
10677+
return nok(code)
10678+
}
10679+
function after(code) {
10680+
if (markdownLineEnding(code)) {
10681+
return ok(code)
10682+
}
10683+
if (markdownSpace(code)) {
1067610684
return effects.check(
1067710685
{
1067810686
tokenize: spaceThenNonSpace
1067910687
},
1068010688
ok,
1068110689
nok
10682-
)
10690+
)(code)
1068310691
}
1068410692
return nok(code)
1068510693
}
1068610694
}
1068710695
function spaceThenNonSpace(effects, ok, nok) {
10688-
const self = this;
1068910696
return factorySpace(effects, after, 'whitespace')
1069010697
function after(code) {
10691-
const tail = self.events[self.events.length - 1];
10692-
return (
10693-
((tail && tail[1].type === 'whitespace') ||
10694-
markdownLineEnding(code)) &&
10695-
code !== null
10696-
? ok(code)
10697-
: nok(code)
10698-
)
10698+
return code === null ? nok(code) : ok(code)
1069910699
}
1070010700
}
1070110701

0 commit comments

Comments
 (0)