remark-comment-config
Advanced tools
Comparing version 7.0.1 to 8.0.0
@@ -1,11 +0,1 @@ | ||
/** | ||
* Plugin to configure remark with comments. | ||
* | ||
* @type {import('unified').Plugin<void[], Root>} | ||
*/ | ||
export default function remarkCommentConfig(): | ||
| void | ||
| import('unified').Transformer<import('mdast').Root, import('mdast').Root> | ||
export type Root = import('mdast').Root | ||
export type HTML = import('mdast').HTML | ||
export type Extension = import('mdast-util-to-markdown').Options | ||
export { default } from "./lib/index.js"; |
44
index.js
@@ -1,43 +0,1 @@ | ||
/** | ||
* @typedef {import('mdast').Root} Root | ||
* @typedef {import('mdast').HTML} HTML | ||
* @typedef {import('mdast-util-to-markdown').Options} Extension | ||
*/ | ||
import {commentMarker} from 'mdast-comment-marker' | ||
/** | ||
* Plugin to configure remark with comments. | ||
* | ||
* @type {import('unified').Plugin<void[], Root>} | ||
*/ | ||
export default function remarkCommentConfig() { | ||
const data = this.data() | ||
/** @type {Extension} */ | ||
const commentConfig = { | ||
handlers: { | ||
/** @param {HTML} node */ | ||
html(node) { | ||
const marker = commentMarker(node) | ||
if (marker && marker.name === 'remark') { | ||
Object.assign(this.options, marker.parameters) | ||
} | ||
// Like the source: | ||
// <https://github.com/syntax-tree/mdast-util-to-markdown/blob/e40e015/lib/handle/html.js#L4> | ||
return node.value || '' | ||
} | ||
} | ||
} | ||
const extensions = /** @type {Extension[]} */ ( | ||
// Other extensions | ||
/* c8 ignore next 2 */ | ||
data.toMarkdownExtensions | ||
? data.toMarkdownExtensions | ||
: (data.toMarkdownExtensions = []) | ||
) | ||
extensions.push(commentConfig) | ||
} | ||
export {default} from './lib/index.js' |
{ | ||
"name": "remark-comment-config", | ||
"version": "7.0.1", | ||
"version": "8.0.0", | ||
"description": "remark plugin to configure it with comments", | ||
"license": "MIT", | ||
"keywords": [ | ||
"unified", | ||
"comment", | ||
"config", | ||
"markdown", | ||
"mdast", | ||
"options", | ||
"plugin", | ||
"remark", | ||
"remark-plugin", | ||
"plugin", | ||
"mdast", | ||
"markdown", | ||
"comment", | ||
"options", | ||
"config", | ||
"settings" | ||
"settings", | ||
"unified" | ||
], | ||
@@ -30,5 +30,5 @@ "repository": "remarkjs/remark-comment-config", | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"exports": "./index.js", | ||
"files": [ | ||
"lib/", | ||
"index.d.ts", | ||
@@ -38,44 +38,39 @@ "index.js" | ||
"dependencies": { | ||
"@types/mdast": "^3.0.0", | ||
"mdast-comment-marker": "^2.0.0", | ||
"mdast-util-to-markdown": "^1.0.0", | ||
"unified": "^10.0.0" | ||
"@types/mdast": "^4.0.0", | ||
"mdast-comment-marker": "^3.0.0", | ||
"unified": "^11.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"c8": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"rehype-stringify": "^9.0.0", | ||
"remark-cli": "^10.0.0", | ||
"remark-parse": "^10.0.0", | ||
"@types/node": "^20.0.0", | ||
"c8": "^8.0.0", | ||
"prettier": "^3.0.0", | ||
"rehype-stringify": "^10.0.0", | ||
"remark-cli": "^11.0.0", | ||
"remark-parse": "^11.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"remark-rehype": "^10.0.0", | ||
"remark-stringify": "^10.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"remark-rehype": "^11.0.0", | ||
"remark-stringify": "^11.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.46.0" | ||
"typescript": "^5.0.0", | ||
"xo": "^0.56.0" | ||
}, | ||
"scripts": { | ||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix", | ||
"prepack": "npm run build && npm run format", | ||
"test": "npm run build && npm run format && npm run test-coverage", | ||
"test-api": "node --conditions development test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
"test-coverage": "c8 --100 --reporter lcov npm run test-api" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"useTabs": false | ||
}, | ||
"xo": { | ||
"prettier": true | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
"remark-preset-wooorm" | ||
] | ||
@@ -86,5 +81,8 @@ }, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true | ||
"ignoreCatch": true, | ||
"strict": true | ||
}, | ||
"xo": { | ||
"prettier": true | ||
} | ||
} |
106
readme.md
@@ -33,8 +33,2 @@ # remark-comment-config | ||
**unified** is a project that transforms content with abstract syntax trees | ||
(ASTs). | ||
**remark** adds support for markdown to unified. | ||
**mdast** is the markdown AST that remark uses. | ||
This is a remark plugin that configures how `remark-stringify` serializes mdast. | ||
## When should I use this? | ||
@@ -54,4 +48,4 @@ | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). | ||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: | ||
This package is [ESM only][esm]. | ||
In Node.js (version 16+), install with [npm][]: | ||
@@ -62,13 +56,13 @@ ```sh | ||
In Deno with [Skypack][]: | ||
In Deno with [`esm.sh`][esmsh]: | ||
```js | ||
import remarkCommentConfig from 'https://cdn.skypack.dev/remark-comment-config@7?dts' | ||
import remarkCommentConfig from 'https://esm.sh/remark-comment-config@8' | ||
``` | ||
In browsers with [Skypack][]: | ||
In browsers with [`esm.sh`][esmsh]: | ||
```html | ||
<script type="module"> | ||
import remarkCommentConfig from 'https://cdn.skypack.dev/remark-comment-config@7?min' | ||
import remarkCommentConfig from 'https://esm.sh/remark-comment-config@8?bundle' | ||
</script> | ||
@@ -82,47 +76,47 @@ ``` | ||
```markdown | ||
# Moons of Neptune | ||
<!--remark bullet="+"--> | ||
- a | ||
- Naiad | ||
<!--remark bullet="-"--> | ||
- b | ||
- Thalassa | ||
<!--remark bullet="*"--> | ||
- c | ||
- Despina | ||
``` | ||
And our module `example.js` looks as follows: | ||
…and a module `example.js`: | ||
```js | ||
import {read} from 'to-vfile' | ||
import {remark} from 'remark' | ||
import remarkCommentConfig from 'remark-comment-config' | ||
import {read} from 'to-vfile' | ||
main() | ||
const file = await remark() | ||
.use(remarkCommentConfig) | ||
.process(await read('example.md')) | ||
async function main() { | ||
const file = await remark() | ||
.use(remarkCommentConfig) | ||
.process(await read('example.md')) | ||
console.log(String(file)) | ||
} | ||
console.log(String(file)) | ||
``` | ||
Now running `node example.js` yields: | ||
…then running `node example.js` yields: | ||
```markdown | ||
# Moons of Neptune | ||
<!--remark bullet="+"--> | ||
+ a | ||
+ Naiad | ||
<!--remark bullet="-"--> | ||
- b | ||
- Thalassa | ||
<!--remark bullet="*"--> | ||
* c | ||
* Despina | ||
``` | ||
@@ -133,3 +127,3 @@ | ||
This package exports no identifiers. | ||
The default export is `remarkCommentConfig`. | ||
The default export is [`remarkCommentConfig`][api-remark-comment-config]. | ||
@@ -139,20 +133,30 @@ ### `unified().use(remarkCommentConfig)` | ||
Configure remark with comments. | ||
There are no options. | ||
Comments should start with `remark` and contain “attributes” for settings. | ||
For example, `<!--remark foo="bar" baz-->`. | ||
The settings are passed to [`remark-stringify`][stringify-settings]. | ||
The settings are passed to [`remark-stringify`][remark-stringify-options]. | ||
###### Parameters | ||
There are no parameters. | ||
###### Returns | ||
Nothing (`undefined`). | ||
## Types | ||
This package is fully typed with [TypeScript][]. | ||
There are no extra exported types. | ||
It exports no additional types. | ||
## Compatibility | ||
Projects maintained by the unified collective are compatible with all maintained | ||
Projects maintained by the unified collective are compatible with maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, `remark-comment-config@^8`, | ||
compatible with Node.js 16. | ||
This plugin works with `remark` version 13+. | ||
@@ -165,3 +169,3 @@ Version 5 (and lower) worked with older versions of remark. | ||
If the markdown is user provided, this may open you up to a | ||
[cross-site scripting (XSS)][xss] attack. | ||
[cross-site scripting (XSS)][wiki-xss] attack. | ||
@@ -203,5 +207,5 @@ ## Related | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-comment-config.svg | ||
[size-badge]: https://img.shields.io/bundlejs/size/remark-comment-config | ||
[size]: https://bundlephobia.com/result?p=remark-comment-config | ||
[size]: https://bundlejs.com/?q=remark-comment-config | ||
@@ -220,11 +224,13 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[skypack]: https://www.skypack.dev | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[esmsh]: https://esm.sh | ||
[health]: https://github.com/remarkjs/.github | ||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md | ||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md | ||
[support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md | ||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
@@ -237,12 +243,14 @@ [license]: license | ||
[unified]: https://github.com/unifiedjs/unified | ||
[remark-message-control]: https://github.com/remarkjs/remark-message-control | ||
[remark-stringify-options]: https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/readme.md#options | ||
[remark-yaml-config]: https://github.com/remarkjs/remark-yaml-config | ||
[typescript]: https://www.typescriptlang.org | ||
[stringify-settings]: https://github.com/remarkjs/remark/blob/HEAD/packages/remark-stringify/readme.md#options | ||
[unified]: https://github.com/unifiedjs/unified | ||
[remark-yaml-config]: https://github.com/remarkjs/remark-yaml-config | ||
[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting | ||
[remark-message-control]: https://github.com/remarkjs/remark-message-control | ||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting | ||
[api-remark-comment-config]: #unifieduseremarkcommentconfig |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11279
3
12
7
55
247
+ Added@types/hast@3.0.4(transitive)
+ Added@types/mdast@4.0.4(transitive)
+ Added@types/unist@3.0.3(transitive)
+ Addeddevlop@1.1.0(transitive)
+ Addedmdast-comment-marker@3.0.0(transitive)
+ Addedmdast-util-from-markdown@2.0.2(transitive)
+ Addedmdast-util-mdx-expression@2.0.1(transitive)
+ Addedmdast-util-phrasing@4.1.0(transitive)
+ Addedmdast-util-to-markdown@2.1.2(transitive)
+ Addedmdast-util-to-string@4.0.0(transitive)
+ Addedmicromark@4.0.1(transitive)
+ Addedmicromark-core-commonmark@2.0.2(transitive)
+ Addedmicromark-factory-destination@2.0.1(transitive)
+ Addedmicromark-factory-label@2.0.1(transitive)
+ Addedmicromark-factory-space@2.0.1(transitive)
+ Addedmicromark-factory-title@2.0.1(transitive)
+ Addedmicromark-factory-whitespace@2.0.1(transitive)
+ Addedmicromark-util-character@2.1.1(transitive)
+ Addedmicromark-util-chunked@2.0.1(transitive)
+ Addedmicromark-util-classify-character@2.0.1(transitive)
+ Addedmicromark-util-combine-extensions@2.0.1(transitive)
+ Addedmicromark-util-decode-numeric-character-reference@2.0.2(transitive)
+ Addedmicromark-util-decode-string@2.0.1(transitive)
+ Addedmicromark-util-encode@2.0.1(transitive)
+ Addedmicromark-util-html-tag-name@2.0.1(transitive)
+ Addedmicromark-util-normalize-identifier@2.0.1(transitive)
+ Addedmicromark-util-resolve-all@2.0.1(transitive)
+ Addedmicromark-util-sanitize-uri@2.0.1(transitive)
+ Addedmicromark-util-subtokenize@2.0.2(transitive)
+ Addedmicromark-util-symbol@2.0.1(transitive)
+ Addedmicromark-util-types@2.0.1(transitive)
+ Addedunified@11.0.5(transitive)
+ Addedunist-util-is@6.0.0(transitive)
+ Addedunist-util-stringify-position@4.0.0(transitive)
+ Addedunist-util-visit@5.0.0(transitive)
+ Addedunist-util-visit-parents@6.0.1(transitive)
+ Addedvfile@6.0.3(transitive)
+ Addedvfile-message@4.0.2(transitive)
- Removedmdast-util-to-markdown@^1.0.0
- Removed@types/hast@2.3.10(transitive)
- Removed@types/mdast@3.0.15(transitive)
- Removed@types/unist@2.0.11(transitive)
- Removeddiff@5.2.0(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedkleur@4.1.5(transitive)
- Removedmdast-comment-marker@2.1.2(transitive)
- Removedmdast-util-from-markdown@1.3.1(transitive)
- Removedmdast-util-mdx-expression@1.3.2(transitive)
- Removedmdast-util-phrasing@3.0.1(transitive)
- Removedmdast-util-to-markdown@1.5.0(transitive)
- Removedmdast-util-to-string@3.2.0(transitive)
- Removedmicromark@3.2.0(transitive)
- Removedmicromark-core-commonmark@1.1.0(transitive)
- Removedmicromark-factory-destination@1.1.0(transitive)
- Removedmicromark-factory-label@1.1.0(transitive)
- Removedmicromark-factory-space@1.1.0(transitive)
- Removedmicromark-factory-title@1.1.0(transitive)
- Removedmicromark-factory-whitespace@1.1.0(transitive)
- Removedmicromark-util-character@1.2.0(transitive)
- Removedmicromark-util-chunked@1.1.0(transitive)
- Removedmicromark-util-classify-character@1.1.0(transitive)
- Removedmicromark-util-combine-extensions@1.1.0(transitive)
- Removedmicromark-util-decode-numeric-character-reference@1.1.0(transitive)
- Removedmicromark-util-decode-string@1.1.0(transitive)
- Removedmicromark-util-encode@1.1.0(transitive)
- Removedmicromark-util-html-tag-name@1.2.0(transitive)
- Removedmicromark-util-normalize-identifier@1.1.0(transitive)
- Removedmicromark-util-resolve-all@1.1.0(transitive)
- Removedmicromark-util-sanitize-uri@1.2.0(transitive)
- Removedmicromark-util-subtokenize@1.1.0(transitive)
- Removedmicromark-util-symbol@1.1.0(transitive)
- Removedmicromark-util-types@1.1.0(transitive)
- Removedmri@1.2.0(transitive)
- Removedsade@1.8.1(transitive)
- Removedunified@10.1.2(transitive)
- Removedunist-util-is@5.2.1(transitive)
- Removedunist-util-stringify-position@3.0.3(transitive)
- Removedunist-util-visit@4.1.2(transitive)
- Removedunist-util-visit-parents@5.1.3(transitive)
- Removeduvu@0.5.6(transitive)
- Removedvfile@5.3.7(transitive)
- Removedvfile-message@3.1.4(transitive)
Updated@types/mdast@^4.0.0
Updatedmdast-comment-marker@^3.0.0
Updatedunified@^11.0.0