New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eleventy-plugin-unified

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eleventy-plugin-unified - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

14

package.json
{
"type": "module",
"name": "eleventy-plugin-unified",
"version": "1.1.0",
"version": "1.2.0",
"description": "Use the unified ecosystem in Eleventy with remark and rehype.",

@@ -28,3 +28,3 @@ "main": ".eleventy.cjs",

"engines": {
"node": "^12.17 || ^13.7 || >= 14"
"node": ">= 16"
},

@@ -37,8 +37,11 @@ "files": [

"rehype-parse": "^8.0.4",
"rehype-retext": "^3.0.2",
"rehype-stringify": "^9.0.3",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"retext-english": "^4.1.0",
"unified": "^10.1.2"
},
"devDependencies": {
"@11ty/eleventy": "^1.0.2",
"@commitlint/cli": "^17.1.2",

@@ -49,2 +52,3 @@ "@commitlint/config-conventional": "^17.1.0",

"c8": "^7.12.0",
"deepmerge": "^4.2.2",
"eslint": "^8.25.0",

@@ -56,3 +60,7 @@ "eslint-config-prettier": "^8.5.0",

"proxyquire": "^2.1.3",
"semantic-release": "^19.0.5"
"rehype-format": "^4.0.1",
"remark-slug": "^7.0.1",
"retext-repeated-words": "^4.2.0",
"semantic-release": "^19.0.5",
"unist-util-visit": "^4.1.1"
},

@@ -59,0 +67,0 @@ "release": {

@@ -7,13 +7,12 @@ # Eleventy Plugin Unified

You can render and transform:
You can render, transform and lint:
- markdown with the [remark](https://github.com/remarkjs/remark) ecosystem.
- html with the [rehype](https://github.com/rehypejs/rehype) ecosystem.
- text with the [retext](https://github.com/retextjs/retext) ecosystem.
[retext](https://github.com/retextjs/retext) is not yet supported, raise an issue if you'd like this.
## Install
```bash
npm install eleventy-plugin-unified
npm install eleventy-plugin-unified remark-slug
```

@@ -109,2 +108,61 @@

### Configuring text transforms (retext plugins)
```bash
npm install eleventy-plugin-unified retext-repeated-words vfile-reporter
```
```javascript
// .eleventy.config.cjs
const EleventyUnifiedPlugin = require("eleventy-plugin-unified");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyUnifiedPlugin, [
reporter: 'vfile-reporter',
textTransforms: [
'retext-repeated-words'
]
]);
};
```
or
```javascript
// .eleventy.config.cjs
const EleventyUnifiedPlugin = require("eleventy-plugin-unified");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyUnifiedPlugin, [
reporter: (file) => {
console.log(file);
},
textTransforms: [
'retext-repeated-words'
]
]);
};
```
### Configuring text parser language
```bash
npm install eleventy-plugin-unified retext-latin retext-repeated-words vfile-reporter
```
```javascript
// .eleventy.config.cjs
const EleventyUnifiedPlugin = require("eleventy-plugin-unified");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyUnifiedPlugin, [
textParser: 'retext-latin',
reporter: 'vfile-reporter',
textTransforms: [
'retext-repeated-words'
]
]);
};
```
### Configuring options for a plugin

@@ -111,0 +169,0 @@

import { unified } from "unified";
import parse from "rehype-parse";
import retext from "rehype-retext";
import stringify from "rehype-stringify";
import importPlugins from "./import-plugins.js";
const importIfPath = async (pathOrName) => {
if (!pathOrName) {
return;
}
if (typeof pathOrName === "function") {
return pathOrName;
} else {
const { default: importedFunction } = await import(pathOrName);
return importedFunction;
}
};
/**

@@ -10,2 +23,5 @@ * @param {String} html html

* @param {Array.<String>} [pluginOptions.htmlTransforms]
* @param {Array.<String>} [pluginOptions.textTransforms]
* @param {String|Function} [pluginOptions.textParser]
* @param {Function} [pluginOptions.reporter]
* @param {String} [pluginOptions.transformsDirectory]

@@ -18,4 +34,20 @@ * @param {Object} [pluginOptions.pageContext]

html,
{ htmlTransforms, transformsDirectory, pageContext, eleventyConfig } = {}
{
htmlTransforms,
textTransforms,
textParser = "retext-english",
reporter,
transformsDirectory,
pageContext,
eleventyConfig,
} = {}
) {
const hasTextTransforms =
textTransforms instanceof Array && textTransforms.length > 0;
const retextPlugins = await importPlugins(
textTransforms,
transformsDirectory
);
const retextParser = await importIfPath(textParser);
const retextReporter = await importIfPath(reporter);
const output = await unified()

@@ -26,2 +58,3 @@ // Turn HTML into HTML AST (hast)

.use(await importPlugins(htmlTransforms, transformsDirectory))
.use(retext, unified().use(retextParser).use(retextPlugins))
// Turn HTML syntax tree into HTML text

@@ -34,3 +67,14 @@ .use(stringify)

.process(html);
if (
hasTextTransforms &&
typeof retextReporter === "function" &&
pageContext?.inputPath &&
output?.messages.length > 0
) {
output.path = pageContext.inputPath;
retextReporter(output);
}
return String(output);
}

Sorry, the diff of this file is not supported yet

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