Skip to content

Commit

Permalink
build(packages/remark-capitalize-headings): add missing `excludeHeadi…
Browse files Browse the repository at this point in the history
…ngText` example to docs
  • Loading branch information
Xunnamius committed Nov 30, 2023
1 parent d0d0286 commit 8264348
Showing 1 changed file with 83 additions and 9 deletions.
92 changes: 83 additions & 9 deletions packages/remark-capitalize-headings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ will not do.
- [Examples](#examples)
- [Using the Default Configuration](#using-the-default-configuration)
- [Using `excludeHeadingLevel`](#using-excludeheadinglevel)
- [Using `excludeHeadingText`](#using-excludeheadingtext)
- [Using `excludeSectionRegExp`](#using-excludesectionregexp)
- [Using `replaceHeadingRegExp`](#using-replaceheadingregexp)
- [Related](#related)
Expand Down Expand Up @@ -236,7 +237,7 @@ Suppose we have the following Markdown file `example.md`:

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

## Section 3 has the rest
## Section 3 has the rest {#section-three}

### Subsection [a][1]

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

-## Section 3 has the rest
+## Section 3 Has the Rest
-## Section 3 has the rest {#section-three}
+## Section 3 Has the Rest {#section-Three}

### Subsection [a][1]

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

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

-## Section 3 has the rest
+## Section 3 Has the Rest
-## Section 3 has the rest {#section-three}
+## Section 3 Has the Rest {#section-Three}

### Subsection [a][1]

#### Sci-fi title generator

-##### children of celeste
+##### Children of Celeste

-##### the bionic oblivion
+##### The Bionic Oblivion

-##### snows Of arrakis
+##### Snows of Arrakis

[1]: https://www.youtube.com/watch?v=dFs4yX4V7NQ
```

### Using `excludeHeadingText`

Running the following JavaScript:

```typescript
import { read } from 'to-vfile';
import { remark } from 'remark';
import remarkCapitalizeHeadings from 'remark-capitalize-headings';

const file = await remark()
.use(remarkCapitalizeHeadings, {
// Don't mess with {#custom-headers} from remark-heading-id
// See: https://github.com/Xunnamius/unified-utils/issues/95
excludeHeadingText: ['\\{\\s*#.*?\\}\\s*$']
})
.process(await read('example.md'));

console.log(String(file));
```

Would output the following compared to `example.md`:

```diff
-# my documentation
+# My Documentation

-## Section 1 is [the best](https://google.com)
+## Section 1 Is [the best](https://google.com)

### Subsection a

### Subsection _a_

### Subsection \_a

### Subsection a: be see

### Subsection b

### Subsection C

-## section 2 is the test
+## Section 2 Is the Test

### subsection 1

### Subsection 2

#### `options.opt1`

#### `options.opt2`

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

-## Section 3 has the rest {#section-three}
+## Section 3 Has the Rest {#section-three}

### Subsection [a][1]

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

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

-## Section 3 has the rest
+## Section 3 Has the Rest
-## Section 3 has the rest {#section-three}
+## Section 3 Has the Rest {#section-Three}

### Subsection [a][1]

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

-## Section 3 has the rest
+## Section 3 Has The Rest
-## Section 3 has the rest {#section-three}
+## Section 3 Has The Rest {#section-Three}

### Subsection [a][1]

Expand Down

0 comments on commit 8264348

Please sign in to comment.