Skip to content

Commit 8264348

Browse files
committed
build(packages/remark-capitalize-headings): add missing excludeHeadingText example to docs
1 parent d0d0286 commit 8264348

File tree

1 file changed

+83
-9
lines changed

1 file changed

+83
-9
lines changed

packages/remark-capitalize-headings/README.md

+83-9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ will not do.
5050
- [Examples](#examples)
5151
- [Using the Default Configuration](#using-the-default-configuration)
5252
- [Using `excludeHeadingLevel`](#using-excludeheadinglevel)
53+
- [Using `excludeHeadingText`](#using-excludeheadingtext)
5354
- [Using `excludeSectionRegExp`](#using-excludesectionregexp)
5455
- [Using `replaceHeadingRegExp`](#using-replaceheadingregexp)
5556
- [Related](#related)
@@ -236,7 +237,7 @@ Suppose we have the following Markdown file `example.md`:
236237

237238
#### Additional option: `options.opt3`
238239

239-
## Section 3 has the rest
240+
## Section 3 has the rest {#section-three}
240241

241242
### Subsection [a][1]
242243

@@ -307,8 +308,8 @@ Would output the following compared to `example.md`:
307308
-#### Additional option: `options.opt3`
308309
+#### Additional Option: `options.opt3`
309310

310-
-## Section 3 has the rest
311-
+## Section 3 Has the Rest
311+
-## Section 3 has the rest {#section-three}
312+
+## Section 3 Has the Rest {#section-Three}
312313

313314
### Subsection [a][1]
314315

@@ -380,8 +381,81 @@ Would output the following compared to `example.md`:
380381

381382
#### Additional option: `options.opt3`
382383

383-
-## Section 3 has the rest
384-
+## Section 3 Has the Rest
384+
-## Section 3 has the rest {#section-three}
385+
+## Section 3 Has the Rest {#section-Three}
386+
387+
### Subsection [a][1]
388+
389+
#### Sci-fi title generator
390+
391+
-##### children of celeste
392+
+##### Children of Celeste
393+
394+
-##### the bionic oblivion
395+
+##### The Bionic Oblivion
396+
397+
-##### snows Of arrakis
398+
+##### Snows of Arrakis
399+
400+
[1]: https://www.youtube.com/watch?v=dFs4yX4V7NQ
401+
```
402+
403+
### Using `excludeHeadingText`
404+
405+
Running the following JavaScript:
406+
407+
```typescript
408+
import { read } from 'to-vfile';
409+
import { remark } from 'remark';
410+
import remarkCapitalizeHeadings from 'remark-capitalize-headings';
411+
412+
const file = await remark()
413+
.use(remarkCapitalizeHeadings, {
414+
// Don't mess with {#custom-headers} from remark-heading-id
415+
// See: https://github.com/Xunnamius/unified-utils/issues/95
416+
excludeHeadingText: ['\\{\\s*#.*?\\}\\s*$']
417+
})
418+
.process(await read('example.md'));
419+
420+
console.log(String(file));
421+
```
422+
423+
Would output the following compared to `example.md`:
424+
425+
```diff
426+
-# my documentation
427+
+# My Documentation
428+
429+
-## Section 1 is [the best](https://google.com)
430+
+## Section 1 Is [the best](https://google.com)
431+
432+
### Subsection a
433+
434+
### Subsection _a_
435+
436+
### Subsection \_a
437+
438+
### Subsection a: be see
439+
440+
### Subsection b
441+
442+
### Subsection C
443+
444+
-## section 2 is the test
445+
+## Section 2 Is the Test
446+
447+
### subsection 1
448+
449+
### Subsection 2
450+
451+
#### `options.opt1`
452+
453+
#### `options.opt2`
454+
455+
#### Additional option: `options.opt3`
456+
457+
-## Section 3 has the rest {#section-three}
458+
+## Section 3 Has the Rest {#section-three}
385459

386460
### Subsection [a][1]
387461

@@ -453,8 +527,8 @@ Would output the following compared to `example.md`:
453527

454528
#### Additional option: `options.opt3`
455529

456-
-## Section 3 has the rest
457-
+## Section 3 Has the Rest
530+
-## Section 3 has the rest {#section-three}
531+
+## Section 3 Has the Rest {#section-Three}
458532

459533
### Subsection [a][1]
460534

@@ -532,8 +606,8 @@ Would output the following compared to `example.md`:
532606
-#### Additional option: `options.opt3`
533607
+#### Additional Option: `options.opt3`
534608

535-
-## Section 3 has the rest
536-
+## Section 3 Has The Rest
609+
-## Section 3 has the rest {#section-three}
610+
+## Section 3 Has The Rest {#section-Three}
537611

538612
### Subsection [a][1]
539613

0 commit comments

Comments
 (0)