@contextlint/core 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @contextlint/core
|
|
2
|
+
|
|
3
|
+
Rule engine and Markdown parser for
|
|
4
|
+
[contextlint](https://github.com/nozomi-koborinai/contextlint) —
|
|
5
|
+
a rule-based linter for structured Markdown documents.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @contextlint/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> Most users should install
|
|
14
|
+
> [`@contextlint/cli`](https://www.npmjs.com/package/@contextlint/cli)
|
|
15
|
+
> instead. This package is for programmatic usage.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { parseDocument, runRules, tbl001 } from "@contextlint/core";
|
|
21
|
+
|
|
22
|
+
const doc = parseDocument(
|
|
23
|
+
"| ID | Status |\n|----|--------|\n| 1 | Done |",
|
|
24
|
+
);
|
|
25
|
+
const rule = tbl001({
|
|
26
|
+
requiredColumns: ["ID", "Status", "Description"],
|
|
27
|
+
});
|
|
28
|
+
const messages = runRules([rule], doc, "example.md");
|
|
29
|
+
|
|
30
|
+
console.log(messages);
|
|
31
|
+
// [{ ruleId: "TBL-001", severity: "error",
|
|
32
|
+
// message: "Missing required column ...", line: 1 }]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
See the
|
|
36
|
+
[main repository](https://github.com/nozomi-koborinai/contextlint)
|
|
37
|
+
for the full list of rules and configuration options.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
[MIT](https://github.com/nozomi-koborinai/contextlint/blob/main/LICENSE)
|