Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"function": (params, onError) => {
filterTokens(params, "blockquote_open", (blockquote) => {
const lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7)
});
});
}
};
"function": (params, onError) => {
const n = params.config.n || 2;
forEachLine(getLineMetadata(params), (line, lineIndex) => {
const lineNumber = lineIndex + 1;
if ((lineNumber % n) === 0) {
onError({
"lineNumber": lineNumber,
"detail": "Line number " + lineNumber
});
}
});
}
};
return new Promise((resolve, reject) => {
const editor = vscode.window.activeTextEditor;
if (editor) {
const document = editor.document;
if (isMarkdownDocument(document)) {
const name = document.uri.toString();
const text = document.getText();
const {config} = getConfig(document);
const errors = markdownlintWrapper(name, text, config);
const fixedText = markdownlintRuleHelpers.applyFixes(text, errors);
if (text !== fixedText) {
return editor.edit((editBuilder) => {
const start = document.lineAt(0).range.start;
const end = document.lineAt(document.lineCount - 1).range.end;
editBuilder.replace(new vscode.Range(start, end), fixedText);
}).then(resolve, reject);
}
}
}
return resolve();
});
}
return new Promise((resolve, reject) => {
const editor = vscode.window.activeTextEditor;
if (editor && fixInfo) {
const document = editor.document;
const lineNumber = fixInfo.lineNumber || (lineIndex + 1);
const {text, range} = document.lineAt(lineNumber - 1);
const fixedText = markdownlintRuleHelpers.applyFix(text, fixInfo, "\n");
return editor.edit((editBuilder) => {
if (typeof fixedText === "string") {
editBuilder.replace(range, fixedText);
} else {
let deleteRange = range;
if (lineNumber === 1) {
if (document.lineCount > 1) {
const nextLine = document.lineAt(range.end.line + 1);
deleteRange = range.with({"end": nextLine.range.start});
}
} else {
const previousLine = document.lineAt(range.start.line - 1);
deleteRange = range.with({"start": previousLine.range.end});
}
editBuilder.delete(deleteRange);
}
files.forEach(file => {
fixOptions.files = [file];
const fixResult = markdownlint.sync(fixOptions);
const fixes = fixResult[file].filter(error => error.fixInfo);
if (fixes.length > 0) {
const originalText = fs.readFileSync(file, fsOptions);
const fixedText = markdownlintRuleHelpers.applyFixes(originalText, fixes);
if (originalText !== fixedText) {
fs.writeFileSync(file, fixedText, fsOptions);
}
}
});
}