Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8be03a

Browse files
committed
Update markdownlint-github for new breaking change
1 parent 6f02a09 commit f8be03a

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

.markdownlint-cli2.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import markdownIt from "markdown-it";
12
import { init } from "./index.js";
23

4+
const markdownItFactory = () => markdownIt({ html: true });
5+
36
const configOptions = await init({
47
default: false,
58
"heading-increment": true,
@@ -11,5 +14,6 @@ const configOptions = await init({
1114
const options = {
1215
config: configOptions,
1316
customRules: ["./index.js"],
17+
markdownItFactory,
1418
};
1519
export default options;

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali
4747
4. Edit `.markdownlint-cli2.mjs` file to suit your needs. Start with
4848

4949
```js
50+
import markdownIt from "markdown-it"
5051
import configOptions, {init} from "@github/markdownlint-github"
52+
const markdownItFactory = () => markdownIt({ html: true })
5153
const options = {
5254
config: init(),
5355
customRules: ["@github/markdownlint-github"],
56+
markdownItFactory,
5457
outputFormatters: [
5558
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] // ensures the error message includes a link to the rule documentation
5659
]
@@ -62,13 +65,16 @@ See [`markdownlint` rules](https://github.com/DavidAnson/markdownlint#rules--ali
6265
This looks like:
6366
6467
```js
68+
import markdownIt from "markdown-it"
6569
import configOptions, {init} from "@github/markdownlint-github"
6670
const overriddenOptions = init({
6771
'fenced-code-language': false, // Custom overrides
6872
})
73+
const markdownItFactory = () => markdownIt({ html: true })
6974
const options = {
7075
config: overriddenOptions,
7176
customRules: ["@github/markdownlint-github"],
77+
markdownItFactory,
7278
outputFormatters: [
7379
[ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ]
7480
]
@@ -96,9 +102,12 @@ The rule will need to be enabled in the configuration. For instance, if you intr
96102
97103
```js
98104
import configOptions, {init} from "@github/markdownlint-github"
105+
import markdownIt from "markdown-it"
106+
const markdownItFactory = () => markdownIt({ html: true })
99107
const options = init({
100108
"some-rule": true,
101109
customRules: ["@github/markdownlint-github", "some-rule.js"],
110+
markdownItFactory
102111
})
103112
export default options
104113
```

test/accessibility-rules.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { lint } from "markdownlint/async";
2+
import markdownIt from "markdown-it";
23
import githubMarkdownLint from "../index.js";
34
import accessibilityRules from "../style/accessibility.js";
45

56
const exampleFileName = "./test/example.md";
7+
const markdownItFactory = () => markdownIt({ html: true });
68

79
describe("when A11y rules applied", () => {
810
test("fails expected rules", async () => {
@@ -13,6 +15,7 @@ describe("when A11y rules applied", () => {
1315
},
1416
files: [exampleFileName],
1517
customRules: githubMarkdownLint,
18+
markdownItFactory,
1619
};
1720

1821
const result = await new Promise((resolve, reject) => {

test/utils/run-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { lint } from "markdownlint/async";
2+
import markdownIt from "markdown-it";
3+
4+
const markdownItFactory = () => markdownIt({ html: true });
25

36
export async function runTest(strings, rule, ruleConfig) {
47
const thisRuleName = rule.names[1];
@@ -9,6 +12,7 @@ export async function runTest(strings, rule, ruleConfig) {
912
[thisRuleName]: ruleConfig || true,
1013
},
1114
customRules: [rule],
15+
markdownItFactory,
1216
};
1317

1418
const results = await Promise.all(

0 commit comments

Comments
 (0)