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

micromark-extension-mdx-expression

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-extension-mdx-expression - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

4

dev/index.d.ts

@@ -1,2 +0,2 @@

export { mdxExpression } from "./lib/syntax.js";
export type Options = import('./lib/syntax.js').Options;
export {mdxExpression} from './lib/syntax.js'
export type Options = import('./lib/syntax.js').Options

@@ -5,14 +5,14 @@ /**

*/
export function mdxExpression(options?: Options): Extension;
export type Extension = import('micromark-util-types').Extension;
export type Tokenizer = import('micromark-util-types').Tokenizer;
export type State = import('micromark-util-types').State;
export type Acorn = import('micromark-util-events-to-acorn').Acorn;
export type AcornOptions = import('micromark-util-events-to-acorn').AcornOptions;
export function mdxExpression(options?: Options): Extension
export type Extension = import('micromark-util-types').Extension
export type Tokenizer = import('micromark-util-types').Tokenizer
export type State = import('micromark-util-types').State
export type Acorn = import('micromark-util-events-to-acorn').Acorn
export type AcornOptions = import('micromark-util-events-to-acorn').AcornOptions
export type Options = {
addResult?: boolean | undefined;
acorn?: import("micromark-util-events-to-acorn").Acorn | undefined;
acornOptions?: import("acorn").Options | undefined;
spread?: boolean | undefined;
allowEmpty?: boolean | undefined;
};
addResult?: boolean | undefined
acorn?: import('micromark-util-events-to-acorn').Acorn | undefined
acornOptions?: import('acorn').Options | undefined
spread?: boolean | undefined
allowEmpty?: boolean | undefined
}

@@ -1,2 +0,2 @@

export { mdxExpression } from "./lib/syntax.js";
export type Options = import('./lib/syntax.js').Options;
export {mdxExpression} from './lib/syntax.js'
export type Options = import('./lib/syntax.js').Options
/**
* @typedef {import('./lib/syntax.js').Options} Options
*/
export { mdxExpression } from './lib/syntax.js';
export {mdxExpression} from './lib/syntax.js'

@@ -5,14 +5,14 @@ /**

*/
export function mdxExpression(options?: Options): Extension;
export type Extension = import('micromark-util-types').Extension;
export type Tokenizer = import('micromark-util-types').Tokenizer;
export type State = import('micromark-util-types').State;
export type Acorn = import('micromark-util-events-to-acorn').Acorn;
export type AcornOptions = import('micromark-util-events-to-acorn').AcornOptions;
export function mdxExpression(options?: Options): Extension
export type Extension = import('micromark-util-types').Extension
export type Tokenizer = import('micromark-util-types').Tokenizer
export type State = import('micromark-util-types').State
export type Acorn = import('micromark-util-events-to-acorn').Acorn
export type AcornOptions = import('micromark-util-events-to-acorn').AcornOptions
export type Options = {
addResult?: boolean | undefined;
acorn?: import("micromark-util-events-to-acorn").Acorn | undefined;
acornOptions?: import("acorn").Options | undefined;
spread?: boolean | undefined;
allowEmpty?: boolean | undefined;
};
addResult?: boolean | undefined
acorn?: import('micromark-util-events-to-acorn').Acorn | undefined
acornOptions?: import('acorn').Options | undefined
spread?: boolean | undefined
allowEmpty?: boolean | undefined
}

@@ -17,5 +17,5 @@ /**

*/
import { factoryMdxExpression } from 'micromark-factory-mdx-expression';
import { factorySpace } from 'micromark-factory-space';
import { markdownLineEnding } from 'micromark-util-character';
import {factoryMdxExpression} from 'micromark-factory-mdx-expression'
import {factorySpace} from 'micromark-factory-space'
import {markdownLineEnding} from 'micromark-util-character'

@@ -27,4 +27,4 @@ /**

export function mdxExpression(options = {}) {
const addResult = options.addResult;
const acorn = options.acorn; // Hidden: `micromark-extension-mdx-jsx` supports expressions in tags,
const addResult = options.addResult
const acorn = options.acorn // Hidden: `micromark-extension-mdx-jsx` supports expressions in tags,
// and one of them is only “spread” elements.

@@ -35,10 +35,10 @@ // It also has expressions that are not allowed to be empty (`<x y={}/>`).

const spread = options.spread;
let allowEmpty = options.allowEmpty;
const spread = options.spread
let allowEmpty = options.allowEmpty
/** @type {AcornOptions} */
let acornOptions;
let acornOptions
if (allowEmpty === null || allowEmpty === undefined) {
allowEmpty = true;
allowEmpty = true
}

@@ -48,11 +48,16 @@

if (!acorn.parseExpressionAt) {
throw new Error('Expected a proper `acorn` instance passed in as `options.acorn`');
throw new Error(
'Expected a proper `acorn` instance passed in as `options.acorn`'
)
}
acornOptions = Object.assign({
ecmaVersion: 2020,
sourceType: 'module'
}, options.acornOptions);
acornOptions = Object.assign(
{
ecmaVersion: 2020,
sourceType: 'module'
},
options.acornOptions
)
} else if (options.acornOptions || options.addResult) {
throw new Error('Expected an `acorn` instance passed in as `options.acorn`');
throw new Error('Expected an `acorn` instance passed in as `options.acorn`')
}

@@ -72,18 +77,29 @@

}
};
}
/** @type {Tokenizer} */
function tokenizeFlowExpression(effects, ok, nok) {
const self = this;
return start;
const self = this
return start
/** @type {State} */
function start(code) {
return factoryMdxExpression.call(self, effects, factorySpace(effects, after, "whitespace"), 'mdxFlowExpression', 'mdxFlowExpressionMarker', 'mdxFlowExpressionChunk', acorn, acornOptions, addResult, spread, allowEmpty)(code);
return factoryMdxExpression.call(
self,
effects,
factorySpace(effects, after, 'whitespace'),
'mdxFlowExpression',
'mdxFlowExpressionMarker',
'mdxFlowExpressionChunk',
acorn,
acornOptions,
addResult,
spread,
allowEmpty
)(code)
}
/** @type {State} */
function after(code) {
return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
return code === null || markdownLineEnding(code) ? ok(code) : nok(code)
}

@@ -93,12 +109,24 @@ }

function tokenizeTextExpression(effects, ok) {
const self = this;
return start;
const self = this
return start
/** @type {State} */
function start(code) {
return factoryMdxExpression.call(self, effects, ok, 'mdxTextExpression', 'mdxTextExpressionMarker', 'mdxTextExpressionChunk', acorn, acornOptions, addResult, spread, allowEmpty, true)(code);
return factoryMdxExpression.call(
self,
effects,
ok,
'mdxTextExpression',
'mdxTextExpressionMarker',
'mdxTextExpressionChunk',
acorn,
acornOptions,
addResult,
spread,
allowEmpty,
true
)(code)
}
}
}
}
{
"name": "micromark-extension-mdx-expression",
"version": "1.0.2",
"version": "1.0.3",
"description": "micromark extension to support MDX or MDX JS expressions",

@@ -5,0 +5,0 @@ "license": "MIT",

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