Add types, docs for options
This commit is contained in:
parent
7ca8974f14
commit
b685b00060
6 changed files with 74 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@
|
||||||
coverage/
|
coverage/
|
||||||
node_modules/
|
node_modules/
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
!/index.d.ts
|
||||||
|
|
15
index.d.ts
vendored
Normal file
15
index.d.ts
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import type {ToMarkdownOptions} from 'mdast-util-directive'
|
||||||
|
|
||||||
|
export {default} from './lib/index.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for `remark-directive`.
|
||||||
|
*
|
||||||
|
* Currently supports
|
||||||
|
* `collapseEmptyAttributes`,
|
||||||
|
* `preferShortcut`,
|
||||||
|
* `preferUnquoted`,
|
||||||
|
* `quoteSmart`,
|
||||||
|
* and `quote` as serialization options.
|
||||||
|
*/
|
||||||
|
export interface Options extends ToMarkdownOptions {}
|
1
index.js
1
index.js
|
@ -1 +1,2 @@
|
||||||
|
// Note: types exposed from `index.d.ts`.
|
||||||
export {default} from './lib/index.js'
|
export {default} from './lib/index.js'
|
||||||
|
|
23
package.json
23
package.json
|
@ -78,6 +78,29 @@
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"xo": {
|
"xo": {
|
||||||
"overrides": [
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"**/*.d.ts"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/array-type": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"default": "generic"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/ban-types": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"extendDefaults": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@typescript-eslint/consistent-type-definitions": [
|
||||||
|
"error",
|
||||||
|
"interface"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"files": [
|
"files": [
|
||||||
"test/**/*.js"
|
"test/**/*.js"
|
||||||
|
|
37
readme.md
37
readme.md
|
@ -19,7 +19,8 @@ proposal][commonmark-prop] (`:cite[smith04]`,
|
||||||
* [Install](#install)
|
* [Install](#install)
|
||||||
* [Use](#use)
|
* [Use](#use)
|
||||||
* [API](#api)
|
* [API](#api)
|
||||||
* [`unified().use(remarkDirective)`](#unifieduseremarkdirective)
|
* [`unified().use(remarkDirective[, options])`](#unifieduseremarkdirective-options)
|
||||||
|
* [`Options`](#options)
|
||||||
* [Examples](#examples)
|
* [Examples](#examples)
|
||||||
* [Example: YouTube](#example-youtube)
|
* [Example: YouTube](#example-youtube)
|
||||||
* [Example: Styled blocks](#example-styled-blocks)
|
* [Example: Styled blocks](#example-styled-blocks)
|
||||||
|
@ -174,13 +175,14 @@ function myRemarkPlugin() {
|
||||||
This package exports no identifiers.
|
This package exports no identifiers.
|
||||||
The default export is [`remarkDirective`][api-remark-directive].
|
The default export is [`remarkDirective`][api-remark-directive].
|
||||||
|
|
||||||
### `unified().use(remarkDirective)`
|
### `unified().use(remarkDirective[, options])`
|
||||||
|
|
||||||
Add support for generic directives.
|
Add support for generic directives.
|
||||||
|
|
||||||
###### Parameters
|
###### Parameters
|
||||||
|
|
||||||
There are no parameters.
|
* `options` ([`Options`][api-options], optional)
|
||||||
|
— configuration
|
||||||
|
|
||||||
###### Returns
|
###### Returns
|
||||||
|
|
||||||
|
@ -191,6 +193,29 @@ Nothing (`undefined`).
|
||||||
Doesn’t handle the directives:
|
Doesn’t handle the directives:
|
||||||
[create your own plugin][unified-create-plugin] to do that.
|
[create your own plugin][unified-create-plugin] to do that.
|
||||||
|
|
||||||
|
### `Options`
|
||||||
|
|
||||||
|
Configuration (TypeScript type).
|
||||||
|
|
||||||
|
###### Fields
|
||||||
|
|
||||||
|
* `collapseEmptyAttributes`
|
||||||
|
(`boolean`, default: `true`)
|
||||||
|
— collapse empty attributes: get `title` instead of `title=""`
|
||||||
|
* `preferShortcut`
|
||||||
|
(`boolean`, default: `true`)
|
||||||
|
— prefer `#` and `.` shortcuts for `id` and `class`
|
||||||
|
* `preferUnquoted`
|
||||||
|
(`boolean`, default: `false`)
|
||||||
|
— leave attributes unquoted if that results in less bytes
|
||||||
|
* `quoteSmart`
|
||||||
|
(`boolean`, default: `false`)
|
||||||
|
— use the other quote if that results in less bytes
|
||||||
|
* `quote`
|
||||||
|
(`'"'` or `"'"`,
|
||||||
|
default: the [`quote`][quote] used by `remark-stringify` for titles)
|
||||||
|
— preferred quote to use around attribute values
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Example: YouTube
|
### Example: YouTube
|
||||||
|
@ -500,6 +525,8 @@ abide by its terms.
|
||||||
|
|
||||||
[micromark-extending-markdown]: https://github.com/micromark/micromark#extending-markdown
|
[micromark-extending-markdown]: https://github.com/micromark/micromark#extending-markdown
|
||||||
|
|
||||||
|
[quote]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options
|
||||||
|
|
||||||
[rehype]: https://github.com/rehypejs/rehype
|
[rehype]: https://github.com/rehypejs/rehype
|
||||||
|
|
||||||
[remark]: https://github.com/remarkjs/remark
|
[remark]: https://github.com/remarkjs/remark
|
||||||
|
@ -512,4 +539,6 @@ abide by its terms.
|
||||||
|
|
||||||
[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
||||||
|
|
||||||
[api-remark-directive]: #unifieduseremarkdirective
|
[api-remark-directive]: #unifieduseremarkdirective-options
|
||||||
|
|
||||||
|
[api-options]: #options
|
||||||
|
|
|
@ -12,5 +12,5 @@
|
||||||
"target": "es2022"
|
"target": "es2022"
|
||||||
},
|
},
|
||||||
"exclude": ["coverage/", "node_modules/"],
|
"exclude": ["coverage/", "node_modules/"],
|
||||||
"include": ["**/*.js"]
|
"include": ["**/*.js", "index.d.ts"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue