@hashicorp/remark-plugins
Advanced tools
Comparing version 3.1.0 to 3.1.1-canary.0
{ | ||
"name": "@hashicorp/remark-plugins", | ||
"description": "A potpourri of remark plugins used to process .mdx files", | ||
"version": "3.1.0", | ||
"version": "3.1.1-canary.0", | ||
"author": "Jeff Escalante", | ||
@@ -13,2 +13,3 @@ "bugs": "https://github.com/hashicorp/remark-plugins/issues", | ||
"remark": "^12.0.1", | ||
"remark-mdx": "^1.6.22", | ||
"to-vfile": "^6.1.0", | ||
@@ -15,0 +16,0 @@ "unist-util-flatmap": "^1.0.0", |
@@ -9,2 +9,6 @@ const generateSlug = require('../../generate_slug') | ||
// code blocks. | ||
// | ||
// NOTE: Some of the HTML code is duplicated in: | ||
// https://github.com/hashicorp/consul/blob/4f15f83dc64e2a9a95cb6b989719838b1f97015b/website/components/config-entry-reference/index.jsx#L84-L105 | ||
// If updating the HTML code here, also update there. | ||
module.exports = function anchorLinksPlugin({ | ||
@@ -11,0 +15,0 @@ compatibilitySlug, |
const path = require('path') | ||
const remark = require('remark') | ||
const remarkMdx = require('remark-mdx') | ||
const flatMap = require('unist-util-flatmap') | ||
const { readSync } = require('to-vfile') | ||
module.exports = function includeMarkdownPlugin({ resolveFrom } = {}) { | ||
module.exports = function includeMarkdownPlugin({ | ||
resolveFrom, | ||
mdxPartials, | ||
} = {}) { | ||
return function transformer(tree, file) { | ||
@@ -35,4 +39,13 @@ return flatMap(tree, (node) => { | ||
// return the file contents in place of the @include | ||
// this takes a couple steps because we allow recursive includes | ||
const processor = remark().use(includeMarkdownPlugin, { resolveFrom }) | ||
// this takes a couple steps because we process the file contents | ||
// using remark | ||
const processor = remark() | ||
// if the include is MDX, and the plugin consumer has confirmed their | ||
// intent to stringify MDX nodes (eg "jsx"), then use remarkMdx to support | ||
// custom components (which would otherwise appear as likely invalid HTML nodes) | ||
const isMdx = includePath.match(/\.mdx$/) | ||
if (isMdx && mdxPartials) processor.use(remarkMdx) | ||
// use the includeMarkdown plugin to allow recursive includes | ||
processor.use(includeMarkdownPlugin, { resolveFrom }) | ||
// Process the file contents, then return them | ||
const ast = processor.parse(includeContents) | ||
@@ -39,0 +52,0 @@ return processor.runSync(ast, includeContents).children |
@@ -16,3 +16,5 @@ const visit = require('unist-util-visit') | ||
const customMap = options.map || {} | ||
return customMap[elemKey] || defaultMap[elemKey] | ||
return typeof customMap[elemKey] === 'string' | ||
? customMap[elemKey] | ||
: defaultMap[elemKey] | ||
} | ||
@@ -19,0 +21,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
38847
509
8
1
+ Addedremark-mdx@^1.6.22
+ Added@babel/code-frame@7.24.7(transitive)
+ Added@babel/core@7.12.9(transitive)
+ Added@babel/generator@7.24.7(transitive)
+ Added@babel/helper-environment-visitor@7.24.7(transitive)
+ Added@babel/helper-function-name@7.24.7(transitive)
+ Added@babel/helper-hoist-variables@7.24.7(transitive)
+ Added@babel/helper-module-imports@7.24.7(transitive)
+ Added@babel/helper-module-transforms@7.24.7(transitive)
+ Added@babel/helper-plugin-utils@7.10.47.24.7(transitive)
+ Added@babel/helper-simple-access@7.24.7(transitive)
+ Added@babel/helper-split-export-declaration@7.24.7(transitive)
+ Added@babel/helper-string-parser@7.24.7(transitive)
+ Added@babel/helper-validator-identifier@7.24.7(transitive)
+ Added@babel/helpers@7.24.7(transitive)
+ Added@babel/highlight@7.24.7(transitive)
+ Added@babel/parser@7.24.7(transitive)
+ Added@babel/plugin-proposal-object-rest-spread@7.12.1(transitive)
+ Added@babel/plugin-syntax-jsx@7.12.1(transitive)
+ Added@babel/plugin-syntax-object-rest-spread@7.8.3(transitive)
+ Added@babel/plugin-transform-parameters@7.24.7(transitive)
+ Added@babel/template@7.24.7(transitive)
+ Added@babel/traverse@7.24.7(transitive)
+ Added@babel/types@7.24.7(transitive)
+ Added@jridgewell/gen-mapping@0.3.5(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.4.15(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Added@mdx-js/util@1.6.22(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedconvert-source-map@1.9.0(transitive)
+ Addeddebug@4.3.5(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-core-module@2.13.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjsesc@2.5.2(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedms@2.1.2(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpicocolors@1.0.1(transitive)
+ Addedremark-mdx@1.6.22(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedto-fast-properties@2.0.0(transitive)
+ Addedunified@9.2.0(transitive)