Socket
Socket
Sign inDemoInstall

@hashicorp/remark-plugins

Package Overview
Dependencies
8
Maintainers
13
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"name": "@hashicorp/remark-plugins",
"description": "A potpourri of remark plugins used to process .mdx files",
"version": "0.1.0",
"version": "0.1.1",
"author": "Kevin Pruett",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/hashicorp/remark-plugins/issues",

@@ -5,2 +5,3 @@ const slug = require('remark-slug')

module.exports = {
name: 'headingLinkablePlugin',
plugins: [

@@ -7,0 +8,0 @@ slug,

@@ -7,28 +7,30 @@ const is = require('unist-util-is')

module.exports = () => tree => {
visit(tree, 'listItem', liNode => {
visit(liNode, 'paragraph', pNode => {
visit(pNode, 'inlineCode', codeNode => {
// Construct an id/slug based on value of <code> node
const codeSlug = slugger.slug(`inlinecode-${codeNode.value}`)
module.exports = function inlineCodeLinkablePlugin() {
return function transformer(tree) {
visit(tree, 'listItem', liNode => {
visit(liNode, 'paragraph', pNode => {
visit(pNode, 'inlineCode', codeNode => {
// Construct an id/slug based on value of <code> node
const codeSlug = slugger.slug(`inlinecode-${codeNode.value}`)
// Add slug to parent <li> node's id attribute
const data = liNode.data || (liNode.data = {})
const props = data.hProperties || (data.hProperties = {})
props.id = codeSlug
// Add slug to parent <li> node's id attribute
const data = liNode.data || (liNode.data = {})
const props = data.hProperties || (data.hProperties = {})
props.id = codeSlug
// Wrap link element around child <code> node
pNode.children = pNode.children.map(node => {
return is(node, codeNode)
? {
type: 'link',
url: `#${codeSlug}`,
title: null,
children: [node]
}
: node
// Wrap link element around child <code> node
pNode.children = pNode.children.map(node => {
return is(node, codeNode)
? {
type: 'link',
url: `#${codeSlug}`,
title: null,
children: [node]
}
: node
})
})
})
})
})
}
}

@@ -11,34 +11,36 @@ const is = require('unist-util-is')

module.exports = () => tree => {
visit(tree, 'paragraph', (pNode, _, parent) => {
visit(pNode, 'text', textNode => {
Object.keys(sigils).forEach(symbol => {
if (textNode.value.startsWith(`${symbol} `)) {
// Remove the literal sigil symbol from string contents
textNode.value = textNode.value.replace(`${symbol} `, '')
module.exports = function paragraphCustomAlertsPlugin() {
return function transformer(tree) {
visit(tree, 'paragraph', (pNode, _, parent) => {
visit(pNode, 'text', textNode => {
Object.keys(sigils).forEach(symbol => {
if (textNode.value.startsWith(`${symbol} `)) {
// Remove the literal sigil symbol from string contents
textNode.value = textNode.value.replace(`${symbol} `, '')
// Wrap matched nodes with <div> (containing proper attributes)
parent.children = parent.children.map(node => {
return is(node, pNode)
? {
type: 'wrapper',
children: [node],
data: {
hName: 'div',
hProperties: {
className: [
'alert',
`alert-${sigils[symbol]}`,
'g-type-body'
],
role: 'alert'
// Wrap matched nodes with <div> (containing proper attributes)
parent.children = parent.children.map(node => {
return is(node, pNode)
? {
type: 'wrapper',
children: [node],
data: {
hName: 'div',
hProperties: {
className: [
'alert',
`alert-${sigils[symbol]}`,
'g-type-body'
],
role: 'alert'
}
}
}
}
: node
})
}
: node
})
}
})
})
})
})
}
}
const visit = require('unist-util-visit')
module.exports = function hashicorpTypography() {
return function transformer(ast) {
module.exports = function typographyPlugin() {
return function transformer(tree) {
// Add typography classes to headings
visit(ast, 'heading', node => {
visit(tree, 'heading', node => {
const data = node.data || (node.data = {})

@@ -37,4 +37,4 @@ const props = data.hProperties || (data.hProperties = {})

// Add typography classes to list items
visit(ast, 'list', ast => {
ast.children.map(li => {
visit(tree, 'list', node => {
node.children.map(li => {
const data = li.data || (li.data = {})

@@ -41,0 +41,0 @@ const props = data.hProperties || (data.hProperties = {})

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