heading-case 1.1.7 → 2.0.0

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # heading-case
2
2
 
3
- Format page titles and section headings in markdown files to use [sentence-style capitalization](https://learn.microsoft.com/en-us/style-guide/text-formatting/using-type/use-sentence-style-capitalization).
3
+ Format page titles and section headings in Markdown and MDX files to use [sentence-style capitalization](https://learn.microsoft.com/en-us/style-guide/text-formatting/using-type/use-sentence-style-capitalization).
4
+
5
+ It can be used as a Prettier plugin or as a standalone CLI.
4
6
 
5
7
  <p>
6
8
  <a href="https://npmjs.com/package/heading-case">
@@ -24,12 +26,6 @@ Format page titles and section headings in markdown files to use [sentence-style
24
26
  # A new method for creating JavaScript rollovers
25
27
  ```
26
28
 
27
- ## Limitations
28
-
29
- This package is designed for Rspack's documentation. It follows the writing style of Rspack documentation and may not work well for other projects.
30
-
31
- There are some edge cases that can not be correctly handled, so the execution result is not completely reliable.
32
-
33
29
  ## Usage
34
30
 
35
31
  Install:
@@ -38,7 +34,48 @@ Install:
38
34
  npm add heading-case -D
39
35
  ```
40
36
 
41
- Check all markdown and MDX files in the current directory:
37
+ ### Rstack CLI
38
+
39
+ Add `heading-case` to the [`rs fmt` Prettier plugins](https://rstack.rs/guide/formatting#prettier-plugins):
40
+
41
+ ```ts
42
+ import { define } from 'rstack';
43
+
44
+ define.fmt({
45
+ plugins: ['heading-case'],
46
+ });
47
+ ```
48
+
49
+ Check or write formatted files:
50
+
51
+ ```bash
52
+ rs fmt --check
53
+ rs fmt
54
+ ```
55
+
56
+ ### Prettier
57
+
58
+ Add the plugin to your Prettier configuration:
59
+
60
+ ```js
61
+ /** @type {import('prettier').Config} */
62
+ const config = {
63
+ plugins: ['heading-case'],
64
+ };
65
+
66
+ export default config;
67
+ ```
68
+
69
+ Then run Prettier normally:
70
+
71
+ ```bash
72
+ prettier . --check
73
+ prettier . --write
74
+ ```
75
+
76
+ ### Standalone CLI
77
+
78
+ The existing CLI remains available. Check all Markdown and MDX files in the current directory:
42
79
 
43
80
  ```bash
44
81
  npx heading-case
@@ -52,6 +89,19 @@ Check and write the formatted content to the file:
52
89
  npx heading-case --write
53
90
  ```
54
91
 
92
+ The programmatic CLI and core formatting utilities are available from subpath exports:
93
+
94
+ ```js
95
+ import { headingCase } from 'heading-case/cli';
96
+ import { formatLine } from 'heading-case/core';
97
+ ```
98
+
99
+ ## Limitations
100
+
101
+ This package is designed for Rstack's documentation. It follows the writing style of Rstack documentation and may not work well for other projects.
102
+
103
+ There are some edge cases that can not be correctly handled, so the execution result is not completely reliable.
104
+
55
105
  ## License
56
106
 
57
107
  [MIT](./LICENSE).
package/bin.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { headingCase } from './dist/index.js';
2
+ import { headingCase } from './dist/cli.js';
3
3
 
4
- headingCase();
4
+ await headingCase();
package/dist/cli.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare function globMarkdownFiles(cwd: string): Promise<string[]>;
2
+ export declare function headingCase({ root, write, }?: {
3
+ root?: string;
4
+ write?: boolean;
5
+ }): Promise<void>;