Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 3.0.0 to 3.1.0

141

lib/index.d.ts

@@ -10,3 +10,3 @@ /**

*/
export function mdxJsxFromMarkdown(): FromMarkdownExtension
export function mdxJsxFromMarkdown(): FromMarkdownExtension;
/**

@@ -24,22 +24,19 @@ * Create an extension for `mdast-util-to-markdown` to enable MDX JSX.

*/
export function mdxJsxToMarkdown(
options?: ToMarkdownOptions | null | undefined
): ToMarkdownExtension
export type CompileContext = import('mdast-util-from-markdown').CompileContext
export type FromMarkdownExtension = import('mdast-util-from-markdown').Extension
export type FromMarkdownHandle = import('mdast-util-from-markdown').Handle
export type OnEnterError = import('mdast-util-from-markdown').OnEnterError
export type OnExitError = import('mdast-util-from-markdown').OnExitError
export type Token = import('mdast-util-from-markdown').Token
export type ToMarkdownHandle = import('mdast-util-to-markdown').Handle
export type ToMarkdownExtension = import('mdast-util-to-markdown').Options
export type State = import('mdast-util-to-markdown').State
export type Tracker = import('mdast-util-to-markdown').Tracker
export type MdxJsxAttribute = import('../index.js').MdxJsxAttribute
export type MdxJsxAttributeValueExpression =
import('../index.js').MdxJsxAttributeValueExpression
export type MdxJsxExpressionAttribute =
import('../index.js').MdxJsxExpressionAttribute
export type MdxJsxFlowElement = import('../index.js').MdxJsxFlowElement
export type MdxJsxTextElement = import('../index.js').MdxJsxTextElement
export function mdxJsxToMarkdown(options?: ToMarkdownOptions | null | undefined): ToMarkdownExtension;
export type CompileContext = import('mdast-util-from-markdown').CompileContext;
export type FromMarkdownExtension = import('mdast-util-from-markdown').Extension;
export type FromMarkdownHandle = import('mdast-util-from-markdown').Handle;
export type OnEnterError = import('mdast-util-from-markdown').OnEnterError;
export type OnExitError = import('mdast-util-from-markdown').OnExitError;
export type Token = import('mdast-util-from-markdown').Token;
export type ToMarkdownHandle = import('mdast-util-to-markdown').Handle;
export type ToMarkdownExtension = import('mdast-util-to-markdown').Options;
export type State = import('mdast-util-to-markdown').State;
export type Tracker = import('mdast-util-to-markdown').Tracker;
export type Point = import('unist').Point;
export type MdxJsxAttribute = import('../index.js').MdxJsxAttribute;
export type MdxJsxAttributeValueExpression = import('../index.js').MdxJsxAttributeValueExpression;
export type MdxJsxExpressionAttribute = import('../index.js').MdxJsxExpressionAttribute;
export type MdxJsxFlowElement = import('../index.js').MdxJsxFlowElement;
export type MdxJsxTextElement = import('../index.js').MdxJsxTextElement;
/**

@@ -49,30 +46,30 @@ * Single tag.

export type Tag = {
/**
* Name of tag, or `undefined` for fragment.
*
* > 👉 **Note**: `null` is used in the AST for fragments, as it serializes in
* > JSON.
*/
name: string | undefined
/**
* Attributes.
*/
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>
/**
* Whether the tag is closing (`</x>`).
*/
close: boolean
/**
* Whether the tag is self-closing (`<x/>`).
*/
selfClosing: boolean
/**
* Start point.
*/
start: Token['start']
/**
* End point.
*/
end: Token['start']
}
/**
* Name of tag, or `undefined` for fragment.
*
* > 👉 **Note**: `null` is used in the AST for fragments, as it serializes in
* > JSON.
*/
name: string | undefined;
/**
* Attributes.
*/
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>;
/**
* Whether the tag is closing (`</x>`).
*/
close: boolean;
/**
* Whether the tag is self-closing (`<x/>`).
*/
selfClosing: boolean;
/**
* Start point.
*/
start: Token['start'];
/**
* End point.
*/
end: Token['start'];
};
/**

@@ -82,24 +79,24 @@ * Configuration.

export type ToMarkdownOptions = {
/**
* Preferred quote to use around attribute values (default: `'"'`).
*/
quote?: '"' | "'" | null | undefined
/**
* Use the other quote if that results in less bytes (default: `false`).
*/
quoteSmart?: boolean | null | undefined
/**
* Do not use an extra space when closing self-closing elements: `<img/>`
* instead of `<img />` (default: `false`).
*/
tightSelfClosing?: boolean | null | undefined
/**
* Try and wrap syntax at this width (default: `Infinity`).
*
* When set to a finite number (say, `80`), the formatter will print
* attributes on separate lines when a tag doesn’t fit on one line.
* The normal behavior is to print attributes with spaces between them
* instead of line endings.
*/
printWidth?: number | null | undefined
}
/**
* Preferred quote to use around attribute values (default: `'"'`).
*/
quote?: '"' | "'" | null | undefined;
/**
* Use the other quote if that results in less bytes (default: `false`).
*/
quoteSmart?: boolean | null | undefined;
/**
* Do not use an extra space when closing self-closing elements: `<img/>`
* instead of `<img />` (default: `false`).
*/
tightSelfClosing?: boolean | null | undefined;
/**
* Try and wrap syntax at this width (default: `Infinity`).
*
* When set to a finite number (say, `80`), the formatter will print
* attributes on separate lines when a tag doesn’t fit on one line.
* The normal behavior is to print attributes with spaces between them
* instead of line endings.
*/
printWidth?: number | null | undefined;
};

