Skip to content

Commit 19085cb

Browse files
committed
docs: update
1 parent 72415db commit 19085cb

File tree

5 files changed

+111
-27
lines changed

5 files changed

+111
-27
lines changed

README.md

Lines changed: 91 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,108 @@
1-
# pkg-placeholder
1+
# markdown-it-todo-lists
22

33
[![npm version][npm-version-src]][npm-version-href]
44
[![npm downloads][npm-downloads-src]][npm-downloads-href]
55
[![bundle][bundle-src]][bundle-href]
66
[![JSDocs][jsdocs-src]][jsdocs-href]
77
[![License][license-src]][license-href]
88

9-
_description_
9+
A markdown-it plugin to create todo lists.
1010

11-
> **Note**:
12-
> Replace `pkg-placeholder`, `_description_` and `antfu` globally to use this template.
11+
- [ ] item 1
12+
- [x] item 2
13+
- [X] item 3
1314

14-
## Sponsors
15+
```markdown
16+
- [ ] item 1
17+
- [x] item 2
18+
- [X] item 3
19+
```
1520

16-
<p align="center">
17-
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
18-
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
19-
</a>
20-
</p>
21+
## Usage
22+
23+
```bash
24+
npm i markdown-it-todo-lists
25+
```
26+
27+
```js
28+
import MarkdownIt from 'markdown-it'
29+
import MarkdownItTodoLists from 'markdown-it-todo-lists'
30+
31+
const md = MarkdownIt()
32+
33+
md.use(MarkdownItTodoLists, /* Options */)
34+
35+
const html = md.render(/* ... */)
36+
```
37+
38+
For the options available, please refer to [the jsdoc](./src/index.ts).
39+
40+
## Functionality
41+
42+
```markdown
43+
- [ ] item 1
44+
- [x] item 2
45+
```
46+
47+
Use `enabled = true` in options:
48+
49+
```js
50+
md.use(MarkdownItTodoLists, {
51+
enabled: true
52+
})
53+
```
54+
55+
to HTML:
56+
57+
```html
58+
<ul class="todo-list-container">
59+
<li class="todo-list-item">
60+
<input class="todo-list-item-checkbox" type="checkbox" />item 1
61+
</li>
62+
<li class="todo-list-item">
63+
<input class="todo-list-item-checkbox" type="checkbox" checked />item 2
64+
</li>
65+
</ul>
66+
```
67+
68+
Use `useLabel = true` in options:
69+
70+
```js
71+
md.use(MarkdownItTodoLists, {
72+
useLabel: true
73+
})
74+
```
75+
76+
to HTML:
77+
78+
```html
79+
<ul class="todo-list-container">
80+
<li class="todo-list-item">
81+
<label>
82+
<input class="todo-list-item-checkbox" type="checkbox" disabled />item 1
83+
</label>
84+
</li>
85+
<li class="todo-list-item">
86+
<label>
87+
<input class="todo-list-item-checkbox" type="checkbox" checked disabled />item 2
88+
</label>
89+
</li>
90+
</ul>
91+
```
2192

2293
## License
2394

