mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Convert markdownlint library to an ECMAScript module, replace markdownlint-micromark with micromark, stop publishing (large) markdownlint-browser.js, see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c for guidance.
This commit is contained in:
parent
191226f070
commit
1e71f6f44e
140 changed files with 1087 additions and 10428 deletions
36
example/standalone.mjs
Normal file
36
example/standalone.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// @ts-check
|
||||
|
||||
import markdownlint from "markdownlint";
|
||||
|
||||
const options = {
|
||||
"files": [ "good.md", "bad.md" ],
|
||||
"strings": {
|
||||
"good.string": "# good.string\n\nThis string passes all rules.\n",
|
||||
"bad.string": "#bad.string\n\n#This string fails\tsome rules.\n"
|
||||
}
|
||||
};
|
||||
|
||||
// Makes a synchronous call, using result.toString for pretty formatting
|
||||
const result = markdownlint.sync(options);
|
||||
console.log(result.toString());
|
||||
|
||||
// Makes an asynchronous call
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
// @ts-ignore
|
||||
console.log(result.toString());
|
||||
}
|
||||
});
|
||||
|
||||
// Displays the result object directly
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
console.dir(result, { "colors": true, "depth": null });
|
||||
}
|
||||
});
|
||||
|
||||
// Fixes all supported violations in Markdown content
|
||||
const original = "# Heading";
|
||||
const fixResults = markdownlint.sync({ "strings": { "content": original } });
|
||||
const fixed = markdownlint.applyFixes(original, fixResults.content);
|
||||
console.log(fixed);
|
||||
Loading…
Add table
Add a link
Reference in a new issue