How to use the markdownlint-rule-helpers.applyFixes function in markdownlint-rule-helpers

To help you get started, we’ve selected a few markdownlint-rule-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DavidAnson / vscode-markdownlint / extension.js View on Github external
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();
	});
}
github igorshubovych / markdownlint-cli / markdownlint.js View on Github external
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);
        }
      }
    });
  }

markdownlint-rule-helpers

A collection of markdownlint helper functions for custom rules

MIT
Latest version published 1 month ago

Package Health Score

88 / 100
Full package analysis