24-
[MIT](./LICENSE) License © 2024-PRESENT [Anthony Fu](https://github.com/antfu)
95+
[MIT](./LICENSE) License © 2024-PRESENT [Anthony Fu](https://github.com/skyline523)
2596

2697
<!-- Badges -->
2798

28-
[npm-version-src]: https://img.shields.io/npm/v/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669
29-
[npm-version-href]: https://npmjs.com/package/pkg-placeholder
30-
[npm-downloads-src]: https://img.shields.io/npm/dm/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669
31-
[npm-downloads-href]: https://npmjs.com/package/pkg-placeholder
32-
[bundle-src]: https://img.shields.io/bundlephobia/minzip/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669&label=minzip
33-
[bundle-href]: https://bundlephobia.com/result?p=pkg-placeholder
34-
[license-src]: https://img.shields.io/github/license/antfu/pkg-placeholder.svg?style=flat&colorA=080f12&colorB=1fa669
35-
[license-href]: https://github.com/antfu/pkg-placeholder/blob/main/LICENSE
99+
[npm-version-src]: https://img.shields.io/npm/v/markdown-it-todo-lists?style=flat&colorA=080f12&colorB=1fa669
100+
[npm-version-href]: https://npmjs.com/package/markdown-it-todo-lists
101+
[npm-downloads-src]: https://img.shields.io/npm/dm/markdown-it-todo-lists?style=flat&colorA=080f12&colorB=1fa669
102+
[npm-downloads-href]: https://npmjs.com/package/markdown-it-todo-lists
103+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/markdown-it-todo-lists?style=flat&colorA=080f12&colorB=1fa669&label=minzip
104+
[bundle-href]: https://bundlephobia.com/result?p=markdown-it-todo-lists
105+
[license-src]: https://img.shields.io/github/license/antfu/markdown-it-todo-lists.svg?style=flat&colorA=080f12&colorB=1fa669
106+
[license-href]: https://github.com/antfu/markdown-it-todo-lists/blob/main/LICENSE
36107
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
37-
[jsdocs-href]: https://www.jsdocs.io/package/pkg-placeholder
108+
[jsdocs-href]: https://www.jsdocs.io/package/markdown-it-todo-lists

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import type { PluginWithOptions } from 'markdown-it'
22
import type { Token } from 'markdown-it/index.js'
33

44
export interface MarkdownItTodoListOptions {
5+
/**
6+
* Checkbox selectable
7+
*/
58
enabled?: boolean
9+
/**
10+
* Use `label` label nesting
11+
*/
612
useLabel?: boolean
713
}
814

9-
const MarkdownItTodoList: PluginWithOptions<MarkdownItTodoListOptions> = (md, options = {}) => {
15+
const MarkdownItTodoLists: PluginWithOptions<MarkdownItTodoListOptions> = (md, options = {}) => {
1016
const {
1117
enabled = false,
1218
useLabel = false,
@@ -68,4 +74,4 @@ function setTokenAttrs(token: Token, name: string, value: string): void {
6874
}
6975
}
7076

71-
export default MarkdownItTodoList
77+
export default MarkdownItTodoLists

test/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import process from 'node:process'
22
import { describe, expect, it } from 'vitest'
33
import MarkdownIt from 'markdown-it'
4-
import MarkdownItTodoList from '../src'
4+
import MarkdownItTodoLists from '../src'
55

6-
describe('should', () => {
6+
describe('fixtures', () => {
77
const files = import.meta.glob('./input/*.md', { as: 'raw', eager: true })
88
const filter = process.env.FILTER
99
Object.entries(files)
@@ -19,7 +19,7 @@ describe('should', () => {
1919
xhtmlOut: true,
2020
})
2121

22-
md.use(MarkdownItTodoList, {
22+
md.use(MarkdownItTodoLists, {
2323
useLabel: true,
2424
})
2525

test/output/index.base.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<ul class="todo-list-container">
2-
<li class="todo-list-item"><label><input class="todo-list-item-checkbox" type="checkbox" checked disabled />item 1</label></li>
3-
<li class="todo-list-item"><label><input class="todo-list-item-checkbox" type="checkbox" checked disabled />item 2</label></li>
2+
<li class="todo-list-item"><label>
3+
<input class="todo-list-item-checkbox" type="checkbox" checked disabled />item 1
4+
</label>
5+
</li>
6+
<li class="todo-list-item"><label>
7+
<input class="todo-list-item-checkbox" type="checkbox" checked disabled />item 2
8+
</label>
9+
</li>
410
</ul>

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"module": "ESNext",
66
"moduleResolution": "Bundler",
77
"resolveJsonModule": true,
8+
"types": ["vite/client"],
89
"strict": true,
910
"strictNullChecks": true,
1011
"noEmit": true,

0 commit comments

Comments
 (0)