@@ -14,2 +14,4 @@ /**

*
* @typedef {import('unist').Point} Point
*
* @typedef {import('../index.js').MdxJsxAttribute} MdxJsxAttribute

@@ -141,2 +143,14 @@ * @typedef {import('../index.js').MdxJsxAttributeValueExpression} MdxJsxAttributeValueExpression

/**
* Copy a point-like value.
*
* @param {Point} d
* Point-like value.
* @returns {Point}
* unist point.
*/
function point(d) {
return {line: d.line, column: d.column, offset: d.offset}
}
/**
* @this {CompileContext}

@@ -268,3 +282,12 @@ * @type {FromMarkdownHandle}

enterMdxJsxTagAnyAttribute.call(this, token)
tag.attributes.push({type: 'mdxJsxAttribute', name: '', value: null})
tag.attributes.push({
type: 'mdxJsxAttribute',
name: '',
value: null,
position: {
start: point(token.start),
// @ts-expect-error: `end` will be patched later.
end: undefined
}
})
}

@@ -312,2 +335,4 @@

node.name = this.sliceSerialize(token)
assert(node.position !== undefined)
node.position.end = point(token.end)
}

@@ -325,2 +350,4 @@

node.name += ':' + this.sliceSerialize(token)
assert(node.position !== undefined)
node.position.end = point(token.end)
}

@@ -332,9 +359,9 @@

*/
function exitMdxJsxTagAttributeValueLiteral() {
function exitMdxJsxTagAttributeValueLiteral(token) {
const tag = this.data.mdxJsxTag
assert(tag, 'expected `mdxJsxTag`')
tag.attributes[tag.attributes.length - 1].value = parseEntities(
this.resume(),
{nonTerminated: false}
)
const node = tag.attributes[tag.attributes.length - 1]
node.value = parseEntities(this.resume(), {nonTerminated: false})
assert(node.position !== undefined)
node.position.end = point(token.end)
}

@@ -360,2 +387,4 @@

tail.value = node
assert(tail.position !== undefined)
tail.position.end = point(token.end)
}

@@ -362,0 +391,0 @@

{
"name": "mdast-util-mdx-jsx",
"version": "3.0.0",
"version": "3.1.0",
"description": "mdast extension to parse and serialize MDX or MDX.js JSX",

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

"acorn": "^8.0.0",
"c8": "^8.0.0",
"micromark-extension-mdx-jsx": "^2.0.0",
"c8": "^9.0.0",
"micromark-extension-mdx-jsx": "^3.0.0",
"micromark-extension-mdx-md": "^2.0.0",
"prettier": "^2.0.0",
"prettier": "^3.0.0",
"remark-cli": "^11.0.0",

@@ -64,3 +64,3 @@ "remark-preset-wooorm": "^9.0.0",

"typescript": "^5.0.0",
"xo": "^0.54.0"
"xo": "^0.57.0"
},

@@ -70,3 +70,3 @@ "scripts": {

"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
"test-api-prod": "node --conditions production test.js",

@@ -109,4 +109,8 @@ "test-api-dev": "node --conditions development test.js",

],
"prettier": true
"prettier": true,
"rules": {
"logical-assignment-operators": "off",
"unicorn/prefer-at": "off"
}
}
}
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