Socket
Socket
Sign inDemoInstall

mdast-util-mdx-jsx

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-mdx-jsx - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

1

index.d.ts

@@ -12,2 +12,3 @@ /** @type {FromMarkdownExtension} */

export type ToMarkdownHandle = import('mdast-util-to-markdown').Handle
export type ToMarkdownMap = import('mdast-util-to-markdown').Map
export type Program = import('estree-jsx').Program

@@ -14,0 +15,0 @@ export type MDXJsxAttributeValueExpression =

54

index.js

@@ -9,2 +9,3 @@ /**

* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
* @typedef {import('mdast-util-to-markdown').Map} ToMarkdownMap
* @typedef {import('estree-jsx').Program} Program

@@ -26,5 +27,4 @@ * @typedef {import('./complex-types').MDXJsxAttributeValueExpression} MDXJsxAttributeValueExpression

import {checkQuote} from 'mdast-util-to-markdown/lib/util/check-quote.js'
import {indentLines} from 'mdast-util-to-markdown/lib/util/indent-lines.js'
const eol = /\r?\n|\r/g
mdxElement.peek = peekElement

@@ -337,2 +337,3 @@

const exit = context.enter(node.type)
let attributeValue = ''
let index = -1

@@ -350,2 +351,5 @@ /** @type {Array.<string>} */

const isMultiFlow =
node.type === 'mdxJsxFlowElement' && node.attributes.length > 1
while (++index < node.attributes.length) {

@@ -373,4 +377,6 @@ const attribute = node.attributes[index]

attributes.push(result)
attributes.push((isMultiFlow ? '\n ' : ' ') + result)
}
attributeValue = attributes.join('') + (isMultiFlow ? '\n' : '')
}

@@ -381,8 +387,3 @@

(node.name || '') +
(node.type === 'mdxJsxFlowElement' && attributes.length > 1
? // Flow w/ multiple attributes.
'\n' + indent(attributes.join('\n')) + '\n'
: attributes.length > 0 // Text or flow w/ a single attribute.
? ' ' + dedentStart(indent(attributes.join(' ')))
: '') +
attributeValue +
(selfClosing ? '/' : '') +

@@ -400,6 +401,6 @@ '>' +

}
/**
* @type {ToMarkdownHandle}
*/
function peekElement() {

@@ -413,34 +414,9 @@ return '<'

*/
function dedentStart(value) {
return value.replace(/^ +/, '')
}
/**
* @param {string} value
* @returns {string}
*/
function indent(value) {
/** @type {Array.<string>} */
const result = []
let start = 0
/** @type {RegExpExecArray|null} */
let match
return indentLines(value, map)
while ((match = eol.exec(value))) {
one(value.slice(start, match.index))
result.push(match[0])
start = match.index + match[0].length
/** @type {ToMarkdownMap} */
function map(line, _, blank) {
return (blank ? '' : ' ') + line
}
one(value.slice(start))
return result.join('')
/**
* @param {string} slice
* @returns {void}
*/
function one(slice) {
result.push((slice ? ' ' : '') + slice)
}
}
{
"name": "mdast-util-mdx-jsx",
"version": "1.1.0",
"version": "1.1.1",
"description": "mdast extension to parse and serialize MDX or MDX.js JSX",

@@ -55,4 +55,4 @@ "license": "MIT",

"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"remark-cli": "^10.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",

@@ -62,3 +62,3 @@ "tape": "^5.0.0",

"typescript": "^4.0.0",
"xo": "^0.42.0"
"xo": "^0.44.0"
},

@@ -65,0 +65,0 @@ "scripts": {

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