remark-textr
Advanced tools
Comparing version 6.0.0 to 6.1.0
export { default } from "./lib/index.js"; | ||
export type Options = import('./lib/index.js').Options; | ||
export type TextrPlugin = import('./lib/index.js').TextrPlugin; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
export default function remarkTextr(options?: Readonly<Options> | null | undefined): (tree: Root) => Promise<undefined>; | ||
export default function remarkTextr(options?: Readonly<Options> | null | undefined): ((tree: Root) => undefined) | ((tree: Root) => Promise<undefined>); | ||
export type Root = import('mdast').Root; | ||
@@ -35,1 +35,2 @@ /** | ||
export type TextrPlugin = (value: string, options: object) => string | null | undefined | void; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -47,12 +47,31 @@ /** | ||
const textrOptions = settings.options || {} | ||
if (plugins.every((plugin) => typeof plugin === 'function')) { | ||
const typography = textr(textrOptions).use(...plugins) | ||
/** | ||
* Transform synchronously. | ||
* | ||
* @param {Root} tree | ||
* Tree. | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
return function (tree) { | ||
visit(tree, 'text', function (node) { | ||
node.value = typography.exec(node.value) | ||
}) | ||
} | ||
} | ||
const promise = Promise.all( | ||
plugins.map(async function (fn) { | ||
if (typeof fn === 'string') { | ||
// Assume plugin at default. | ||
plugins.map(async function (value) { | ||
if (typeof value === 'string') { | ||
// Assume value at default. | ||
/** @type {{default: TextrPlugin}} */ | ||
const mod = await import(fn) | ||
return mod.default | ||
const module_ = await import(value) | ||
return module_.default | ||
} | ||
return fn | ||
return value | ||
}) | ||
@@ -64,3 +83,3 @@ ).then(function (list) { | ||
/** | ||
* Transform. | ||
* Transform asynchronously. | ||
* | ||
@@ -67,0 +86,0 @@ * @param {Root} tree |
{ | ||
"name": "remark-textr", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "remark plugin to improve typography with Textr", | ||
@@ -37,2 +37,3 @@ "license": "MIT", | ||
"lib/", | ||
"index.d.ts.map", | ||
"index.d.ts", | ||
@@ -49,3 +50,3 @@ "index.js" | ||
"@types/textr": "^0.3.0", | ||
"c8": "^8.0.0", | ||
"c8": "^9.0.0", | ||
"prettier": "^3.0.0", | ||
@@ -59,3 +60,3 @@ "remark": "^15.0.0", | ||
"typographic-quotes": "^2.0.0", | ||
"xo": "^0.56.0" | ||
"xo": "^0.57.0" | ||
}, | ||
@@ -62,0 +63,0 @@ "scripts": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14853
9
127
0