Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-yaml-config

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-yaml-config - npm Package Compare versions

Comparing version 6.0.1 to 7.0.0

lib/index.d.ts

12

index.d.ts

@@ -1,11 +0,1 @@

/**
* Plugin to configure it with YAML frontmatter.
*
* @type {import('unified').Plugin<void[], Root>}
*/
export default function remarkYamlConfig():
| void
| import('unified').Transformer<import('mdast').Root, import('mdast').Root>
export type Root = import('mdast').Root
export type YAML = import('mdast').YAML
export type Extension = import('mdast-util-to-markdown').Options
export { default } from "./lib/index.js";

@@ -1,45 +0,1 @@

/**
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast').YAML} YAML
* @typedef {import('mdast-util-to-markdown').Options} Extension
*/
import jsYaml from 'js-yaml'
/**
* Plugin to configure it with YAML frontmatter.
*
* @type {import('unified').Plugin<void[], Root>}
*/
export default function remarkYamlConfig() {
const data = this.data()
/** @type {Extension} */
const yamlConfig = {
handlers: {
/** @param {YAML} node */
yaml(node) {
const data = jsYaml.load(node.value)
/** @type {object|undefined} */
const config =
data && typeof data === 'object' && 'remark' in data
? // @ts-expect-error: hush we just checked.
data.remark
: undefined
Object.assign(this.options, config || {})
// Like the source:
// <https://github.com/syntax-tree/mdast-util-frontmatter/blob/583ae25/lib/to-markdown.js#L28>
return '---' + (node.value ? '\n' + node.value : '') + '\n---'
}
}
}
const extensions = /** @type {Extension[]} */ (
// Other extensions
/* c8 ignore next 2 */
data.toMarkdownExtensions
? data.toMarkdownExtensions
: (data.toMarkdownExtensions = [])
)
extensions.push(yamlConfig)
}
export {default} from './lib/index.js'
{
"name": "remark-yaml-config",
"version": "6.0.1",
"version": "7.0.0",
"description": "remark plugin to configure it with YAML frontmatter",
"license": "MIT",
"keywords": [
"unified",
"config",
"frontmatter",
"markdown",
"mdast",
"options",
"plugin",
"remark",
"remark-plugin",
"plugin",
"mdast",
"markdown",
"yaml",
"frontmatter",
"options",
"config",
"settings"
"settings",
"unified",
"yaml"
],

@@ -31,5 +31,5 @@ "repository": "remarkjs/remark-yaml-config",

"type": "module",
"main": "index.js",
"types": "index.d.ts",
"exports": "./index.js",
"files": [
"lib/",
"index.d.ts",

@@ -39,43 +39,39 @@ "index.js"

"dependencies": {
"@types/mdast": "^3.0.0",
"js-yaml": "^4.0.0",
"mdast-util-to-markdown": "^1.0.0",
"unified": "^10.0.0"
"@types/mdast": "^4.0.0",
"unified": "^11.0.0",
"yaml": "^2.0.0"
},
"devDependencies": {
"@types/tape": "^4.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark": "^14.0.0",
"remark-cli": "^10.0.0",
"remark-frontmatter": "^4.0.0",
"remark-html": "^15.0.0",
"@types/node": "^20.0.0",
"c8": "^8.0.0",
"prettier": "^3.0.0",
"rehype-stringify": "^10.0.0",
"remark": "^15.0.0",
"remark-cli": "^11.0.0",
"remark-frontmatter": "^5.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"remark-rehype": "^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 +82,8 @@ },

"detail": true,
"strict": true,
"ignoreCatch": true
"ignoreCatch": true,
"strict": true
},
"xo": {
"prettier": true
}
}

@@ -33,8 +33,2 @@ # remark-yaml-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 remarkYamlConfig from 'https://cdn.skypack.dev/remark-yaml-config@6?dts'
import remarkYamlConfig from 'https://esm.sh/remark-yaml-config@7'
```
In browsers with [Skypack][]:
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import remarkYamlConfig from 'https://cdn.skypack.dev/remark-yaml-config@6?min'
import remarkYamlConfig from 'https://esm.sh/remark-yaml-config@7?bundle'
</script>

@@ -87,29 +81,25 @@ ```

- Hello
- Triton
```
And our module `example.js` looks as follows:
…and a module `example.js`:
```js
import {read} from 'to-vfile'
import {remark} from 'remark'
import remarkFrontmatter from 'remark-frontmatter'
import remarkYamlConfig from 'remark-yaml-config'
import {read} from 'to-vfile'
main()
const file = await remark()
.use(remarkFrontmatter)
.use(remarkYamlConfig)
.process(await read('example.md'))
async function main() {
const file = await remark()
.use(remarkFrontmatter)
.use(remarkYamlConfig)
.process(await read('example.md'))
console.log(String(file))
}
console.log(String(file))
```
> ⚠️ **Important**: [`remark-frontmatter`][remark-frontmatter] is required to
> ⚠️ **Important**: [`remark-frontmatter`][remark-frontmatter] is needed to
> support YAML frontmatter in markdown.
Now running `node example.js` yields:
…then running `node example.js` yields:

@@ -119,6 +109,6 @@ ```markdown

remark:
bullet: "*"
bullet: "+"
---
+ Hello
+ Triton
```

@@ -129,3 +119,3 @@

This package exports no identifiers.
The default export is `remarkYamlConfig`.
The default export is [`remarkYamlConfig`][api-remark-yaml-config].

@@ -135,19 +125,29 @@ ### `unified().use(remarkYamlConfig)`

Configure remark with YAML frontmatter.
There are no options
Parses YAML frontmatter and takes the value of the `remark` field as settings.
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-yaml-config@^7`,
compatible with Node.js 16.
This plugin works with `remark` version 13+.

@@ -160,3 +160,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.

@@ -198,5 +198,5 @@ ## Related

[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-yaml-config.svg
[size-badge]: https://img.shields.io/bundlejs/size/remark-yaml-config
[size]: https://bundlephobia.com/result?p=remark-yaml-config
[size]: https://bundlejs.com/?q=remark-yaml-config

@@ -215,11 +215,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

@@ -232,12 +234,14 @@ [license]: license

[unified]: https://github.com/unifiedjs/unified
[remark-frontmatter]: https://github.com/remarkjs/remark-frontmatter
[remark-comment-config]: https://github.com/remarkjs/remark-comment-config
[remark-stringify-options]: https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/readme.md#options
[typescript]: https://www.typescriptlang.org
[stringify-settings]: https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/readme.md#options
[unified]: https://github.com/unifiedjs/unified
[remark-comment-config]: https://github.com/remarkjs/remark-comment-config
[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[remark-frontmatter]: https://github.com/remarkjs/remark-frontmatter
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[api-remark-yaml-config]: #unifieduseremarkyamlconfig
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc