Socket
Socket
Sign inDemoInstall

@hashicorp/remark-plugins

Package Overview
Dependencies
122
Maintainers
23
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 3.1.1-canary.0

3

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc