From 875b0c253328717fc3ba0885115cace95e2ff0e9 Mon Sep 17 00:00:00 2001 From: Oleksii Shmalko Date: Tue, 14 Nov 2023 15:48:40 +0200 Subject: [PATCH] chore: run prettier --- .../components/cover-image.js | 2 +- .../next-blog-starter/components/hero-post.js | 6 +- .../components/post-preview.js | 6 +- packages/orgx/index.js | 10 +- packages/orgx/lib/condition.browser.js | 2 +- packages/orgx/lib/condition.js | 4 +- packages/orgx/lib/evaluate.js | 14 +- packages/orgx/lib/node-types.js | 4 +- packages/orgx/lib/plugin/recma-jsx-build.js | 16 +- packages/orgx/lib/plugin/recma-jsx-rewrite.js | 43 +- packages/orgx/lib/plugin/recma-stringify.js | 14 +- packages/orgx/lib/plugin/rehype-recma.js | 4 +- packages/orgx/lib/plugin/rehype-remove-raw.js | 10 +- packages/orgx/lib/run.js | 6 +- packages/orgx/lib/util/estree-util-create.js | 10 +- .../estree-util-declaration-to-expression.js | 6 +- .../lib/util/estree-util-is-declaration.js | 4 +- .../estree-util-specifiers-to-declarations.js | 44 +- .../util/estree-util-to-binary-addition.js | 14 +- .../estree-util-to-id-or-member-expression.js | 42 +- packages/orgx/lib/util/extnames-to-regex.js | 2 +- .../orgx/lib/util/resolve-evaluate-options.js | 25 +- packages/orgx/test/compile.js | 680 +++--- packages/orgx/test/context/components.js | 8 +- packages/orgx/test/context/data.js | 8 +- packages/orgx/test/evaluate.js | 182 +- packages/uniorg-parse/src/entities.ts | 1983 +++++++++-------- packages/uniorg-parse/src/parser.ts | 45 +- packages/uniorg-parse/src/reader.ts | 2 +- packages/uniorg-stringify/src/stringify.ts | 16 +- 30 files changed, 1653 insertions(+), 1559 deletions(-) diff --git a/examples/next-blog-starter/components/cover-image.js b/examples/next-blog-starter/components/cover-image.js index 61745cf..f8a5ceb 100644 --- a/examples/next-blog-starter/components/cover-image.js +++ b/examples/next-blog-starter/components/cover-image.js @@ -1,6 +1,6 @@ import cn from 'classnames'; import Link from 'next/link'; -import Image from "next/legacy/image"; +import Image from 'next/legacy/image'; export default function CoverImage({ title, src, slug, height, width }) { const image = ( diff --git a/examples/next-blog-starter/components/hero-post.js b/examples/next-blog-starter/components/hero-post.js index 36bc72f..f018ff1 100644 --- a/examples/next-blog-starter/components/hero-post.js +++ b/examples/next-blog-starter/components/hero-post.js @@ -26,7 +26,11 @@ export default function HeroPost({

- + {title}

diff --git a/examples/next-blog-starter/components/post-preview.js b/examples/next-blog-starter/components/post-preview.js index f7c3d92..446bf4a 100644 --- a/examples/next-blog-starter/components/post-preview.js +++ b/examples/next-blog-starter/components/post-preview.js @@ -24,7 +24,11 @@ export default function PostPreview({ />

- + {title}

diff --git a/packages/orgx/index.js b/packages/orgx/index.js index 7852f01..f4abd91 100644 --- a/packages/orgx/index.js +++ b/packages/orgx/index.js @@ -4,8 +4,8 @@ * @typedef {import('./lib/evaluate.js').EvaluateOptions} EvaluateOptions */ -export {createProcessor} from './lib/core.js' -export {compile, compileSync} from './lib/compile.js' -export {evaluate, evaluateSync} from './lib/evaluate.js' -export {run, runSync} from './lib/run.js' -export {nodeTypes} from './lib/node-types.js' +export { createProcessor } from './lib/core.js'; +export { compile, compileSync } from './lib/compile.js'; +export { evaluate, evaluateSync } from './lib/evaluate.js'; +export { run, runSync } from './lib/run.js'; +export { nodeTypes } from './lib/node-types.js'; diff --git a/packages/orgx/lib/condition.browser.js b/packages/orgx/lib/condition.browser.js index faf5737..6b75911 100644 --- a/packages/orgx/lib/condition.browser.js +++ b/packages/orgx/lib/condition.browser.js @@ -1 +1 @@ -export const development = false +export const development = false; diff --git a/packages/orgx/lib/condition.js b/packages/orgx/lib/condition.js index 974ab7d..805641a 100644 --- a/packages/orgx/lib/condition.js +++ b/packages/orgx/lib/condition.js @@ -1,3 +1,3 @@ -import process from 'process' +import process from 'process'; -export const development = process.env.NODE_ENV === 'development' +export const development = process.env.NODE_ENV === 'development'; diff --git a/packages/orgx/lib/evaluate.js b/packages/orgx/lib/evaluate.js index 9a8e04d..5bb3ba0 100644 --- a/packages/orgx/lib/evaluate.js +++ b/packages/orgx/lib/evaluate.js @@ -5,9 +5,9 @@ * @typedef {import('mdx/types').MDXModule} ExportMap */ -import {compile, compileSync} from './compile.js' -import {run, runSync} from './run.js' -import {resolveEvaluateOptions} from './util/resolve-evaluate-options.js' +import { compile, compileSync } from './compile.js'; +import { run, runSync } from './run.js'; +import { resolveEvaluateOptions } from './util/resolve-evaluate-options.js'; /** * Evaluate MDX. @@ -19,10 +19,10 @@ import {resolveEvaluateOptions} from './util/resolve-evaluate-options.js' * @return {Promise} */ export async function evaluate(vfileCompatible, evaluateOptions) { - const {compiletime, runtime} = resolveEvaluateOptions(evaluateOptions) + const { compiletime, runtime } = resolveEvaluateOptions(evaluateOptions); // V8 on Erbium. /* c8 ignore next 2 */ - return run(await compile(vfileCompatible, compiletime), runtime) + return run(await compile(vfileCompatible, compiletime), runtime); } /** @@ -35,6 +35,6 @@ export async function evaluate(vfileCompatible, evaluateOptions) { * @return {ExportMap} */ export function evaluateSync(vfileCompatible, evaluateOptions) { - const {compiletime, runtime} = resolveEvaluateOptions(evaluateOptions) - return runSync(compileSync(vfileCompatible, compiletime), runtime) + const { compiletime, runtime } = resolveEvaluateOptions(evaluateOptions); + return runSync(compileSync(vfileCompatible, compiletime), runtime); } diff --git a/packages/orgx/lib/node-types.js b/packages/orgx/lib/node-types.js index 59bd745..e62a1af 100644 --- a/packages/orgx/lib/node-types.js +++ b/packages/orgx/lib/node-types.js @@ -7,5 +7,5 @@ export const nodeTypes = [ 'mdxJsxFlowElement', 'mdxJsxTextElement', 'mdxTextExpression', - 'mdxjsEsm' -] + 'mdxjsEsm', +]; diff --git a/packages/orgx/lib/plugin/recma-jsx-build.js b/packages/orgx/lib/plugin/recma-jsx-build.js index f7e14b0..2dbe134 100644 --- a/packages/orgx/lib/plugin/recma-jsx-build.js +++ b/packages/orgx/lib/plugin/recma-jsx-build.js @@ -8,9 +8,9 @@ * `arguments[0]` instead. */ -import {buildJsx} from 'estree-util-build-jsx' -import {specifiersToDeclarations} from '../util/estree-util-specifiers-to-declarations.js' -import {toIdOrMemberExpression} from '../util/estree-util-to-id-or-member-expression.js' +import { buildJsx } from 'estree-util-build-jsx'; +import { specifiersToDeclarations } from '../util/estree-util-specifiers-to-declarations.js'; +import { toIdOrMemberExpression } from '../util/estree-util-to-id-or-member-expression.js'; /** * A plugin to build JSX into function calls. @@ -19,10 +19,10 @@ import {toIdOrMemberExpression} from '../util/estree-util-to-id-or-member-expres * @type {import('unified').Plugin<[BuildJsxOptions & RecmaJsxBuildOptions?], Program>} */ export function recmaJsxBuild(options = {}) { - const {development, outputFormat} = options + const { development, outputFormat } = options; return (tree, file) => { - buildJsx(tree, {development, filePath: file.history[0]}) + buildJsx(tree, { development, filePath: file.history[0] }); // When compiling to a function body, replace the import that was just // generated, and get `jsx`, `jsxs`, and `Fragment` from `arguments[0]` @@ -40,8 +40,8 @@ export function recmaJsxBuild(options = {}) { declarations: specifiersToDeclarations( tree.body[0].specifiers, toIdOrMemberExpression(['arguments', 0]) - ) - } + ), + }; } - } + }; } diff --git a/packages/orgx/lib/plugin/recma-jsx-rewrite.js b/packages/orgx/lib/plugin/recma-jsx-rewrite.js index 2c5c2e8..998f046 100644 --- a/packages/orgx/lib/plugin/recma-jsx-rewrite.js +++ b/packages/orgx/lib/plugin/recma-jsx-rewrite.js @@ -79,9 +79,9 @@ export function recmaJsxRewrite(options = {}) { walk(tree, { enter(_node) { const node = /** @type {Node} */ (_node); - const newScope = /** @type {Scope|undefined} */ (scopeInfo.map.get( - node - )); + const newScope = /** @type {Scope|undefined} */ ( + scopeInfo.map.get(node) + ); if ( node.type === 'FunctionDeclaration' || @@ -142,7 +142,9 @@ export function recmaJsxRewrite(options = {}) { const isInScope = inScope(currentScope, id); if (!own.call(fnScope.references, fullId)) { - const parentScope = /** @type {Scope|null} */ (currentScope.parent); + const parentScope = /** @type {Scope|null} */ ( + currentScope.parent + ); if ( !isInScope || // If the parent scope is `_createContent`, then this @@ -198,9 +200,8 @@ export function recmaJsxRewrite(options = {}) { /** @type {Array} */ let jsxIdExpression = ['_components', id]; if (isIdentifierName(id) === false) { - let invalidComponentName = fnScope.idToInvalidComponentName.get( - id - ); + let invalidComponentName = + fnScope.idToInvalidComponentName.get(id); if (invalidComponentName === undefined) { invalidComponentName = `_component${fnScope.idToInvalidComponentName.size}`; fnScope.idToInvalidComponentName.set(id, invalidComponentName); @@ -209,14 +210,12 @@ export function recmaJsxRewrite(options = {}) { jsxIdExpression = [invalidComponentName]; } - node.openingElement.name = toJsxIdOrMemberExpression( - jsxIdExpression - ); + node.openingElement.name = + toJsxIdOrMemberExpression(jsxIdExpression); if (node.closingElement) { - node.closingElement.name = toJsxIdOrMemberExpression( - jsxIdExpression - ); + node.closingElement.name = + toJsxIdOrMemberExpression(jsxIdExpression); } } } @@ -315,15 +314,15 @@ export function recmaJsxRewrite(options = {}) { optional: false, } : parameters[0].type === 'MemberExpression' - ? // If we’re only getting components from `props.components`, - // make sure it’s defined. - { - type: 'LogicalExpression', - operator: '||', - left: parameters[0], - right: { type: 'ObjectExpression', properties: [] }, - } - : parameters[0]; + ? // If we’re only getting components from `props.components`, + // make sure it’s defined. + { + type: 'LogicalExpression', + operator: '||', + left: parameters[0], + right: { type: 'ObjectExpression', properties: [] }, + } + : parameters[0]; /** @type {ObjectPattern|undefined} */ let componentsPattern; diff --git a/packages/orgx/lib/plugin/recma-stringify.js b/packages/orgx/lib/plugin/recma-stringify.js index 9f8e647..2e318ec 100644 --- a/packages/orgx/lib/plugin/recma-stringify.js +++ b/packages/orgx/lib/plugin/recma-stringify.js @@ -8,7 +8,7 @@ * in. */ -import {toJs, jsx} from 'estree-util-to-js' +import { toJs, jsx } from 'estree-util-to-js'; /** * A plugin that adds an esast compiler: a small wrapper around `astring` to add @@ -18,9 +18,9 @@ import {toJs, jsx} from 'estree-util-to-js' * @type {import('unified').Plugin<[RecmaStringifyOptions]|[], Program, string>} */ export function recmaStringify(options = {}) { - const {SourceMapGenerator} = options + const { SourceMapGenerator } = options; - Object.assign(this, {Compiler: compiler}) + Object.assign(this, { Compiler: compiler }); /** @type {import('unified').CompilerFunction} */ function compiler(tree, file) { @@ -28,12 +28,12 @@ export function recmaStringify(options = {}) { ? toJs(tree, { filePath: file.path || 'unknown.mdx', SourceMapGenerator, - handlers: jsx + handlers: jsx, }) - : toJs(tree, {handlers: jsx}) + : toJs(tree, { handlers: jsx }); - file.map = result.map + file.map = result.map; - return result.value + return result.value; } } diff --git a/packages/orgx/lib/plugin/rehype-recma.js b/packages/orgx/lib/plugin/rehype-recma.js index 4acec9a..6ac4d60 100644 --- a/packages/orgx/lib/plugin/rehype-recma.js +++ b/packages/orgx/lib/plugin/rehype-recma.js @@ -3,7 +3,7 @@ * @typedef {import('hast').Root} Root */ -import {toEstree} from 'hast-util-to-estree' +import { toEstree } from 'hast-util-to-estree'; /** * A plugin to transform an HTML (hast) tree to a JS (estree). @@ -12,5 +12,5 @@ import {toEstree} from 'hast-util-to-estree' * @type {import('unified').Plugin, Root, Program>} */ export function rehypeRecma() { - return (tree) => toEstree(tree) + return (tree) => toEstree(tree); } diff --git a/packages/orgx/lib/plugin/rehype-remove-raw.js b/packages/orgx/lib/plugin/rehype-remove-raw.js index c923803..12a416a 100644 --- a/packages/orgx/lib/plugin/rehype-remove-raw.js +++ b/packages/orgx/lib/plugin/rehype-remove-raw.js @@ -2,7 +2,7 @@ * @typedef {import('hast').Root} Root */ -import {visit} from 'unist-util-visit' +import { visit } from 'unist-util-visit'; /** * A tiny plugin that removes raw HTML. @@ -15,9 +15,9 @@ export function rehypeRemoveRaw() { return (tree) => { visit(tree, 'raw', (_, index, parent) => { if (parent && typeof index === 'number') { - parent.children.splice(index, 1) - return index + parent.children.splice(index, 1); + return index; } - }) - } + }); + }; } diff --git a/packages/orgx/lib/run.js b/packages/orgx/lib/run.js index 80ecfec..f63db8c 100644 --- a/packages/orgx/lib/run.js +++ b/packages/orgx/lib/run.js @@ -1,5 +1,5 @@ /** @type {new (code: string, ...args: Array) => Function} **/ -const AsyncFunction = Object.getPrototypeOf(run).constructor +const AsyncFunction = Object.getPrototypeOf(run).constructor; /** * Asynchronously run code. @@ -12,7 +12,7 @@ const AsyncFunction = Object.getPrototypeOf(run).constructor export async function run(file, options) { // V8 on Erbium. /* c8 ignore next 2 */ - return new AsyncFunction(String(file))(options) + return new AsyncFunction(String(file))(options); } /** @@ -25,5 +25,5 @@ export async function run(file, options) { */ export function runSync(file, options) { // eslint-disable-next-line no-new-func - return new Function(String(file))(options) + return new Function(String(file))(options); } diff --git a/packages/orgx/lib/util/estree-util-create.js b/packages/orgx/lib/util/estree-util-create.js index 7a9f9c7..0eaa1a6 100644 --- a/packages/orgx/lib/util/estree-util-create.js +++ b/packages/orgx/lib/util/estree-util-create.js @@ -11,17 +11,17 @@ export function create(template, node) { /** @type {Array} */ // @ts-expect-error: `start`, `end`, `comments` are custom Acorn fields. - const fields = ['start', 'end', 'loc', 'range', 'comments'] - let index = -1 + const fields = ['start', 'end', 'loc', 'range', 'comments']; + let index = -1; while (++index < fields.length) { - const field = fields[index] + const field = fields[index]; if (field in template) { // @ts-expect-error: assume they’re settable. - node[field] = template[field] + node[field] = template[field]; } } - return node + return node; } diff --git a/packages/orgx/lib/util/estree-util-declaration-to-expression.js b/packages/orgx/lib/util/estree-util-declaration-to-expression.js index 2f34961..fdf126a 100644 --- a/packages/orgx/lib/util/estree-util-declaration-to-expression.js +++ b/packages/orgx/lib/util/estree-util-declaration-to-expression.js @@ -14,16 +14,16 @@ */ export function declarationToExpression(declaration) { if (declaration.type === 'FunctionDeclaration') { - return {...declaration, type: 'FunctionExpression'} + return { ...declaration, type: 'FunctionExpression' }; } if (declaration.type === 'ClassDeclaration') { - return {...declaration, type: 'ClassExpression'} + return { ...declaration, type: 'ClassExpression' }; /* Internal utility so the next shouldn’t happen or a maintainer is making a * mistake. */ /* c8 ignore next 4 */ } // Probably `VariableDeclaration`. - throw new Error('Cannot turn `' + declaration.type + '` into an expression') + throw new Error('Cannot turn `' + declaration.type + '` into an expression'); } diff --git a/packages/orgx/lib/util/estree-util-is-declaration.js b/packages/orgx/lib/util/estree-util-is-declaration.js index d2f4254..bcc9867 100644 --- a/packages/orgx/lib/util/estree-util-is-declaration.js +++ b/packages/orgx/lib/util/estree-util-is-declaration.js @@ -9,10 +9,10 @@ export function isDeclaration(node) { /** @type {string} */ // @ts-expect-error Hush typescript, looks like `type` is available. - const type = node && typeof node === 'object' && node.type + const type = node && typeof node === 'object' && node.type; return Boolean( type === 'FunctionDeclaration' || type === 'ClassDeclaration' || type === 'VariableDeclaration' - ) + ); } diff --git a/packages/orgx/lib/util/estree-util-specifiers-to-declarations.js b/packages/orgx/lib/util/estree-util-specifiers-to-declarations.js index 2f75a2c..33e3651 100644 --- a/packages/orgx/lib/util/estree-util-specifiers-to-declarations.js +++ b/packages/orgx/lib/util/estree-util-specifiers-to-declarations.js @@ -9,7 +9,7 @@ * @typedef {import('estree-jsx').Expression} Expression */ -import {create} from './estree-util-create.js' +import { create } from './estree-util-create.js'; /** * @param {Array} specifiers @@ -17,22 +17,22 @@ import {create} from './estree-util-create.js' * @returns {Array} */ export function specifiersToDeclarations(specifiers, init) { - let index = -1 + let index = -1; /** @type {Array} */ - const declarations = [] + const declarations = []; /** @type {Array} */ - const otherSpecifiers = [] + const otherSpecifiers = []; // Can only be one according to JS syntax. /** @type {ImportNamespaceSpecifier|undefined} */ - let importNamespaceSpecifier + let importNamespaceSpecifier; while (++index < specifiers.length) { - const specifier = specifiers[index] + const specifier = specifiers[index]; if (specifier.type === 'ImportNamespaceSpecifier') { - importNamespaceSpecifier = specifier + importNamespaceSpecifier = specifier; } else { - otherSpecifiers.push(specifier) + otherSpecifiers.push(specifier); } } @@ -41,9 +41,9 @@ export function specifiersToDeclarations(specifiers, init) { create(importNamespaceSpecifier, { type: 'VariableDeclarator', id: importNamespaceSpecifier.local, - init + init, }) - ) + ); } declarations.push({ @@ -56,14 +56,14 @@ export function specifiersToDeclarations(specifiers, init) { specifier.type === 'ImportSpecifier' ? specifier.imported : specifier.type === 'ExportSpecifier' - ? specifier.exported - : {type: 'Identifier', name: 'default'} - let value = specifier.local + ? specifier.exported + : { type: 'Identifier', name: 'default' }; + let value = specifier.local; // Switch them around if we’re exporting. if (specifier.type === 'ExportSpecifier') { - value = key - key = specifier.local + value = key; + key = specifier.local; } return create(specifier, { @@ -73,14 +73,14 @@ export function specifiersToDeclarations(specifiers, init) { method: false, computed: false, key, - value - }) - }) + value, + }); + }), }, init: importNamespaceSpecifier - ? {type: 'Identifier', name: importNamespaceSpecifier.local.name} - : init - }) + ? { type: 'Identifier', name: importNamespaceSpecifier.local.name } + : init, + }); - return declarations + return declarations; } diff --git a/packages/orgx/lib/util/estree-util-to-binary-addition.js b/packages/orgx/lib/util/estree-util-to-binary-addition.js index 6d36b28..93d8d8a 100644 --- a/packages/orgx/lib/util/estree-util-to-binary-addition.js +++ b/packages/orgx/lib/util/estree-util-to-binary-addition.js @@ -6,18 +6,20 @@ * @param {Array} expressions */ export function toBinaryAddition(expressions) { - let index = -1 + let index = -1; /** @type {Expression|undefined} */ - let left + let left; while (++index < expressions.length) { - const right = expressions[index] - left = left ? {type: 'BinaryExpression', left, operator: '+', right} : right + const right = expressions[index]; + left = left + ? { type: 'BinaryExpression', left, operator: '+', right } + : right; } // Just for types. /* c8 ignore next */ - if (!left) throw new Error('Expected non-empty `expressions` to be passed') + if (!left) throw new Error('Expected non-empty `expressions` to be passed'); - return left + return left; } diff --git a/packages/orgx/lib/util/estree-util-to-id-or-member-expression.js b/packages/orgx/lib/util/estree-util-to-id-or-member-expression.js index 63fe3f1..dd266f7 100644 --- a/packages/orgx/lib/util/estree-util-to-id-or-member-expression.js +++ b/packages/orgx/lib/util/estree-util-to-id-or-member-expression.js @@ -9,14 +9,14 @@ import { start as esStart, cont as esCont, - name as isIdentifierName -} from 'estree-util-is-identifier-name' + name as isIdentifierName, +} from 'estree-util-is-identifier-name'; export const toIdOrMemberExpression = toIdOrMemberExpressionFactory( 'Identifier', 'MemberExpression', isIdentifierName -) +); export const toJsxIdOrMemberExpression = // @ts-expect-error: fine @@ -27,7 +27,7 @@ export const toJsxIdOrMemberExpression = 'JSXMemberExpression', isJsxIdentifierName ) - ) + ); /** * @param {string} idType @@ -35,30 +35,32 @@ export const toJsxIdOrMemberExpression = * @param {(value: string) => boolean} isIdentifier */ function toIdOrMemberExpressionFactory(idType, memberType, isIdentifier) { - return toIdOrMemberExpression + return toIdOrMemberExpression; /** * @param {Array} ids * @returns {Identifier|MemberExpression} */ function toIdOrMemberExpression(ids) { - let index = -1 + let index = -1; /** @type {Identifier|Literal|MemberExpression|undefined} */ - let object + let object; while (++index < ids.length) { - const name = ids[index] - const valid = typeof name === 'string' && isIdentifier(name) + const name = ids[index]; + const valid = typeof name === 'string' && isIdentifier(name); // A value of `asd.123` could be turned into `asd['123']` in the JS form, // but JSX does not have a form for it, so throw. /* c8 ignore next 3 */ if (idType === 'JSXIdentifier' && !valid) { - throw new Error('Cannot turn `' + name + '` into a JSX identifier') + throw new Error('Cannot turn `' + name + '` into a JSX identifier'); } /** @type {Identifier|Literal} */ // @ts-expect-error: JSX is fine. - const id = valid ? {type: idType, name} : {type: 'Literal', value: name} + const id = valid + ? { type: idType, name } + : { type: 'Literal', value: name }; // @ts-expect-error: JSX is fine. object = object ? { @@ -66,18 +68,18 @@ function toIdOrMemberExpressionFactory(idType, memberType, isIdentifier) { object, property: id, computed: id.type === 'Literal', - optional: false + optional: false, } - : id + : id; } // Just for types. /* c8 ignore next 3 */ - if (!object) throw new Error('Expected non-empty `ids` to be passed') + if (!object) throw new Error('Expected non-empty `ids` to be passed'); if (object.type === 'Literal') - throw new Error('Expected identifier as left-most value') + throw new Error('Expected identifier as left-most value'); - return object + return object; } } @@ -86,17 +88,17 @@ function toIdOrMemberExpressionFactory(idType, memberType, isIdentifier) { * @param {string} name */ function isJsxIdentifierName(name) { - let index = -1 + let index = -1; while (++index < name.length) { // We currently receive valid input, but this catches bugs and is needed // when externalized. /* c8 ignore next */ - if (!(index ? jsxCont : esStart)(name.charCodeAt(index))) return false + if (!(index ? jsxCont : esStart)(name.charCodeAt(index))) return false; } // `false` if `name` is empty. - return index > 0 + return index > 0; } /** @@ -104,5 +106,5 @@ function isJsxIdentifierName(name) { * @param {number} code */ function jsxCont(code) { - return code === 45 /* `-` */ || esCont(code) + return code === 45 /* `-` */ || esCont(code); } diff --git a/packages/orgx/lib/util/extnames-to-regex.js b/packages/orgx/lib/util/extnames-to-regex.js index 1002c8e..4f766db 100644 --- a/packages/orgx/lib/util/extnames-to-regex.js +++ b/packages/orgx/lib/util/extnames-to-regex.js @@ -10,5 +10,5 @@ export function extnamesToRegex(extnames) { // eslint-disable-next-line security/detect-non-literal-regexp return new RegExp( '\\.(' + extnames.map((d) => d.slice(1)).join('|') + ')([?#]|$)' - ) + ); } diff --git a/packages/orgx/lib/util/resolve-evaluate-options.js b/packages/orgx/lib/util/resolve-evaluate-options.js index de73f41..505fcf8 100644 --- a/packages/orgx/lib/util/resolve-evaluate-options.js +++ b/packages/orgx/lib/util/resolve-evaluate-options.js @@ -25,15 +25,22 @@ * @returns {{compiletime: ProcessorOptions, runtime: RunnerOptions}} */ export function resolveEvaluateOptions(options) { - const {development, Fragment, jsx, jsxs, jsxDEV, useMDXComponents, ...rest} = - options || {} + const { + development, + Fragment, + jsx, + jsxs, + jsxDEV, + useMDXComponents, + ...rest + } = options || {}; - if (!Fragment) throw new Error('Expected `Fragment` given to `evaluate`') + if (!Fragment) throw new Error('Expected `Fragment` given to `evaluate`'); if (development) { - if (!jsxDEV) throw new Error('Expected `jsxDEV` given to `evaluate`') + if (!jsxDEV) throw new Error('Expected `jsxDEV` given to `evaluate`'); } else { - if (!jsx) throw new Error('Expected `jsx` given to `evaluate`') - if (!jsxs) throw new Error('Expected `jsxs` given to `evaluate`') + if (!jsx) throw new Error('Expected `jsx` given to `evaluate`'); + if (!jsxs) throw new Error('Expected `jsxs` given to `evaluate`'); } return { @@ -41,8 +48,8 @@ export function resolveEvaluateOptions(options) { ...rest, development, outputFormat: 'function-body', - providerImportSource: useMDXComponents ? '#' : undefined + providerImportSource: useMDXComponents ? '#' : undefined, }, - runtime: {Fragment, jsx, jsxs, jsxDEV, useMDXComponents} - } + runtime: { Fragment, jsx, jsxs, jsxDEV, useMDXComponents }, + }; } diff --git a/packages/orgx/test/compile.js b/packages/orgx/test/compile.js index dc50af4..7b64eb2 100644 --- a/packages/orgx/test/compile.js +++ b/packages/orgx/test/compile.js @@ -5,47 +5,47 @@ * @typedef {import('../lib/compile.js').VFileCompatible} VFileCompatible */ -import {Buffer} from 'buffer' -import {promises as fs} from 'fs' -import path from 'path' -import {test} from 'uvu' -import * as assert from 'uvu/assert' -import {nanoid} from 'nanoid' -import {h} from 'preact' -import {render} from 'preact-render-to-string' -import React from 'react' -import rehypeKatex from 'rehype-katex' -import rehypeRaw from 'rehype-raw' -import remarkFrontmatter from 'remark-frontmatter' -import remarkGfm from 'remark-gfm' -import remarkMath from 'remark-math' -import {VFile} from 'vfile' -import {SourceMapGenerator} from 'source-map' -import {compile, compileSync, createProcessor, nodeTypes} from '../index.js' +import { Buffer } from 'buffer'; +import { promises as fs } from 'fs'; +import path from 'path'; +import { test } from 'uvu'; +import * as assert from 'uvu/assert'; +import { nanoid } from 'nanoid'; +import { h } from 'preact'; +import { render } from 'preact-render-to-string'; +import React from 'react'; +import rehypeKatex from 'rehype-katex'; +import rehypeRaw from 'rehype-raw'; +import remarkFrontmatter from 'remark-frontmatter'; +import remarkGfm from 'remark-gfm'; +import remarkMath from 'remark-math'; +import { VFile } from 'vfile'; +import { SourceMapGenerator } from 'source-map'; +import { compile, compileSync, createProcessor, nodeTypes } from '../index.js'; // @ts-expect-error: make sure a single react is used. -import {renderToStaticMarkup as renderToStaticMarkup_} from '../../react/node_modules/react-dom/server.js' -import {MDXProvider} from '../../react/index.js' +import { renderToStaticMarkup as renderToStaticMarkup_ } from '../../react/node_modules/react-dom/server.js'; +import { MDXProvider } from '../../react/index.js'; // Note: Node has an experimental `--enable-source-maps` flag, but most of V8 // doesn’t seem to support it. // So instead use a userland module. -import 'source-map-support/register.js' +import 'source-map-support/register.js'; /** @type {import('react-dom/server').renderToStaticMarkup} */ -const renderToStaticMarkup = renderToStaticMarkup_ +const renderToStaticMarkup = renderToStaticMarkup_; test('compile', async () => { try { // @ts-expect-error: removed option. - await compile('# hi!', {filepath: 'example.mdx'}) - assert.unreachable() + await compile('# hi!', { filepath: 'example.mdx' }); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /`options.filepath` is no longer supported/, 'should throw when a removed option is passed' - ) + ); } assert.equal( @@ -54,7 +54,7 @@ test('compile', async () => { ), '

hi!

', 'should compile' - ) + ); assert.equal( renderToStaticMarkup( @@ -62,61 +62,61 @@ test('compile', async () => { ), '

hi?

', 'should compile a vfile' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('# hi!')))), '

hi!

', 'should compile (sync)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('')))), '', 'should compile an empty document' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( await run( compileSync('x', { - remarkPlugins: [() => () => ({type: 'root', children: []})] + remarkPlugins: [() => () => ({ type: 'root', children: [] })], }) ) ) ), '', 'should compile an empty document (remark)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( await run( compileSync('y', { - rehypePlugins: [() => () => ({type: 'root', children: []})] + rehypePlugins: [() => () => ({ type: 'root', children: [] })], }) ) ) ), '', 'should compile an empty document (rehype)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( await run( compileSync('y', { - rehypePlugins: [() => () => ({type: 'doctype', name: 'html'})] + rehypePlugins: [() => () => ({ type: 'doctype', name: 'html' })], }) ) ) ), '', 'should compile a document (rehype, non-representable)' - ) + ); assert.equal( renderToStaticMarkup( @@ -124,15 +124,15 @@ test('compile', async () => { await run( compileSync('y', { rehypePlugins: [ - () => () => ({type: 'element', tagName: 'x', children: []}) - ] + () => () => ({ type: 'element', tagName: 'x', children: [] }), + ], }) ) ) ), '', 'should compile a non-element document (rehype, single element)' - ) + ); assert.equal( renderToStaticMarkup( @@ -140,33 +140,33 @@ test('compile', async () => { await run( compileSync('y', { rehypePlugins: [ - () => () => ({type: 'element', tagName: 'a-b', children: []}) - ] + () => () => ({ type: 'element', tagName: 'a-b', children: [] }), + ], }) ) ) ), '', 'should compile custom elements' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(compileSync('!', {jsxRuntime: 'automatic'})) + await run(compileSync('!', { jsxRuntime: 'automatic' })) ) ), '

!

', 'should support the automatic runtime (`@jsxRuntime`)' - ) + ); assert.equal( render( - h(await run(compileSync('?', {jsxImportSource: 'preact/compat'})), {}) + h(await run(compileSync('?', { jsxImportSource: 'preact/compat' })), {}) ), '

?

', 'should support an import source (`@jsxImportSource`)' - ) + ); assert.equal( render( @@ -176,7 +176,7 @@ test('compile', async () => { jsxRuntime: 'classic', pragma: 'preact.createElement', pragmaFrag: 'preact.Fragment', - pragmaImportSource: 'preact/compat' + pragmaImportSource: 'preact/compat', }) ), {} @@ -184,39 +184,39 @@ test('compile', async () => { ), '%', 'should support `pragma`, `pragmaFrag` for `preact/compat`' - ) + ); assert.equal( render( - h(await run(compileSync('<>1', {jsxImportSource: 'preact'})), {}) + h(await run(compileSync('<>1', { jsxImportSource: 'preact' })), {}) ), '1', 'should support `jsxImportSource` for `preact`' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( await run( - String(compileSync('<>+', {jsxImportSource: '@emotion/react'})) + String(compileSync('<>+', { jsxImportSource: '@emotion/react' })) ) ) ), '+', 'should support `jsxImportSource` for `emotion`' - ) + ); assert.throws( () => { compileSync('import React from "react"\n\n.', { jsxRuntime: 'classic', pragmaImportSource: '@emotion/react', - pragma: '' - }) + pragma: '', + }); }, /Missing `pragma` in classic runtime with `pragmaImportSource`/, 'should *not* support `jsxClassicImportSource` w/o `pragma`' - ) + ); assert.equal( renderToStaticMarkup( @@ -224,14 +224,14 @@ test('compile', async () => { components: { /** @param {Record} props */ X(props) { - return React.createElement('span', props, '!') - } - } + return React.createElement('span', props, '!'); + }, + }, }) ), '!', 'should support passing in `components` to `MDXContent`' - ) + ); assert.equal( renderToStaticMarkup( @@ -240,15 +240,15 @@ test('compile', async () => { x: { /** @param {Record} props */ y(props) { - return React.createElement('span', props, '?') - } - } - } + return React.createElement('span', props, '?'); + }, + }, + }, }) ), '?', 'should support passing in `components` (for members) to `MDXContent`' - ) + ); assert.equal( renderToStaticMarkup( @@ -260,30 +260,30 @@ test('compile', async () => { { /** @param {Record} props */ Y(props) { - return React.createElement('span', props, '?') - } + return React.createElement('span', props, '?'); + }, } - ) - } + ), + }, }) ), '

! and ?

', 'should support passing in `components` directly and as an object w/ members' - ) + ); assert.equal( renderToStaticMarkup( React.createElement(await run(compileSync('*a*')), { components: { em(props) { - return React.createElement('i', props) - } - } + return React.createElement('i', props); + }, + }, }) ), '

a

', 'should support overwriting components by passing them to `MDXContent`' - ) + ); assert.equal( renderToStaticMarkup( @@ -294,30 +294,30 @@ test('compile', async () => { { components: { em(props) { - return React.createElement('i', props) - } - } + return React.createElement('i', props); + }, + }, } ) ), '

a, a

', 'should *not* support overwriting components in exports' - ) + ); try { renderToStaticMarkup( React.createElement( await run(compileSync('export var X = () => \n\n')) ) - ) - assert.unreachable() + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /Y is not defined/, 'should throw on missing components in exported components' - ) + ); } assert.equal( @@ -327,14 +327,14 @@ test('compile', async () => { { components: { Y() { - return React.createElement('span', {}, '!') - } - } + return React.createElement('span', {}, '!'); + }, + }, }, React.createElement( await run( compileSync('export var X = () => \n\n', { - providerImportSource: '@mdx-js/react' + providerImportSource: '@mdx-js/react', }) ) ) @@ -342,7 +342,7 @@ test('compile', async () => { ), '!', 'should support provided components in exported components' - ) + ); assert.equal( renderToStaticMarkup( @@ -356,7 +356,7 @@ test('compile', async () => { ), '
a
', 'should support custom components in exported components' - ) + ); assert.equal( renderToStaticMarkup( @@ -366,15 +366,15 @@ test('compile', async () => { components: { y: { z() { - return React.createElement('span', {}, '!') - } - } - } + return React.createElement('span', {}, '!'); + }, + }, + }, }, React.createElement( await run( compileSync('export var X = () => \n\n', { - providerImportSource: '@mdx-js/react' + providerImportSource: '@mdx-js/react', }) ) ) @@ -382,7 +382,7 @@ test('compile', async () => { ), '!', 'should support provided component objects in exported components' - ) + ); assert.equal( renderToStaticMarkup( @@ -392,15 +392,15 @@ test('compile', async () => { * @param {Record} props */ wrapper(props) { - const {components, ...rest} = props - return React.createElement('div', rest) - } - } + const { components, ...rest } = props; + return React.createElement('div', rest); + }, + }, }) ), '

a

', 'should support setting the layout by passing it (as `wrapper`) to `MDXContent`' - ) + ); assert.equal( renderToStaticMarkup( @@ -414,7 +414,7 @@ test('compile', async () => { ), '

a

', 'should support setting the layout through a class component' - ) + ); assert.equal( renderToStaticMarkup( @@ -430,73 +430,75 @@ test('compile', async () => { * @param {Record} props */ wrapper(props) { - const {components, ...rest} = props - return React.createElement('article', rest) - } - } + const { components, ...rest } = props; + return React.createElement('article', rest); + }, + }, } ) ), '

a

', 'should *not* support overwriting the layout by passing one (as `wrapper`) to `MDXContent`' - ) + ); assert.throws( () => { compileSync( 'export default function a() {}\n\nexport default function b() {}\n\n.' - ) + ); }, /Cannot specify multiple layouts \(previous: 1:1-1:31\)/, 'should *not* support multiple layouts (1)' - ) + ); assert.throws( () => { compileSync( 'export default function a() {}\n\nexport {Layout as default} from "./components.js"\n\n.' - ) + ); }, /Cannot specify multiple layouts \(previous: 1:1-1:31\)/, 'should *not* support multiple layouts (2)' - ) + ); try { renderToStaticMarkup( React.createElement(await run(compileSync('export default a'))) - ) - assert.unreachable() + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.equal( exception.message, 'a is not defined', 'should support an identifier as an export default' - ) + ); } try { - renderToStaticMarkup(React.createElement(await run(compileSync('')))) - assert.unreachable() + renderToStaticMarkup(React.createElement(await run(compileSync('')))); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /Expected component `X` to be defined/, 'should throw if a required component is not passed' - ) + ); } try { - renderToStaticMarkup(React.createElement(await run(compileSync('')))) - assert.unreachable() + renderToStaticMarkup( + React.createElement(await run(compileSync(''))) + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /Expected object `a` to be defined/, 'should throw if a required member is not passed' - ) + ); } try { @@ -504,15 +506,15 @@ test('compile', async () => { React.createElement( await run(compileSync('export const a = {}\n\n')) ) - ) - assert.unreachable() + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /Expected component `a.b` to be defined/, 'should throw if a used member is not defined locally' - ) + ); } try { @@ -520,18 +522,18 @@ test('compile', async () => { React.createElement( await run(compileSync(' } />')) ) - ) - assert.unreachable() + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /Expected object `x` to be defined/, 'should throw if a used member is not defined locally (JSX in a function)' - ) + ); } - console.log('\nnote: the following warning is expected!\n') + console.log('\nnote: the following warning is expected!\n'); assert.equal( renderToStaticMarkup( React.createElement( @@ -540,38 +542,40 @@ test('compile', async () => { ), '', 'should render if a used member is defined locally (JSX in a function)' - ) - console.log('\nnote: the preceding warning is expected!\n') + ); + console.log('\nnote: the preceding warning is expected!\n'); const developmentSourceNode = ( await run( compileSync( - {value: '
', path: 'path/to/file.js'}, - {development: true} + { value: '
', path: 'path/to/file.js' }, + { development: true } ).value ) - )({}) + )({}); assert.equal( // @ts-expect-error React attaches source information on this property, // but it’s private and untyped. developmentSourceNode._source, - {fileName: 'path/to/file.js', lineNumber: 1, columnNumber: 1}, + { fileName: 'path/to/file.js', lineNumber: 1, columnNumber: 1 }, 'should expose source information in the automatic jsx dev runtime' - ) + ); try { renderToStaticMarkup( - React.createElement(await run(compileSync('', {development: true}))) - ) - assert.unreachable() + React.createElement( + await run(compileSync('', { development: true })) + ) + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /It’s referenced in your code at `1:1-1:6/, 'should pass more info to errors w/ `development: true`' - ) + ); } try { @@ -579,20 +583,20 @@ test('compile', async () => { React.createElement( await run( compileSync( - {value: 'asd ', path: 'folder/example.mdx'}, - {development: true} + { value: 'asd ', path: 'folder/example.mdx' }, + { development: true } ) ) ) - ) - assert.unreachable() + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /It’s referenced in your code at `1:5-1:12` in `folder\/example.mdx`/, 'should show what file contains the error w/ `development: true`, and `path`' - ) + ); } assert.equal( @@ -602,33 +606,37 @@ test('compile', async () => { { components: { em(props) { - return React.createElement('i', props) - } - } + return React.createElement('i', props); + }, + }, }, React.createElement( - await run(compileSync('*z*', {providerImportSource: '@mdx-js/react'})) + await run( + compileSync('*z*', { providerImportSource: '@mdx-js/react' }) + ) ) ) ), '

z

', 'should support setting components through context with a `providerImportSource`' - ) + ); try { renderToStaticMarkup( React.createElement( - await run(compileSync('', {providerImportSource: '@mdx-js/react'})) + await run( + compileSync('', { providerImportSource: '@mdx-js/react' }) + ) ) - ) - assert.unreachable() + ); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.match( exception.message, /Expected component `X` to be defined/, 'should throw if a required component is not passed or given to `MDXProvider`' - ) + ); } assert.equal( @@ -637,113 +645,117 @@ test('compile', async () => { ), '

x

', 'should support `createProcessor`' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(createProcessor({format: 'md'}).processSync('\tx')) + await run(createProcessor({ format: 'md' }).processSync('\tx')) ) ), '
x\n
', 'should support `format: md`' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(createProcessor({format: 'mdx'}).processSync('\tx')) + await run(createProcessor({ format: 'mdx' }).processSync('\tx')) ) ), '

x

', 'should support `format: mdx`' - ) + ); try { // @ts-expect-error incorrect `detect`. - createProcessor({format: 'detect'}) - assert.unreachable() + createProcessor({ format: 'detect' }); + assert.unreachable(); } catch (/** @type {unknown} */ error) { - const exception = /** @type {Error} */ (error) + const exception = /** @type {Error} */ (error); assert.equal( exception.message, "Incorrect `format: 'detect'`: `createProcessor` can support either `md` or `mdx`; it does not support detecting the format", 'should not support `format: detect`' - ) + ); } assert.equal( renderToStaticMarkup( - React.createElement(await run(await compile({value: '\tx'}))) + React.createElement(await run(await compile({ value: '\tx' }))) ), '

x

', 'should detect as `mdx` by default' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(await compile({value: '\tx', path: 'y.md'})) + await run(await compile({ value: '\tx', path: 'y.md' })) ) ), '
x\n
', 'should detect `.md` as `md`' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(await compile({value: '\tx', path: 'y.mdx'})) + await run(await compile({ value: '\tx', path: 'y.mdx' })) ) ), '

x

', 'should detect `.mdx` as `mdx`' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(await compile({value: '\tx', path: 'y.md'}, {format: 'mdx'})) + await run( + await compile({ value: '\tx', path: 'y.md' }, { format: 'mdx' }) + ) ) ), '

x

', 'should not “detect” `.md` w/ `format: mdx`' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(await compile({value: '\tx', path: 'y.mdx'}, {format: 'md'})) + await run( + await compile({ value: '\tx', path: 'y.mdx' }, { format: 'md' }) + ) ) ), '
x\n
', 'should not “detect” `.mdx` w/ `format: md`' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(await compile({value: 'r', path: 's.md'})) + await run(await compile({ value: 'r', path: 's.md' })) ) ), '

r

', 'should not support HTML in markdown by default' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( await run( await compile( - {value: 'r', path: 's.md'}, - {rehypePlugins: [rehypeRaw]} + { value: 'r', path: 's.md' }, + { rehypePlugins: [rehypeRaw] } ) ) ) ), '

r

', 'should support HTML in markdown w/ `rehype-raw`' - ) + ); assert.match( String( @@ -766,28 +778,28 @@ test('compile', async () => { declarations: [ { type: 'VariableDeclarator', - id: {type: 'Identifier', name: 'a'}, - init: {type: 'Literal', value: 1} - } - ] - } - ] - } - } - }) - } + id: { type: 'Identifier', name: 'a' }, + init: { type: 'Literal', value: 1 }, + }, + ], + }, + ], + }, + }, + }); + }, ], - rehypePlugins: [[rehypeRaw, {passThrough: nodeTypes}]] + rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }]], }) ), /var a = 1/, 'should support injected MDX nodes w/ `rehype-raw`' - ) -}) + ); +}); test('jsx', async () => { assert.equal( - String(compileSync('*a*', {jsx: true})), + String(compileSync('*a*', { jsx: true })), [ '/*@jsxRuntime automatic @jsxImportSource react*/', 'function _createMdxContent(props) {', @@ -802,13 +814,13 @@ test('jsx', async () => { ' return MDXLayout ? <_createMdxContent {...props} /> : _createMdxContent(props);', '}', 'export default MDXContent;', - '' + '', ].join('\n'), 'should serialize JSX w/ `jsx: true`' - ) + ); assert.equal( - String(compileSync('', {jsx: true})), + String(compileSync('', { jsx: true })), [ '/*@jsxRuntime automatic @jsxImportSource react*/', 'function _createMdxContent(props) {', @@ -819,13 +831,13 @@ test('jsx', async () => { ' return MDXLayout ? <_createMdxContent {...props} /> : _createMdxContent(props);', '}', 'export default MDXContent;', - '' + '', ].join('\n'), 'should serialize props' - ) + ); assert.equal( - String(compileSync('<>', {jsx: true})), + String(compileSync('<>', { jsx: true })), [ '/*@jsxRuntime automatic @jsxImportSource react*/', 'function _createMdxContent(props) {', @@ -842,13 +854,13 @@ test('jsx', async () => { 'function _missingMdxReference(id, component) {', ' throw new Error("Expected " + (component ? "component" : "object") + " `" + id + "` to be defined: you likely forgot to import, pass, or provide it.");', '}', - '' + '', ].join('\n'), 'should serialize fragments, namespaces, members' - ) + ); assert.equal( - String(compileSync('<>a {/* 1 */} b', {jsx: true})), + String(compileSync('<>a {/* 1 */} b', { jsx: true })), [ '/*@jsxRuntime automatic @jsxImportSource react*/', '/*1*/', @@ -860,13 +872,13 @@ test('jsx', async () => { ' return MDXLayout ? <_createMdxContent {...props} /> : _createMdxContent(props);', '}', 'export default MDXContent;', - '' + '', ].join('\n'), 'should serialize fragments, expressions' - ) + ); assert.equal( - String(compileSync('{}', {jsx: true})), + String(compileSync('{}', { jsx: true })), [ '/*@jsxRuntime automatic @jsxImportSource react*/', 'function _createMdxContent(props) {', @@ -880,13 +892,13 @@ test('jsx', async () => { ' return MDXLayout ? <_createMdxContent {...props} /> : _createMdxContent(props);', '}', 'export default MDXContent;', - '' + '', ].join('\n'), 'should serialize custom elements inside expressions' - ) + ); assert.equal( - String(compileSync('Hello {props.name}', {jsx: true})), + String(compileSync('Hello {props.name}', { jsx: true })), [ '/*@jsxRuntime automatic @jsxImportSource react*/', 'function _createMdxContent(props) {', @@ -900,16 +912,16 @@ test('jsx', async () => { ' return MDXLayout ? <_createMdxContent {...props} /> : _createMdxContent(props);', '}', 'export default MDXContent;', - '' + '', ].join('\n'), 'should allow using props' - ) + ); assert.equal( String( compileSync( 'export default function Layout({components, ...props}) { return
}\n\na', - {jsx: true} + { jsx: true } ) ), [ @@ -927,30 +939,30 @@ test('jsx', async () => { ' return <_createMdxContent {...props} />;', '}', 'export default MDXContent;', - '' + '', ].join('\n'), 'should not have a conditional expression for MDXLayout when there is an internal layout' - ) + ); assert.match( - String(compileSync("{}", {jsx: true})), + String(compileSync("{}", { jsx: true })), /x="y " z"/, 'should serialize double quotes in attribute values' - ) + ); assert.match( - String(compileSync('{<>a & b { c < d}', {jsx: true})), + String(compileSync('{<>a & b { c < d}', { jsx: true })), /a & b { c < d/, 'should serialize `<` and `{` in JSX text' - ) -}) + ); +}); test('markdown (CM)', async () => { assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('[a](b)')))), '

a

', 'should support links (resource) (`[]()` -> `a`)' - ) + ); assert.equal( renderToStaticMarkup( @@ -958,122 +970,122 @@ test('markdown (CM)', async () => { ), '

a

', 'should support links (reference) (`[][]` -> `a`)' - ) + ); assert.throws( () => { - compileSync('') + compileSync(''); }, /note: to create a link in MDX, use `\[text]\(url\)/, 'should *not* support links (autolink) (`` -> error)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('> a')))), '
\n

a

\n
', 'should support block quotes (`>` -> `blockquote`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('\\*a*')))), '

*a*

', 'should support characters (escape) (`\\` -> ``)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('<')))), '

<

', 'should support character (reference) (`<` -> `<`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('```\na')))), '
a\n
', 'should support code (fenced) (` ``` ` -> `pre code`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync(' a')))), '

a

', 'should *not* support code (indented) (`\\ta` -> `p`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('`a`')))), '

a

', 'should support code (text) (`` `a` `` -> `code`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('*a*')))), '

a

', 'should support emphasis (`*` -> `em`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('a\\\nb')))), '

a
\nb

', 'should support hard break (escape) (`\\\\\\n` -> `
`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('a \nb')))), '

a
\nb

', 'should support hard break (whitespace) (`\\\\\\n` -> `
`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('#')))), '

', 'should support headings (atx) (`#` -> `

`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('a\n=')))), '

a

', 'should support headings (setext) (`=` -> `

`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('1.')))), '
    \n
  1. \n
', 'should support list (ordered) (`1.` -> `
  1. `)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('*')))), '
      \n
    • \n
    ', 'should support list (unordered) (`*` -> `
    • `)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('**a**')))), '

      a

      ', 'should support strong (`**` -> `strong`)' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('***')))), '
      ', 'should support thematic break (`***` -> `
      `)' - ) -}) + ); +}); test('markdown (GFM, with `remark-gfm`)', async () => { assert.equal( renderToStaticMarkup( React.createElement( - await run(compileSync('http://a', {remarkPlugins: [remarkGfm]})) + await run(compileSync('http://a', { remarkPlugins: [remarkGfm] })) ) ), '

      http://a

      ', 'should support links (autolink literal) (`http://a` -> `a`)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(compileSync('[^a]\n[^a]: b', {remarkPlugins: [remarkGfm]})) + await run(compileSync('[^a]\n[^a]: b', { remarkPlugins: [remarkGfm] })) ) ), `

      1

      @@ -1085,66 +1097,70 @@ test('markdown (GFM, with `remark-gfm`)', async () => {

`, 'should support footnotes (`[^a]` -> ``)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(compileSync('| a |\n| - |', {remarkPlugins: [remarkGfm]})) + await run(compileSync('| a |\n| - |', { remarkPlugins: [remarkGfm] })) ) ), '
a
', 'should support tables (`| a |` -> `...`)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(compileSync('* [x] a\n* [ ] b', {remarkPlugins: [remarkGfm]})) + await run( + compileSync('* [x] a\n* [ ] b', { remarkPlugins: [remarkGfm] }) + ) ) ), '
    \n
  • a
  • \n
  • b
  • \n
', 'should support task lists (`* [x]` -> `input`)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - await run(compileSync('~a~', {remarkPlugins: [remarkGfm]})) + await run(compileSync('~a~', { remarkPlugins: [remarkGfm] })) ) ), '

a

', 'should support strikethrough (`~` -> `del`)' - ) -}) + ); +}); test('markdown (frontmatter, `remark-frontmatter`)', async () => { assert.equal( renderToStaticMarkup( React.createElement( await run( - compileSync('---\na: b\n---\nc', {remarkPlugins: [remarkFrontmatter]}) + compileSync('---\na: b\n---\nc', { + remarkPlugins: [remarkFrontmatter], + }) ) ) ), '

c

', 'should support frontmatter (YAML)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( await run( compileSync('+++\na: b\n+++\nc', { - remarkPlugins: [[remarkFrontmatter, 'toml']] + remarkPlugins: [[remarkFrontmatter, 'toml']], }) ) ) ), '

c

', 'should support frontmatter (TOML)' - ) -}) + ); +}); test('markdown (math, `remark-math`, `rehype-katex`)', async () => { assert.match( @@ -1153,15 +1169,15 @@ test('markdown (math, `remark-math`, `rehype-katex`)', async () => { await run( compileSync('$C_L$', { remarkPlugins: [remarkMath], - rehypePlugins: [rehypeKatex] + rehypePlugins: [rehypeKatex], }) ) ) ), / { assert.equal( @@ -1172,8 +1188,8 @@ test('remark-rehype options', async () => { remarkPlugins: [remarkGfm], remarkRehypeOptions: { footnoteLabel: 'Notes', - footnoteBackLabel: 'Back' - } + footnoteBackLabel: 'Back', + }, }) ) ) @@ -1187,8 +1203,8 @@ test('remark-rehype options', async () => { `, 'should pass options to remark-rehype' - ) -}) + ); +}); // See test('should support custom elements with layouts', async () => { @@ -1205,19 +1221,19 @@ test('should support custom elements with layouts', async () => { type: 'element', tagName: 'custom-element', properties: {}, - children: [] - }) - } - } - ] + children: [], + }); + }; + }, + ], }) ) ) ), '', 'should not crash if element names are used that are not valid JavaScript identifiers, with layouts' - ) -}) + ); +}); test('MDX (JSX)', async () => { assert.equal( @@ -1226,7 +1242,7 @@ test('MDX (JSX)', async () => { ), '

a b

', 'should support JSX (text)' - ) + ); assert.equal( renderToStaticMarkup( @@ -1234,7 +1250,7 @@ test('MDX (JSX)', async () => { ), '

b

', 'should support JSX (flow)' - ) + ); assert.equal( renderToStaticMarkup( @@ -1242,7 +1258,7 @@ test('MDX (JSX)', async () => { ), '

b

', 'should unravel JSX (text) as an only child' - ) + ); assert.equal( renderToStaticMarkup( @@ -1250,7 +1266,7 @@ test('MDX (JSX)', async () => { ), 'b\nc', 'should unravel JSX (text) as only children' - ) + ); assert.equal( renderToStaticMarkup( @@ -1258,19 +1274,19 @@ test('MDX (JSX)', async () => { ), 'b\n\t\nc', 'should unravel JSX (text) and whitespace as only children' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('{1}')))), '1', 'should unravel expression (text) as an only child' - ) + ); assert.equal( renderToStaticMarkup(React.createElement(await run(compileSync('{1}{2}')))), '1\n2', 'should unravel expression (text) as only children' - ) + ); assert.equal( renderToStaticMarkup( @@ -1278,7 +1294,7 @@ test('MDX (JSX)', async () => { ), '1\n2', 'should unravel expression (text) and whitespace as only children' - ) + ); assert.equal( renderToStaticMarkup( @@ -1286,7 +1302,7 @@ test('MDX (JSX)', async () => { ), '

a b

', 'should support JSX (text, fragment)' - ) + ); assert.equal( renderToStaticMarkup( @@ -1294,7 +1310,7 @@ test('MDX (JSX)', async () => { ), '

b

', 'should support JSX (flow, fragment)' - ) + ); assert.equal( renderToStaticMarkup( @@ -1302,7 +1318,7 @@ test('MDX (JSX)', async () => { ), '

a b

', 'should support JSX (namespace)' - ) + ); assert.equal( renderToStaticMarkup( @@ -1310,7 +1326,7 @@ test('MDX (JSX)', async () => { ), '

a 1

', 'should support expressions in MDX (text)' - ) + ); assert.equal( renderToStaticMarkup( @@ -1318,7 +1334,7 @@ test('MDX (JSX)', async () => { ), '2', 'should support expressions in MDX (flow)' - ) + ); assert.equal( renderToStaticMarkup( @@ -1326,7 +1342,7 @@ test('MDX (JSX)', async () => { ), '', 'should support empty expressions in MDX' - ) + ); assert.equal( renderToStaticMarkup( @@ -1334,7 +1350,7 @@ test('MDX (JSX)', async () => { ), '', 'should support JSX attribute names' - ) + ); assert.equal( renderToStaticMarkup( @@ -1344,7 +1360,7 @@ test('MDX (JSX)', async () => { ), '', 'should support JSX attribute values' - ) + ); assert.equal( renderToStaticMarkup( @@ -1352,7 +1368,7 @@ test('MDX (JSX)', async () => { ), '', 'should support JSX spread attributes' - ) + ); assert.equal( renderToStaticMarkup( @@ -1362,8 +1378,8 @@ test('MDX (JSX)', async () => { ), 'the sum of one and one is: 2', 'should support JSX in expressions' - ) -}) + ); +}); test('MDX (ESM)', async () => { assert.equal( @@ -1376,7 +1392,7 @@ test('MDX (ESM)', async () => { ), '!', 'should support importing components w/ ESM' - ) + ); assert.equal( renderToStaticMarkup( @@ -1386,18 +1402,18 @@ test('MDX (ESM)', async () => { ), '3.14', 'should support importing data w/ ESM' - ) + ); assert.equal( (await runWhole(compileSync('export const number = Math.PI'))).number, Math.PI, 'should support exporting w/ ESM' - ) + ); assert.ok( 'a' in (await runWhole(compileSync('export var a'))), 'should support exporting an identifier w/o a value' - ) + ); assert.equal( ( @@ -1407,7 +1423,7 @@ test('MDX (ESM)', async () => { ).a, 1, 'should support exporting an object pattern' - ) + ); assert.equal( ( @@ -1417,9 +1433,9 @@ test('MDX (ESM)', async () => { ) ) ).rest, - {b: 2}, + { b: 2 }, 'should support exporting a rest element in an object pattern' - ) + ); assert.equal( ( @@ -1431,7 +1447,7 @@ test('MDX (ESM)', async () => { ).c, 3, 'should support exporting an assignment pattern in an object pattern' - ) + ); assert.equal( ( @@ -1441,7 +1457,7 @@ test('MDX (ESM)', async () => { ).a, 1, 'should support exporting an array pattern' - ) + ); assert.equal( ( @@ -1451,7 +1467,7 @@ test('MDX (ESM)', async () => { ).pi, Math.PI, 'should support `export as` w/ ESM' - ) + ); assert.equal( renderToStaticMarkup( @@ -1465,7 +1481,7 @@ test('MDX (ESM)', async () => { ), '

a

', 'should support default export to define a layout' - ) + ); assert.equal( renderToStaticMarkup( @@ -1477,7 +1493,7 @@ test('MDX (ESM)', async () => { ), '

a

', 'should support default export from a source' - ) + ); assert.equal( renderToStaticMarkup( @@ -1487,7 +1503,7 @@ test('MDX (ESM)', async () => { ), '

a

', 'should support rexporting something as a default export from a source' - ) + ); assert.equal( renderToStaticMarkup( @@ -1497,7 +1513,7 @@ test('MDX (ESM)', async () => { ), '

a

', 'should support rexporting the default export from a source' - ) + ); assert.equal( renderToStaticMarkup( @@ -1507,7 +1523,7 @@ test('MDX (ESM)', async () => { ), '

a

', 'should support rexporting the default export from a source' - ) + ); assert.equal( renderToStaticMarkup( @@ -1519,11 +1535,13 @@ test('MDX (ESM)', async () => { ), '

a

', 'should support rexporting the default export, and other things, from a source' - ) + ); assert.equal( - compileSync({value: '', path: 'path/to/file.js'}, {development: true}) - .value, + compileSync( + { value: '', path: 'path/to/file.js' }, + { development: true } + ).value, [ '/*@jsxRuntime automatic @jsxImportSource react*/', 'import {jsxDEV as _jsxDEV} from "react/jsx-dev-runtime";', @@ -1550,51 +1568,51 @@ test('MDX (ESM)', async () => { 'function _missingMdxReference(id, component, place) {', ' throw new Error("Expected " + (component ? "component" : "object") + " `" + id + "` to be defined: you likely forgot to import, pass, or provide it." + (place ? "\\nIt’s referenced in your code at `" + place + "` in `path/to/file.js`" : ""));', '}', - '' + '', ].join('\n'), 'should support the jsx dev runtime' - ) -}) + ); +}); test('source maps', async () => { - const base = path.resolve(path.join('test', 'context')) + const base = path.resolve(path.join('test', 'context')); const file = await compile( 'export function Component() {\n a()\n}\n\n', - {SourceMapGenerator} - ) + { SourceMapGenerator } + ); file.value += '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' + Buffer.from(JSON.stringify(file.map)).toString('base64') + - '\n' + '\n'; - await fs.writeFile(path.join(base, 'sourcemap.js'), String(file)) + await fs.writeFile(path.join(base, 'sourcemap.js'), String(file)); const Content = /** @type {MDXContent} */ ( /* @ts-expect-error file is dynamically generated */ (await import('./context/sourcemap.js')).default // type-coverage:ignore-line - ) + ); try { - renderToStaticMarkup(React.createElement(Content)) - assert.unreachable() + renderToStaticMarkup(React.createElement(Content)); + assert.unreachable(); } catch (error) { - const exception = /** @type {Error} */ (error) - const match = /at Component \(file:([^)]+)\)/.exec(String(exception.stack)) + const exception = /** @type {Error} */ (error); + const match = /at Component \(file:([^)]+)\)/.exec(String(exception.stack)); const place = - path.posix.join(...base.split(path.sep), 'unknown.mdx') + ':2:3' + path.posix.join(...base.split(path.sep), 'unknown.mdx') + ':2:3'; assert.equal( match && match[1].slice(-place.length), place, 'should support source maps' - ) + ); } - await fs.unlink(path.join(base, 'sourcemap.js')) -}) + await fs.unlink(path.join(base, 'sourcemap.js')); +}); -test.run() +test.run(); /** * @@ -1602,7 +1620,7 @@ test.run() * @return {Promise} */ async function run(input) { - return (await runWhole(input)).default + return (await runWhole(input)).default; } /** @@ -1611,18 +1629,18 @@ async function run(input) { * @return {Promise} */ async function runWhole(input) { - const name = 'fixture-' + nanoid().toLowerCase() + '.js' - const fp = path.join('test', 'context', name) - const doc = String(input) + const name = 'fixture-' + nanoid().toLowerCase() + '.js'; + const fp = path.join('test', 'context', name); + const doc = String(input); - await fs.writeFile(fp, doc) + await fs.writeFile(fp, doc); try { /** @type {MDXModule} */ - return await import('./context/' + name) + return await import('./context/' + name); } finally { // This is not a bug: the `finally` runs after the whole `try` block, but // before the `return`. - await fs.unlink(fp) + await fs.unlink(fp); } } diff --git a/packages/orgx/test/context/components.js b/packages/orgx/test/context/components.js index d3fcfb3..b6d5459 100644 --- a/packages/orgx/test/context/components.js +++ b/packages/orgx/test/context/components.js @@ -1,17 +1,17 @@ -import React from 'react' +import React from 'react'; /** * @param {Record} props */ export function Pill(props) { - return React.createElement('span', {...props, style: {color: 'red'}}) + return React.createElement('span', { ...props, style: { color: 'red' } }); } /** * @param {Record} props */ export function Layout(props) { - return React.createElement('div', {...props, style: {color: 'red'}}) + return React.createElement('div', { ...props, style: { color: 'red' } }); } -export default Layout +export default Layout; diff --git a/packages/orgx/test/context/data.js b/packages/orgx/test/context/data.js index aa333f1..5a45584 100644 --- a/packages/orgx/test/context/data.js +++ b/packages/orgx/test/context/data.js @@ -1,7 +1,7 @@ -export const number = 3.14 +export const number = 3.14; -export const object = {a: 1, b: 2} +export const object = { a: 1, b: 2 }; -export const array = [1, 2] +export const array = [1, 2]; -export default 2 * number +export default 2 * number; diff --git a/packages/orgx/test/evaluate.js b/packages/orgx/test/evaluate.js index 2e04151..da20a57 100644 --- a/packages/orgx/test/evaluate.js +++ b/packages/orgx/test/evaluate.js @@ -1,58 +1,58 @@ -import {test} from 'uvu' -import * as assert from 'uvu/assert' -import {evaluate, evaluateSync, compile} from '../index.js' +import { test } from 'uvu'; +import * as assert from 'uvu/assert'; +import { evaluate, evaluateSync, compile } from '../index.js'; // @ts-expect-error: make sure a single react is used. -import {renderToStaticMarkup as renderToStaticMarkup_} from '../../react/node_modules/react-dom/server.js' +import { renderToStaticMarkup as renderToStaticMarkup_ } from '../../react/node_modules/react-dom/server.js'; // @ts-expect-error: make sure a single react is used. -import * as runtime_ from '../../react/node_modules/react/jsx-runtime.js' +import * as runtime_ from '../../react/node_modules/react/jsx-runtime.js'; // @ts-expect-error: make sure a single react is used. -import * as devRuntime from '../../react/node_modules/react/jsx-dev-runtime.js' +import * as devRuntime from '../../react/node_modules/react/jsx-dev-runtime.js'; // @ts-expect-error: make sure a single react is used. -import React_ from '../../react/node_modules/react/index.js' -import * as provider from '../../react/index.js' +import React_ from '../../react/node_modules/react/index.js'; +import * as provider from '../../react/index.js'; /** @type {import('react-dom/server').renderToStaticMarkup} */ -const renderToStaticMarkup = renderToStaticMarkup_ +const renderToStaticMarkup = renderToStaticMarkup_; /** @type {{Fragment: unknown, jsx: unknown, jsxs: unknown}} */ -const runtime = runtime_ +const runtime = runtime_; /** @type {import('react')} */ -const React = React_ +const React = React_; test('evaluate', async () => { assert.throws( () => { // @ts-expect-error: missing required arguments - evaluateSync('a') + evaluateSync('a'); }, /Expected `Fragment` given to `evaluate`/, 'should throw on missing `Fragment`' - ) + ); assert.throws( () => { - evaluateSync('a', {Fragment: runtime.Fragment}) + evaluateSync('a', { Fragment: runtime.Fragment }); }, /Expected `jsx` given to `evaluate`/, 'should throw on missing `jsx`' - ) + ); assert.throws( () => { - evaluateSync('a', {Fragment: runtime.Fragment, jsx: runtime.jsx}) + evaluateSync('a', { Fragment: runtime.Fragment, jsx: runtime.jsx }); }, /Expected `jsxs` given to `evaluate`/, 'should throw on missing `jsxs`' - ) + ); assert.throws( () => { - evaluateSync('a', {Fragment: runtime.Fragment, development: true}) + evaluateSync('a', { Fragment: runtime.Fragment, development: true }); }, /Expected `jsxDEV` given to `evaluate`/, 'should throw on missing `jsxDEV` in dev mode' - ) + ); assert.equal( renderToStaticMarkup( @@ -60,7 +60,7 @@ test('evaluate', async () => { ), '

hi!

', 'should evaluate' - ) + ); assert.equal( renderToStaticMarkup( @@ -68,28 +68,28 @@ test('evaluate', async () => { ), '

hi!

', 'should evaluate (sync)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - (await evaluate('# hi dev!', {development: true, ...devRuntime})) + (await evaluate('# hi dev!', { development: true, ...devRuntime })) .default ) ), '

hi dev!

', 'should evaluate (sync)' - ) + ); assert.equal( renderToStaticMarkup( React.createElement( - evaluateSync('# hi dev!', {development: true, ...devRuntime}).default + evaluateSync('# hi dev!', { development: true, ...devRuntime }).default ) ), '

hi dev!

', 'should evaluate (sync)' - ) + ); assert.equal( renderToStaticMarkup( @@ -97,14 +97,14 @@ test('evaluate', async () => { ( await evaluate( 'import {number} from "./context/data.js"\n\n{number}', - {baseUrl: import.meta.url, useDynamicImport: true, ...runtime} + { baseUrl: import.meta.url, useDynamicImport: true, ...runtime } ) ).default ) ), '3.14', 'should support an `import` of a relative url w/ `useDynamicImport`' - ) + ); assert.equal( renderToStaticMarkup( @@ -114,36 +114,36 @@ test('evaluate', async () => { 'import {number} from "' + new URL('context/data.js', import.meta.url) + '"\n\n{number}', - {baseUrl: import.meta.url, useDynamicImport: true, ...runtime} + { baseUrl: import.meta.url, useDynamicImport: true, ...runtime } ) ).default ) ), '3.14', 'should support an `import` of a full url w/ `useDynamicImport`' - ) + ); assert.match( String( await compile('import "a"', { outputFormat: 'function-body', - useDynamicImport: true + useDynamicImport: true, }) ), /\nawait import\("a"\);?\n/, 'should support an `import` w/o specifiers w/ `useDynamicImport`' - ) + ); assert.match( String( await compile('import {} from "a"', { outputFormat: 'function-body', - useDynamicImport: true + useDynamicImport: true, }) ), /\nawait import\("a"\);?\n/, 'should support an `import` w/ 0 specifiers w/ `useDynamicImport`' - ) + ); assert.equal( renderToStaticMarkup( @@ -151,14 +151,14 @@ test('evaluate', async () => { ( await evaluate( 'import * as x from "./context/components.js"\n\nHi!', - {baseUrl: import.meta.url, useDynamicImport: true, ...runtime} + { baseUrl: import.meta.url, useDynamicImport: true, ...runtime } ) ).default ) ), 'Hi!', 'should support a namespace import w/ `useDynamicImport`' - ) + ); assert.equal( renderToStaticMarkup( @@ -166,62 +166,62 @@ test('evaluate', async () => { ( await evaluate( 'import Div, * as x from "./context/components.js"\n\na and
b
', - {baseUrl: import.meta.url, useDynamicImport: true, ...runtime} + { baseUrl: import.meta.url, useDynamicImport: true, ...runtime } ) ).default ) ), '

a and

b

', 'should support a namespace import and a bare specifier w/ `useDynamicImport`' - ) + ); - let mod = await evaluate('export const a = 1\n\n{a}', runtime) + let mod = await evaluate('export const a = 1\n\n{a}', runtime); assert.equal( renderToStaticMarkup(React.createElement(mod.default)), '1', 'should support an `export` (1)' - ) + ); - assert.equal(mod.a, 1, 'should support an `export` (2)') + assert.equal(mod.a, 1, 'should support an `export` (2)'); - mod = await evaluate('export function a() { return 1 }\n\n{a()}', runtime) + mod = await evaluate('export function a() { return 1 }\n\n{a()}', runtime); assert.equal( renderToStaticMarkup(React.createElement(mod.default)), '1', 'should support an `export function` (1)' - ) + ); - if (typeof mod.a !== 'function') throw new TypeError('missing function') + if (typeof mod.a !== 'function') throw new TypeError('missing function'); - assert.equal(mod.a(), 1, 'should support an `export function` (2)') + assert.equal(mod.a(), 1, 'should support an `export function` (2)'); mod = await evaluate( 'export class A { constructor() { this.b = 1 } }\n\n{new A().b}', runtime - ) + ); assert.equal( renderToStaticMarkup(React.createElement(mod.default)), '1', 'should support an `export class` (1)' - ) + ); - const A = /** @type {new () => {b: number}} */ (mod.A) - const a = new A() - assert.equal(a.b, 1, 'should support an `export class` (2)') + const A = /** @type {new () => {b: number}} */ (mod.A); + const a = new A(); + assert.equal(a.b, 1, 'should support an `export class` (2)'); - mod = await evaluate('export const a = 1\nexport {a as b}\n\n{a}', runtime) + mod = await evaluate('export const a = 1\nexport {a as b}\n\n{a}', runtime); assert.equal( renderToStaticMarkup(React.createElement(mod.default)), '1', 'should support an `export as` (1)' - ) + ); - assert.equal(mod.a, 1, 'should support an `export as` (2)') - assert.equal(mod.b, 1, 'should support an `export as` (3)') + assert.equal(mod.a, 1, 'should support an `export as` (2)'); + assert.equal(mod.b, 1, 'should support an `export as` (3)'); assert.equal( renderToStaticMarkup( @@ -236,137 +236,137 @@ test('evaluate', async () => { ), '

a

', 'should support an `export default`' - ) + ); assert.throws( () => { - evaluateSync('export {a} from "b"', runtime) + evaluateSync('export {a} from "b"', runtime); }, /Cannot use `import` or `export … from` in `evaluate` \(outputting a function body\) by default/, 'should throw on an export from' - ) + ); assert.equal( ( await evaluate('export {number} from "./context/data.js"', { baseUrl: import.meta.url, useDynamicImport: true, - ...runtime + ...runtime, }) ).number, 3.14, 'should support an `export from` w/ `useDynamicImport`' - ) + ); assert.equal( ( await evaluate( 'import {number} from "./context/data.js"\nexport {number}', - {baseUrl: import.meta.url, useDynamicImport: true, ...runtime} + { baseUrl: import.meta.url, useDynamicImport: true, ...runtime } ) ).number, 3.14, 'should support an `export` w/ `useDynamicImport`' - ) + ); assert.equal( ( await evaluate('export {number as data} from "./context/data.js"', { baseUrl: import.meta.url, useDynamicImport: true, - ...runtime + ...runtime, }) ).data, 3.14, 'should support an `export as from` w/ `useDynamicImport`' - ) + ); assert.equal( ( await evaluate('export {default as data} from "./context/data.js"', { baseUrl: import.meta.url, useDynamicImport: true, - ...runtime + ...runtime, }) ).data, 6.28, 'should support an `export default as from` w/ `useDynamicImport`' - ) + ); assert.equal( { ...(await evaluate('export * from "./context/data.js"', { baseUrl: import.meta.url, useDynamicImport: true, - ...runtime + ...runtime, })), - default: undefined + default: undefined, }, - {array: [1, 2], default: undefined, number: 3.14, object: {a: 1, b: 2}}, + { array: [1, 2], default: undefined, number: 3.14, object: { a: 1, b: 2 } }, 'should support an `export all from` w/ `useDynamicImport`' - ) + ); // I’m not sure if this makes sense, but it is how Node works. assert.equal( { ...(await evaluate( 'export {default as number} from "./context/data.js"\nexport * from "./context/data.js"', - {baseUrl: import.meta.url, useDynamicImport: true, ...runtime} + { baseUrl: import.meta.url, useDynamicImport: true, ...runtime } )), - default: undefined + default: undefined, }, - {array: [1, 2], default: undefined, number: 6.28, object: {a: 1, b: 2}}, + { array: [1, 2], default: undefined, number: 6.28, object: { a: 1, b: 2 } }, 'should support an `export all from`, but prefer explicit exports, w/ `useDynamicImport`' - ) + ); assert.equal( ( await evaluate( 'export const x = new URL("example.png", import.meta.url).href', - {baseUrl: 'https://example.com', ...runtime} + { baseUrl: 'https://example.com', ...runtime } ) ).x, 'https://example.com/example.png', 'should support rewriting `import.meta.url` w/ `baseUrl`' - ) + ); assert.throws( () => { - evaluateSync('export * from "a"', runtime) + evaluateSync('export * from "a"', runtime); }, /Cannot use `import` or `export … from` in `evaluate` \(outputting a function body\) by default/, 'should throw on an export all from' - ) + ); assert.throws( () => { - evaluateSync('import {a} from "b"', runtime) + evaluateSync('import {a} from "b"', runtime); }, /Cannot use `import` or `export … from` in `evaluate` \(outputting a function body\) by default/, 'should throw on an import' - ) + ); assert.throws( () => { - evaluateSync('import a from "b"', runtime) + evaluateSync('import a from "b"', runtime); }, /Cannot use `import` or `export … from` in `evaluate` \(outputting a function body\) by default/, 'should throw on an import default' - ) + ); assert.equal( renderToStaticMarkup( React.createElement((await evaluate('', runtime)).default, { components: { X() { - return React.createElement('span', {}, '!') - } - } + return React.createElement('span', {}, '!'); + }, + }, }) ), '!', 'should support a given components' - ) + ); assert.equal( renderToStaticMarkup( @@ -375,18 +375,18 @@ test('evaluate', async () => { { components: { X() { - return React.createElement('span', {}, '!') - } - } + return React.createElement('span', {}, '!'); + }, + }, }, React.createElement( - (await evaluate('', {...runtime, ...provider})).default + (await evaluate('', { ...runtime, ...provider })).default ) ) ), '!', 'should support a provider w/ `useMDXComponents`' - ) -}) + ); +}); -test.run() +test.run(); diff --git a/packages/uniorg-parse/src/entities.ts b/packages/uniorg-parse/src/entities.ts index 3c85cf9..03d8e9a 100644 --- a/packages/uniorg-parse/src/entities.ts +++ b/packages/uniorg-parse/src/entities.ts @@ -24,966 +24,1023 @@ export const getOrgEntity = ( }; // (json-encode org-entities) -const orgEntities: [ - string, - string, - boolean, - string, - string, - string, - string -][] = [ - // * Letters - // ** Latin - ['Agrave', '\\`{A}', false, 'À', 'A', 'À', 'À'], - ['agrave', '\\`{a}', false, 'à', 'a', 'à', 'à'], - ['Aacute', "\\'{A}", false, 'Á', 'A', 'Á', 'Á'], - ['aacute', "\\'{a}", false, 'á', 'a', 'á', 'á'], - ['Acirc', '\\^{A}', false, 'Â', 'A', 'Â', 'Â'], - ['acirc', '\\^{a}', false, 'â', 'a', 'â', 'â'], - ['Amacr', '\\bar{A}', false, 'Ā', 'A', 'Ã', 'Ã'], - ['amacr', '\\bar{a}', false, 'ā', 'a', 'ã', 'ã'], - ['Atilde', '\\~{A}', false, 'Ã', 'A', 'Ã', 'Ã'], - ['atilde', '\\~{a}', false, 'ã', 'a', 'ã', 'ã'], - ['Auml', '\\"{A}', false, 'Ä', 'Ae', 'Ä', 'Ä'], - ['auml', '\\"{a}', false, 'ä', 'ae', 'ä', 'ä'], - ['Aring', '\\AA{}', false, 'Å', 'A', 'Å', 'Å'], - ['AA', '\\AA{}', false, 'Å', 'A', 'Å', 'Å'], - ['aring', '\\aa{}', false, 'å', 'a', 'å', 'å'], - ['AElig', '\\AE{}', false, 'Æ', 'AE', 'Æ', 'Æ'], - ['aelig', '\\ae{}', false, 'æ', 'ae', 'æ', 'æ'], - ['Ccedil', '\\c{C}', false, 'Ç', 'C', 'Ç', 'Ç'], - ['ccedil', '\\c{c}', false, 'ç', 'c', 'ç', 'ç'], - ['Egrave', '\\`{E}', false, 'È', 'E', 'È', 'È'], - ['egrave', '\\`{e}', false, 'è', 'e', 'è', 'è'], - ['Eacute', "\\'{E}", false, 'É', 'E', 'É', 'É'], - ['eacute', "\\'{e}", false, 'é', 'e', 'é', 'é'], - ['Ecirc', '\\^{E}', false, 'Ê', 'E', 'Ê', 'Ê'], - ['ecirc', '\\^{e}', false, 'ê', 'e', 'ê', 'ê'], - ['Euml', '\\"{E}', false, 'Ë', 'E', 'Ë', 'Ë'], - ['euml', '\\"{e}', false, 'ë', 'e', 'ë', 'ë'], - ['Igrave', '\\`{I}', false, 'Ì', 'I', 'Ì', 'Ì'], - ['igrave', '\\`{i}', false, 'ì', 'i', 'ì', 'ì'], - ['Iacute', "\\'{I}", false, 'Í', 'I', 'Í', 'Í'], - ['iacute', "\\'{i}", false, 'í', 'i', 'í', 'í'], - ['Icirc', '\\^{I}', false, 'Î', 'I', 'Î', 'Î'], - ['icirc', '\\^{i}', false, 'î', 'i', 'î', 'î'], - ['Iuml', '\\"{I}', false, 'Ï', 'I', 'Ï', 'Ï'], - ['iuml', '\\"{i}', false, 'ï', 'i', 'ï', 'ï'], - ['Ntilde', '\\~{N}', false, 'Ñ', 'N', 'Ñ', 'Ñ'], - ['ntilde', '\\~{n}', false, 'ñ', 'n', 'ñ', 'ñ'], - ['Ograve', '\\`{O}', false, 'Ò', 'O', 'Ò', 'Ò'], - ['ograve', '\\`{o}', false, 'ò', 'o', 'ò', 'ò'], - ['Oacute', "\\'{O}", false, 'Ó', 'O', 'Ó', 'Ó'], - ['oacute', "\\'{o}", false, 'ó', 'o', 'ó', 'ó'], - ['Ocirc', '\\^{O}', false, 'Ô', 'O', 'Ô', 'Ô'], - ['ocirc', '\\^{o}', false, 'ô', 'o', 'ô', 'ô'], - ['Otilde', '\\~{O}', false, 'Õ', 'O', 'Õ', 'Õ'], - ['otilde', '\\~{o}', false, 'õ', 'o', 'õ', 'õ'], - ['Ouml', '\\"{O}', false, 'Ö', 'Oe', 'Ö', 'Ö'], - ['ouml', '\\"{o}', false, 'ö', 'oe', 'ö', 'ö'], - ['Oslash', '\\O', false, 'Ø', 'O', 'Ø', 'Ø'], - ['oslash', '\\o{}', false, 'ø', 'o', 'ø', 'ø'], - ['OElig', '\\OE{}', false, 'Œ', 'OE', 'OE', 'Œ'], - ['oelig', '\\oe{}', false, 'œ', 'oe', 'oe', 'œ'], - ['Scaron', '\\v{S}', false, 'Š', 'S', 'S', 'Š'], - ['scaron', '\\v{s}', false, 'š', 's', 's', 'š'], - ['szlig', '\\ss{}', false, 'ß', 'ss', 'ß', 'ß'], - ['Ugrave', '\\`{U}', false, 'Ù', 'U', 'Ù', 'Ù'], - ['ugrave', '\\`{u}', false, 'ù', 'u', 'ù', 'ù'], - ['Uacute', "\\'{U}", false, 'Ú', 'U', 'Ú', 'Ú'], - ['uacute', "\\'{u}", false, 'ú', 'u', 'ú', 'ú'], - ['Ucirc', '\\^{U}', false, 'Û', 'U', 'Û', 'Û'], - ['ucirc', '\\^{u}', false, 'û', 'u', 'û', 'û'], - ['Uuml', '\\"{U}', false, 'Ü', 'Ue', 'Ü', 'Ü'], - ['uuml', '\\"{u}', false, 'ü', 'ue', 'ü', 'ü'], - ['Yacute', "\\'{Y}", false, 'Ý', 'Y', 'Ý', 'Ý'], - ['yacute', "\\'{y}", false, 'ý', 'y', 'ý', 'ý'], - ['Yuml', '\\"{Y}', false, 'Ÿ', 'Y', 'Y', 'Ÿ'], - ['yuml', '\\"{y}', false, 'ÿ', 'y', 'ÿ', 'ÿ'], - // ** Latin (special face) - ['fnof', '\\textit{f}', false, 'ƒ', 'f', 'f', 'ƒ'], - ['real', '\\Re', true, 'ℜ', 'R', 'R', 'ℜ'], - ['image', '\\Im', true, 'ℑ', 'I', 'I', 'ℑ'], - ['weierp', '\\wp', true, '℘', 'P', 'P', '℘'], - ['ell', '\\ell', true, 'ℓ', 'ell', 'ell', 'ℓ'], - ['imath', '\\imath', true, 'ı', '[dotless i]', 'dotless i', 'ı'], - ['jmath', '\\jmath', true, 'ȷ', '[dotless j]', 'dotless j', 'ȷ'], - // ** Greek - ['Alpha', 'A', false, 'Α', 'Alpha', 'Alpha', 'Α'], - ['alpha', '\\alpha', true, 'α', 'alpha', 'alpha', 'α'], - ['Beta', 'B', false, 'Β', 'Beta', 'Beta', 'Β'], - ['beta', '\\beta', true, 'β', 'beta', 'beta', 'β'], - ['Gamma', '\\Gamma', true, 'Γ', 'Gamma', 'Gamma', 'Γ'], - ['gamma', '\\gamma', true, 'γ', 'gamma', 'gamma', 'γ'], - ['Delta', '\\Delta', true, 'Δ', 'Delta', 'Delta', 'Δ'], - ['delta', '\\delta', true, 'δ', 'delta', 'delta', 'δ'], - ['Epsilon', 'E', false, 'Ε', 'Epsilon', 'Epsilon', 'Ε'], - ['epsilon', '\\epsilon', true, 'ε', 'epsilon', 'epsilon', 'ε'], - [ - 'varepsilon', - '\\varepsilon', - true, - 'ε', - 'varepsilon', - 'varepsilon', - 'ε', - ], - ['Zeta', 'Z', false, 'Ζ', 'Zeta', 'Zeta', 'Ζ'], - ['zeta', '\\zeta', true, 'ζ', 'zeta', 'zeta', 'ζ'], - ['Eta', 'H', false, 'Η', 'Eta', 'Eta', 'Η'], - ['eta', '\\eta', true, 'η', 'eta', 'eta', 'η'], - ['Theta', '\\Theta', true, 'Θ', 'Theta', 'Theta', 'Θ'], - ['theta', '\\theta', true, 'θ', 'theta', 'theta', 'θ'], - ['thetasym', '\\vartheta', true, 'ϑ', 'theta', 'theta', 'ϑ'], - ['vartheta', '\\vartheta', true, 'ϑ', 'theta', 'theta', 'ϑ'], - ['Iota', 'I', false, 'Ι', 'Iota', 'Iota', 'Ι'], - ['iota', '\\iota', true, 'ι', 'iota', 'iota', 'ι'], - ['Kappa', 'K', false, 'Κ', 'Kappa', 'Kappa', 'Κ'], - ['kappa', '\\kappa', true, 'κ', 'kappa', 'kappa', 'κ'], - ['Lambda', '\\Lambda', true, 'Λ', 'Lambda', 'Lambda', 'Λ'], - ['lambda', '\\lambda', true, 'λ', 'lambda', 'lambda', 'λ'], - ['Mu', 'M', false, 'Μ', 'Mu', 'Mu', 'Μ'], - ['mu', '\\mu', true, 'μ', 'mu', 'mu', 'μ'], - ['nu', '\\nu', true, 'ν', 'nu', 'nu', 'ν'], - ['Nu', 'N', false, 'Ν', 'Nu', 'Nu', 'Ν'], - ['Xi', '\\Xi', true, 'Ξ', 'Xi', 'Xi', 'Ξ'], - ['xi', '\\xi', true, 'ξ', 'xi', 'xi', 'ξ'], - ['Omicron', 'O', false, 'Ο', 'Omicron', 'Omicron', 'Ο'], - ['omicron', '\\textit{o}', false, 'ο', 'omicron', 'omicron', 'ο'], - ['Pi', '\\Pi', true, 'Π', 'Pi', 'Pi', 'Π'], - ['pi', '\\pi', true, 'π', 'pi', 'pi', 'π'], - ['Rho', 'P', false, 'Ρ', 'Rho', 'Rho', 'Ρ'], - ['rho', '\\rho', true, 'ρ', 'rho', 'rho', 'ρ'], - ['Sigma', '\\Sigma', true, 'Σ', 'Sigma', 'Sigma', 'Σ'], - ['sigma', '\\sigma', true, 'σ', 'sigma', 'sigma', 'σ'], - ['sigmaf', '\\varsigma', true, 'ς', 'sigmaf', 'sigmaf', 'ς'], - ['varsigma', '\\varsigma', true, 'ς', 'varsigma', 'varsigma', 'ς'], - ['Tau', 'T', false, 'Τ', 'Tau', 'Tau', 'Τ'], - ['Upsilon', '\\Upsilon', true, 'Υ', 'Upsilon', 'Upsilon', 'Υ'], - ['upsih', '\\Upsilon', true, 'ϒ', 'upsilon', 'upsilon', 'ϒ'], - ['upsilon', '\\upsilon', true, 'υ', 'upsilon', 'upsilon', 'υ'], - ['Phi', '\\Phi', true, 'Φ', 'Phi', 'Phi', 'Φ'], - ['phi', '\\phi', true, 'φ', 'phi', 'phi', 'ɸ'], - ['varphi', '\\varphi', true, 'ϕ', 'varphi', 'varphi', 'φ'], - ['Chi', 'X', false, 'Χ', 'Chi', 'Chi', 'Χ'], - ['chi', '\\chi', true, 'χ', 'chi', 'chi', 'χ'], - ['acutex', '\\acute x', true, '´x', "'x", "'x", '𝑥́'], - ['Psi', '\\Psi', true, 'Ψ', 'Psi', 'Psi', 'Ψ'], - ['psi', '\\psi', true, 'ψ', 'psi', 'psi', 'ψ'], - ['tau', '\\tau', true, 'τ', 'tau', 'tau', 'τ'], - ['Omega', '\\Omega', true, 'Ω', 'Omega', 'Omega', 'Ω'], - ['omega', '\\omega', true, 'ω', 'omega', 'omega', 'ω'], - ['piv', '\\varpi', true, 'ϖ', 'omega-pi', 'omega-pi', 'ϖ'], - ['varpi', '\\varpi', true, 'ϖ', 'omega-pi', 'omega-pi', 'ϖ'], - [ - 'partial', - '\\partial', - true, - '∂', - '[partial differential]', - '[partial differential]', - '∂', - ], - // ** Hebrew - ['alefsym', '\\aleph', true, 'ℵ', 'aleph', 'aleph', 'ℵ'], - ['aleph', '\\aleph', true, 'ℵ', 'aleph', 'aleph', 'ℵ'], - ['gimel', '\\gimel', true, 'ℷ', 'gimel', 'gimel', 'ℷ'], - ['beth', '\\beth', true, 'ℶ', 'beth', 'beth', 'ב'], - ['dalet', '\\daleth', true, 'ℸ', 'dalet', 'dalet', 'ד'], - // ** Icelandic - ['ETH', '\\DH{}', false, 'Ð', 'D', 'Ð', 'Ð'], - ['eth', '\\dh{}', false, 'ð', 'dh', 'ð', 'ð'], - ['THORN', '\\TH{}', false, 'Þ', 'TH', 'Þ', 'Þ'], - ['thorn', '\\th{}', false, 'þ', 'th', 'þ', 'þ'], - // * Punctuation - // ** Dots and Marks - ['dots', '\\dots{}', false, '…', '...', '...', '…'], - ['cdots', '\\cdots{}', true, '⋯', '...', '...', '⋯'], - ['hellip', '\\dots{}', false, '…', '...', '...', '…'], - ['middot', '\\textperiodcentered{}', false, '·', '.', '·', '·'], - ['iexcl', '!`', false, '¡', '!', '¡', '¡'], - ['iquest', '?`', false, '¿', '?', '¿', '¿'], - // ** Dash-like - ['shy', '\\-', false, '­', '', '', ''], - ['ndash', '--', false, '–', '-', '-', '–'], - ['mdash', '---', false, '—', '--', '--', '—'], - // ** Quotations - ['quot', '\\textquotedbl{}', false, '"', '"', '"', '"'], - ['acute', '\\textasciiacute{}', false, '´', "'", '´', '´'], - ['ldquo', '\\textquotedblleft{}', false, '“', '"', '"', '“'], - ['rdquo', '\\textquotedblright{}', false, '”', '"', '"', '”'], - ['bdquo', '\\quotedblbase{}', false, '„', '"', '"', '„'], - ['lsquo', '\\textquoteleft{}', false, '‘', '`', '`', '‘'], - ['rsquo', '\\textquoteright{}', false, '’', "'", "'", '’'], - ['sbquo', '\\quotesinglbase{}', false, '‚', ',', ',', '‚'], - ['laquo', '\\guillemotleft{}', false, '«', '<<', '«', '«'], - ['raquo', '\\guillemotright{}', false, '»', '>>', '»', '»'], - ['lsaquo', '\\guilsinglleft{}', false, '‹', '<', '<', '‹'], - ['rsaquo', '\\guilsinglright{}', false, '›', '>', '>', '›'], - // * Other - // ** Misc. (often used) - ['circ', '\\^{}', false, 'ˆ', '^', '^', '∘'], - ['vert', '\\vert{}', true, '|', '|', '|', '|'], - ['vbar', '|', false, '|', '|', '|', '|'], - ['brvbar', '\\textbrokenbar{}', false, '¦', '|', '¦', '¦'], - ['S', '\\S', false, '§', 'paragraph', '§', '§'], - ['sect', '\\S', false, '§', 'paragraph', '§', '§'], - ['amp', '\\&', false, '&', '&', '&', '&'], - ['lt', '\\textless{}', false, '<', '<', '<', '<'], - ['gt', '\\textgreater{}', false, '>', '>', '>', '>'], - ['tilde', '\\textasciitilde{}', false, '~', '~', '~', '~'], - ['slash', '/', false, '/', '/', '/', '/'], - ['plus', '+', false, '+', '+', '+', '+'], - ['under', '\\_', false, '_', '_', '_', '_'], - ['equal', '=', false, '=', '=', '=', '='], - ['asciicirc', '\\textasciicircum{}', false, '^', '^', '^', '^'], - ['dagger', '\\textdagger{}', false, '†', '[dagger]', '[dagger]', '†'], - ['dag', '\\dag{}', false, '†', '[dagger]', '[dagger]', '†'], - [ - 'Dagger', - '\\textdaggerdbl{}', - false, - '‡', - '[doubledagger]', - '[doubledagger]', - '‡', - ], - [ - 'ddag', - '\\ddag{}', - false, - '‡', - '[doubledagger]', - '[doubledagger]', - '‡', - ], - // ** Whitespace - ['nbsp', '~', false, ' ', ' ', ' ', ' '], - ['ensp', '\\hspace*{.5em}', false, ' ', ' ', ' ', ' '], - ['emsp', '\\hspace*{1em}', false, ' ', ' ', ' ', ' '], - ['thinsp', '\\hspace*{.2em}', false, ' ', ' ', ' ', ' '], - // ** Currency - ['curren', '\\textcurrency{}', false, '¤', 'curr.', '¤', '¤'], - ['cent', '\\textcent{}', false, '¢', 'cent', '¢', '¢'], - ['pound', '\\pounds{}', false, '£', 'pound', '£', '£'], - ['yen', '\\textyen{}', false, '¥', 'yen', '¥', '¥'], - ['euro', '\\texteuro{}', false, '€', 'EUR', 'EUR', '€'], - ['EUR', '\\texteuro{}', false, '€', 'EUR', 'EUR', '€'], - ['dollar', '\\$', false, '$', '$', '$', '$'], - ['USD', '\\$', false, '$', '$', '$', '$'], - // ** Property Marks - ['copy', '\\textcopyright{}', false, '©', '(c)', '©', '©'], - ['reg', '\\textregistered{}', false, '®', '(r)', '®', '®'], - ['trade', '\\texttrademark{}', false, '™', 'TM', 'TM', '™'], - // ** Science et al. - ['minus', '\\minus', true, '−', '-', '-', '−'], - ['pm', '\\textpm{}', false, '±', '+-', '±', '±'], - ['plusmn', '\\textpm{}', false, '±', '+-', '±', '±'], - ['times', '\\texttimes{}', false, '×', '*', '×', '×'], - ['frasl', '/', false, '⁄', '/', '/', '⁄'], - ['colon', '\\colon', true, ':', ':', ':', ':'], - ['div', '\\textdiv{}', false, '÷', '/', '÷', '÷'], - ['frac12', '\\textonehalf{}', false, '½', '1/2', '½', '½'], - ['frac14', '\\textonequarter{}', false, '¼', '1/4', '¼', '¼'], - ['frac34', '\\textthreequarters{}', false, '¾', '3/4', '¾', '¾'], - [ - 'permil', - '\\textperthousand{}', - false, - '‰', - 'per thousand', - 'per thousand', - '‰', - ], - ['sup1', '\\textonesuperior{}', false, '¹', '^1', '¹', '¹'], - ['sup2', '\\texttwosuperior{}', false, '²', '^2', '²', '²'], - ['sup3', '\\textthreesuperior{}', false, '³', '^3', '³', '³'], - [ - 'radic', - '\\sqrt{\\,}', - true, - '√', - '[square root]', - '[square root]', - '√', - ], - ['sum', '\\sum', true, '∑', '[sum]', '[sum]', '∑'], - ['prod', '\\prod', true, '∏', '[product]', '[n-ary product]', '∏'], - ['micro', '\\textmu{}', false, 'µ', 'micro', 'µ', 'µ'], - ['macr', '\\textasciimacron{}', false, '¯', '[macron]', '¯', '¯'], - ['deg', '\\textdegree{}', false, '°', 'degree', '°', '°'], - ['prime', '\\prime', true, '′', "'", "'", '′'], - ['Prime', '\\prime{}\\prime', true, '″', "''", "''", '″'], - ['infin', '\\infty', true, '∞', '[infinity]', '[infinity]', '∞'], - ['infty', '\\infty', true, '∞', '[infinity]', '[infinity]', '∞'], - [ - 'prop', - '\\propto', - true, - '∝', - '[proportional to]', - '[proportional to]', - '∝', - ], - [ - 'propto', - '\\propto', - true, - '∝', - '[proportional to]', - '[proportional to]', - '∝', - ], - ['not', '\\textlnot{}', false, '¬', '[angled dash]', '¬', '¬'], - ['neg', '\\neg{}', true, '¬', '[angled dash]', '¬', '¬'], - ['land', '\\land', true, '∧', '[logical and]', '[logical and]', '∧'], - ['wedge', '\\wedge', true, '∧', '[logical and]', '[logical and]', '∧'], - ['lor', '\\lor', true, '∨', '[logical or]', '[logical or]', '∨'], - ['vee', '\\vee', true, '∨', '[logical or]', '[logical or]', '∨'], - ['cap', '\\cap', true, '∩', '[intersection]', '[intersection]', '∩'], - ['cup', '\\cup', true, '∪', '[union]', '[union]', '∪'], - ['smile', '\\smile', true, '⌣', '[cup product]', '[cup product]', '⌣'], - ['frown', '\\frown', true, '⌢', '[Cap product]', '[cap product]', '⌢'], - ['int', '\\int', true, '∫', '[integral]', '[integral]', '∫'], - [ - 'therefore', - '\\therefore', - true, - '∴', - '[therefore]', - '[therefore]', - '∴', - ], - [ - 'there4', - '\\therefore', - true, - '∴', - '[therefore]', - '[therefore]', - '∴', - ], - ['because', '\\because', true, '∵', '[because]', '[because]', '∵'], - ['sim', '\\sim', true, '∼', '~', '~', '∼'], - [ - 'cong', - '\\cong', - true, - '≅', - '[approx. equal to]', - '[approx. equal to]', - '≅', - ], - [ - 'simeq', - '\\simeq', - true, - '≅', - '[approx. equal to]', - '[approx. equal to]', - '≅', - ], - [ - 'asymp', - '\\asymp', - true, - '≈', - '[almost equal to]', - '[almost equal to]', - '≈', - ], - [ - 'approx', - '\\approx', - true, - '≈', - '[almost equal to]', - '[almost equal to]', - '≈', - ], - ['ne', '\\ne', true, '≠', '[not equal to]', '[not equal to]', '≠'], - ['neq', '\\neq', true, '≠', '[not equal to]', '[not equal to]', '≠'], - [ - 'equiv', - '\\equiv', - true, - '≡', - '[identical to]', - '[identical to]', - '≡', - ], - [ - 'triangleq', - '\\triangleq', - true, - '≜', - '[defined to]', - '[defined to]', - '≜', - ], - ['le', '\\le', true, '≤', '<=', '<=', '≤'], - ['leq', '\\le', true, '≤', '<=', '<=', '≤'], - ['ge', '\\ge', true, '≥', '>=', '>=', '≥'], - ['geq', '\\ge', true, '≥', '>=', '>=', '≥'], - [ - 'lessgtr', - '\\lessgtr', - true, - '≶', - '[less than or greater than]', - '[less than or greater than]', - '≶', - ], - [ - 'lesseqgtr', - '\\lesseqgtr', - true, - '⋚', - '[less than or equal or greater than or equal]', - '[less than or equal or greater than or equal]', - '⋚', - ], - ['ll', '\\ll', true, '≪', '<<', '<<', '≪'], - ['Ll', '\\lll', true, '⋘', '<<<', '<<<', '⋘'], - ['lll', '\\lll', true, '⋘', '<<<', '<<<', '⋘'], - ['gg', '\\gg', true, '≫', '>>', '>>', '≫'], - ['Gg', '\\ggg', true, '⋙', '>>>', '>>>', '⋙'], - ['ggg', '\\ggg', true, '⋙', '>>>', '>>>', '⋙'], - ['prec', '\\prec', true, '≺', '[precedes]', '[precedes]', '≺'], - [ - 'preceq', - '\\preceq', - true, - '≼', - '[precedes or equal]', - '[precedes or equal]', - '≼', - ], - [ - 'preccurlyeq', - '\\preccurlyeq', - true, - '≼', - '[precedes or equal]', - '[precedes or equal]', - '≼', - ], - ['succ', '\\succ', true, '≻', '[succeeds]', '[succeeds]', '≻'], - [ - 'succeq', - '\\succeq', - true, - '≽', - '[succeeds or equal]', - '[succeeds or equal]', - '≽', - ], - [ - 'succcurlyeq', - '\\succcurlyeq', - true, - '≽', - '[succeeds or equal]', - '[succeeds or equal]', - '≽', - ], - ['sub', '\\subset', true, '⊂', '[subset of]', '[subset of]', '⊂'], - ['subset', '\\subset', true, '⊂', '[subset of]', '[subset of]', '⊂'], - ['sup', '\\supset', true, '⊃', '[superset of]', '[superset of]', '⊃'], - ['supset', '\\supset', true, '⊃', '[superset of]', '[superset of]', '⊃'], - [ - 'nsub', - '\\not\\subset', - true, - '⊄', - '[not a subset of]', - '[not a subset of', - '⊄', - ], - [ - 'sube', - '\\subseteq', - true, - '⊆', - '[subset of or equal to]', - '[subset of or equal to]', - '⊆', - ], - [ - 'nsup', - '\\not\\supset', - true, - '⊅', - '[not a superset of]', - '[not a superset of]', - '⊅', - ], - [ - 'supe', - '\\supseteq', - true, - '⊇', - '[superset of or equal to]', - '[superset of or equal to]', - '⊇', - ], - ['setminus', '\\setminus', true, '∖', '" ', '"', '⧵'], - ['forall', '\\forall', true, '∀', '[for all]', '[for all]', '∀'], - [ - 'exist', - '\\exists', - true, - '∃', - '[there exists]', - '[there exists]', - '∃', - ], - [ - 'exists', - '\\exists', - true, - '∃', - '[there exists]', - '[there exists]', - '∃', - ], - [ - 'nexist', - '\\nexists', - true, - '∃', - '[there does not exists]', - '[there does not exists]', - '∄', - ], - [ - 'nexists', - '\\nexists', - true, - '∃', - '[there does not exists]', - '[there does not exists]', - '∄', - ], - ['empty', '\\emptyset', true, '∅', '[empty set]', '[empty set]', '∅'], - [ - 'emptyset', - '\\emptyset', - true, - '∅', - '[empty set]', - '[empty set]', - '∅', - ], - ['isin', '\\in', true, '∈', '[element of]', '[element of]', '∈'], - ['in', '\\in', true, '∈', '[element of]', '[element of]', '∈'], - [ - 'notin', - '\\notin', - true, - '∉', - '[not an element of]', - '[not an element of]', - '∉', - ], - [ - 'ni', - '\\ni', - true, - '∋', - '[contains as member]', - '[contains as member]', - '∋', - ], - ['nabla', '\\nabla', true, '∇', '[nabla]', '[nabla]', '∇'], - ['ang', '\\angle', true, '∠', '[angle]', '[angle]', '∠'], - ['angle', '\\angle', true, '∠', '[angle]', '[angle]', '∠'], - ['perp', '\\perp', true, '⊥', '[up tack]', '[up tack]', '⊥'], - ['parallel', '\\parallel', true, '∥', '||', '||', '∥'], - ['sdot', '\\cdot', true, '⋅', '[dot]', '[dot]', '⋅'], - ['cdot', '\\cdot', true, '⋅', '[dot]', '[dot]', '⋅'], - [ - 'lceil', - '\\lceil', - true, - '⌈', - '[left ceiling]', - '[left ceiling]', - '⌈', - ], - [ - 'rceil', - '\\rceil', - true, - '⌉', - '[right ceiling]', - '[right ceiling]', - '⌉', - ], - ['lfloor', '\\lfloor', true, '⌊', '[left floor]', '[left floor]', '⌊'], - [ - 'rfloor', - '\\rfloor', - true, - '⌋', - '[right floor]', - '[right floor]', - '⌋', - ], - ['lang', '\\langle', true, '⟨', '<', '<', '⟨'], - ['rang', '\\rangle', true, '⟩', '>', '>', '⟩'], - ['langle', '\\langle', true, '⟨', '<', '<', '⟨'], - ['rangle', '\\rangle', true, '⟩', '>', '>', '⟩'], - ['hbar', '\\hbar', true, 'ℏ', 'hbar', 'hbar', 'ℏ'], - ['mho', '\\mho', true, '℧', 'mho', 'mho', '℧'], - // ** Arrows - ['larr', '\\leftarrow', true, '←', '<-', '<-', '←'], - ['leftarrow', '\\leftarrow', true, '←', '<-', '<-', '←'], - ['gets', '\\gets', true, '←', '<-', '<-', '←'], - ['lArr', '\\Leftarrow', true, '⇐', '<=', '<=', '⇐'], - ['Leftarrow', '\\Leftarrow', true, '⇐', '<=', '<=', '⇐'], - ['uarr', '\\uparrow', true, '↑', '[uparrow]', '[uparrow]', '↑'], - ['uparrow', '\\uparrow', true, '↑', '[uparrow]', '[uparrow]', '↑'], - ['uArr', '\\Uparrow', true, '⇑', '[dbluparrow]', '[dbluparrow]', '⇑'], - ['Uparrow', '\\Uparrow', true, '⇑', '[dbluparrow]', '[dbluparrow]', '⇑'], - ['rarr', '\\rightarrow', true, '→', '->', '->', '→'], - ['to', '\\to', true, '→', '->', '->', '→'], - ['rightarrow', '\\rightarrow', true, '→', '->', '->', '→'], - ['rArr', '\\Rightarrow', true, '⇒', '=>', '=>', '⇒'], - ['Rightarrow', '\\Rightarrow', true, '⇒', '=>', '=>', '⇒'], - ['darr', '\\downarrow', true, '↓', '[downarrow]', '[downarrow]', '↓'], - [ - 'downarrow', - '\\downarrow', - true, - '↓', - '[downarrow]', - '[downarrow]', - '↓', - ], - [ - 'dArr', - '\\Downarrow', - true, - '⇓', - '[dbldownarrow]', - '[dbldownarrow]', - '⇓', - ], - [ - 'Downarrow', - '\\Downarrow', - true, - '⇓', - '[dbldownarrow]', - '[dbldownarrow]', - '⇓', - ], - ['harr', '\\leftrightarrow', true, '↔', '<->', '<->', '↔'], - ['leftrightarrow', '\\leftrightarrow', true, '↔', '<->', '<->', '↔'], - ['hArr', '\\Leftrightarrow', true, '⇔', '<=>', '<=>', '⇔'], - ['Leftrightarrow', '\\Leftrightarrow', true, '⇔', '<=>', '<=>', '⇔'], - ['crarr', '\\hookleftarrow', true, '↵', "<-'", "<-'", '↵'], - ['hookleftarrow', '\\hookleftarrow', true, '↵', "<-'", "<-'", '↵'], - // ** Function names - ['arccos', '\\arccos', true, 'arccos', 'arccos', 'arccos', 'arccos'], - ['arcsin', '\\arcsin', true, 'arcsin', 'arcsin', 'arcsin', 'arcsin'], - ['arctan', '\\arctan', true, 'arctan', 'arctan', 'arctan', 'arctan'], - ['arg', '\\arg', true, 'arg', 'arg', 'arg', 'arg'], - ['cos', '\\cos', true, 'cos', 'cos', 'cos', 'cos'], - ['cosh', '\\cosh', true, 'cosh', 'cosh', 'cosh', 'cosh'], - ['cot', '\\cot', true, 'cot', 'cot', 'cot', 'cot'], - ['coth', '\\coth', true, 'coth', 'coth', 'coth', 'coth'], - ['csc', '\\csc', true, 'csc', 'csc', 'csc', 'csc'], - ['deg', '\\deg', true, '°', 'deg', 'deg', 'deg'], - ['det', '\\det', true, 'det', 'det', 'det', 'det'], - ['dim', '\\dim', true, 'dim', 'dim', 'dim', 'dim'], - ['exp', '\\exp', true, 'exp', 'exp', 'exp', 'exp'], - ['gcd', '\\gcd', true, 'gcd', 'gcd', 'gcd', 'gcd'], - ['hom', '\\hom', true, 'hom', 'hom', 'hom', 'hom'], - ['inf', '\\inf', true, 'inf', 'inf', 'inf', 'inf'], - ['ker', '\\ker', true, 'ker', 'ker', 'ker', 'ker'], - ['lg', '\\lg', true, 'lg', 'lg', 'lg', 'lg'], - ['lim', '\\lim', true, 'lim', 'lim', 'lim', 'lim'], - ['liminf', '\\liminf', true, 'liminf', 'liminf', 'liminf', 'liminf'], - ['limsup', '\\limsup', true, 'limsup', 'limsup', 'limsup', 'limsup'], - ['ln', '\\ln', true, 'ln', 'ln', 'ln', 'ln'], - ['log', '\\log', true, 'log', 'log', 'log', 'log'], - ['max', '\\max', true, 'max', 'max', 'max', 'max'], - ['min', '\\min', true, 'min', 'min', 'min', 'min'], - ['Pr', '\\Pr', true, 'Pr', 'Pr', 'Pr', 'Pr'], - ['sec', '\\sec', true, 'sec', 'sec', 'sec', 'sec'], - ['sin', '\\sin', true, 'sin', 'sin', 'sin', 'sin'], - ['sinh', '\\sinh', true, 'sinh', 'sinh', 'sinh', 'sinh'], - ['sup', '\\sup', true, '⊃', 'sup', 'sup', 'sup'], - ['tan', '\\tan', true, 'tan', 'tan', 'tan', 'tan'], - ['tanh', '\\tanh', true, 'tanh', 'tanh', 'tanh', 'tanh'], - // ** Signs & Symbols - ['bull', '\\textbullet{}', false, '•', '*', '*', '•'], - ['bullet', '\\textbullet{}', false, '•', '*', '*', '•'], - ['star', '\\star', true, '*', '*', '*', '⋆'], - ['lowast', '\\ast', true, '∗', '*', '*', '∗'], - ['ast', '\\ast', true, '∗', '*', '*', '*'], - ['odot', '\\odot', true, 'o', '[circled dot]', '[circled dot]', 'ʘ'], - [ - 'oplus', - '\\oplus', - true, - '⊕', - '[circled plus]', - '[circled plus]', - '⊕', - ], - [ - 'otimes', - '\\otimes', - true, - '⊗', - '[circled times]', - '[circled times]', - '⊗', - ], - [ - 'check', - '\\checkmark', - true, - '✓', - '[checkmark]', - '[checkmark]', - '✓', - ], - [ - 'checkmark', - '\\checkmark', - true, - '✓', - '[checkmark]', - '[checkmark]', - '✓', - ], - // ** Miscellaneous (seldom used) - ['para', '\\P{}', false, '¶', '[pilcrow]', '¶', '¶'], - ['ordf', '\\textordfeminine{}', false, 'ª', '_a_', 'ª', 'ª'], - ['ordm', '\\textordmasculine{}', false, 'º', '_o_', 'º', 'º'], - ['cedil', '\\c{}', false, '¸', '[cedilla]', '¸', '¸'], - ['oline', '\\overline{~}', true, '‾', '[overline]', '¯', '‾'], - ['uml', '\\textasciidieresis{}', false, '¨', '[diaeresis]', '¨', '¨'], - ['zwnj', '\\/{}', false, '‌', '', '', '‌'], - ['zwj', '', false, '‍', '', '', '‍'], - ['lrm', '', false, '‎', '', '', '‎'], - ['rlm', '', false, '‏', '', '', '‏'], - // ** Smilies - ['smiley', '\\ddot\\smile', true, '☺', ':-)', ':-)', '☺'], - ['blacksmile', '\\ddot\\smile', true, '☻', ':-)', ':-)', '☻'], - ['sad', '\\ddot\\frown', true, '☹', ':-(', ':-(', '☹'], - ['frowny', '\\ddot\\frown', true, '☹', ':-(', ':-(', '☹'], - // ** Suits - ['clubs', '\\clubsuit', true, '♣', '[clubs]', '[clubs]', '♣'], - ['clubsuit', '\\clubsuit', true, '♣', '[clubs]', '[clubs]', '♣'], - ['spades', '\\spadesuit', true, '♠', '[spades]', '[spades]', '♠'], - ['spadesuit', '\\spadesuit', true, '♠', '[spades]', '[spades]', '♠'], - ['hearts', '\\heartsuit', true, '♥', '[hearts]', '[hearts]', '♥'], - [ - 'heartsuit', - '\\heartsuit', - true, - '♥', - '[hearts]', - '[hearts]', - '♥', - ], - ['diams', '\\diamondsuit', true, '♦', '[diamonds]', '[diamonds]', '◆'], - [ - 'diamondsuit', - '\\diamondsuit', - true, - '♦', - '[diamonds]', - '[diamonds]', - '◆', - ], - [ - 'diamond', - '\\diamondsuit', - true, - '⋄', - '[diamond]', - '[diamond]', - '◆', - ], - [ - 'Diamond', - '\\diamondsuit', - true, - '⋄', - '[diamond]', - '[diamond]', - '◆', - ], - ['loz', '\\lozenge', true, '◊', '[lozenge]', '[lozenge]', '⧫'], - ['_ ', '\\hspace*{0.5em}', false, ' ', ' ', ' ', ' '], - ['_ ', '\\hspace*{1.0em}', false, '  ', ' ', ' ', '  '], - [ - '_ ', - '\\hspace*{1.5em}', - false, - '   ', - ' ', - ' ', - '   ', - ], - [ - '_ ', - '\\hspace*{2.0em}', - false, - '    ', - ' ', - ' ', - '    ', - ], - [ - '_ ', - '\\hspace*{2.5em}', - false, - '     ', - ' ', - ' ', - '     ', - ], - [ - '_ ', - '\\hspace*{3.0em}', - false, - '      ', - ' ', - ' ', - '      ', - ], - [ - '_ ', - '\\hspace*{3.5em}', - false, - '       ', - ' ', - ' ', - '       ', - ], - [ - '_ ', - '\\hspace*{4.0em}', - false, - '        ', - ' ', - ' ', - '        ', - ], - [ - '_ ', - '\\hspace*{4.5em}', - false, - '         ', - ' ', - ' ', - '         ', - ], - [ - '_ ', - '\\hspace*{5.0em}', - false, - '          ', - ' ', - ' ', - '          ', - ], - [ - '_ ', - '\\hspace*{5.5em}', - false, - '           ', - ' ', - ' ', - '           ', - ], - [ - '_ ', - '\\hspace*{6.0em}', - false, - '            ', - ' ', - ' ', - '            ', - ], - [ - '_ ', - '\\hspace*{6.5em}', - false, - '             ', - ' ', - ' ', - '             ', - ], - [ - '_ ', - '\\hspace*{7.0em}', - false, - '              ', - ' ', - ' ', - '              ', - ], - [ - '_ ', - '\\hspace*{7.5em}', - false, - '               ', - ' ', - ' ', - '               ', - ], - [ - '_ ', - '\\hspace*{8.0em}', - false, - '                ', - ' ', - ' ', - '                ', - ], - [ - '_ ', - '\\hspace*{8.5em}', - false, - '                 ', - ' ', - ' ', - '                 ', - ], - [ - '_ ', - '\\hspace*{9.0em}', - false, - '                  ', - ' ', - ' ', - '                  ', - ], - [ - '_ ', - '\\hspace*{9.5em}', - false, - '                   ', - ' ', - ' ', - '                   ', - ], - [ - '_ ', - '\\hspace*{10.0em}', - false, - '                    ', - ' ', - ' ', - '                    ', - ], -]; +const orgEntities: [string, string, boolean, string, string, string, string][] = + [ + // * Letters + // ** Latin + ['Agrave', '\\`{A}', false, 'À', 'A', 'À', 'À'], + ['agrave', '\\`{a}', false, 'à', 'a', 'à', 'à'], + ['Aacute', "\\'{A}", false, 'Á', 'A', 'Á', 'Á'], + ['aacute', "\\'{a}", false, 'á', 'a', 'á', 'á'], + ['Acirc', '\\^{A}', false, 'Â', 'A', 'Â', 'Â'], + ['acirc', '\\^{a}', false, 'â', 'a', 'â', 'â'], + ['Amacr', '\\bar{A}', false, 'Ā', 'A', 'Ã', 'Ã'], + ['amacr', '\\bar{a}', false, 'ā', 'a', 'ã', 'ã'], + ['Atilde', '\\~{A}', false, 'Ã', 'A', 'Ã', 'Ã'], + ['atilde', '\\~{a}', false, 'ã', 'a', 'ã', 'ã'], + ['Auml', '\\"{A}', false, 'Ä', 'Ae', 'Ä', 'Ä'], + ['auml', '\\"{a}', false, 'ä', 'ae', 'ä', 'ä'], + ['Aring', '\\AA{}', false, 'Å', 'A', 'Å', 'Å'], + ['AA', '\\AA{}', false, 'Å', 'A', 'Å', 'Å'], + ['aring', '\\aa{}', false, 'å', 'a', 'å', 'å'], + ['AElig', '\\AE{}', false, 'Æ', 'AE', 'Æ', 'Æ'], + ['aelig', '\\ae{}', false, 'æ', 'ae', 'æ', 'æ'], + ['Ccedil', '\\c{C}', false, 'Ç', 'C', 'Ç', 'Ç'], + ['ccedil', '\\c{c}', false, 'ç', 'c', 'ç', 'ç'], + ['Egrave', '\\`{E}', false, 'È', 'E', 'È', 'È'], + ['egrave', '\\`{e}', false, 'è', 'e', 'è', 'è'], + ['Eacute', "\\'{E}", false, 'É', 'E', 'É', 'É'], + ['eacute', "\\'{e}", false, 'é', 'e', 'é', 'é'], + ['Ecirc', '\\^{E}', false, 'Ê', 'E', 'Ê', 'Ê'], + ['ecirc', '\\^{e}', false, 'ê', 'e', 'ê', 'ê'], + ['Euml', '\\"{E}', false, 'Ë', 'E', 'Ë', 'Ë'], + ['euml', '\\"{e}', false, 'ë', 'e', 'ë', 'ë'], + ['Igrave', '\\`{I}', false, 'Ì', 'I', 'Ì', 'Ì'], + ['igrave', '\\`{i}', false, 'ì', 'i', 'ì', 'ì'], + ['Iacute', "\\'{I}", false, 'Í', 'I', 'Í', 'Í'], + ['iacute', "\\'{i}", false, 'í', 'i', 'í', 'í'], + ['Icirc', '\\^{I}', false, 'Î', 'I', 'Î', 'Î'], + ['icirc', '\\^{i}', false, 'î', 'i', 'î', 'î'], + ['Iuml', '\\"{I}', false, 'Ï', 'I', 'Ï', 'Ï'], + ['iuml', '\\"{i}', false, 'ï', 'i', 'ï', 'ï'], + ['Ntilde', '\\~{N}', false, 'Ñ', 'N', 'Ñ', 'Ñ'], + ['ntilde', '\\~{n}', false, 'ñ', 'n', 'ñ', 'ñ'], + ['Ograve', '\\`{O}', false, 'Ò', 'O', 'Ò', 'Ò'], + ['ograve', '\\`{o}', false, 'ò', 'o', 'ò', 'ò'], + ['Oacute', "\\'{O}", false, 'Ó', 'O', 'Ó', 'Ó'], + ['oacute', "\\'{o}", false, 'ó', 'o', 'ó', 'ó'], + ['Ocirc', '\\^{O}', false, 'Ô', 'O', 'Ô', 'Ô'], + ['ocirc', '\\^{o}', false, 'ô', 'o', 'ô', 'ô'], + ['Otilde', '\\~{O}', false, 'Õ', 'O', 'Õ', 'Õ'], + ['otilde', '\\~{o}', false, 'õ', 'o', 'õ', 'õ'], + ['Ouml', '\\"{O}', false, 'Ö', 'Oe', 'Ö', 'Ö'], + ['ouml', '\\"{o}', false, 'ö', 'oe', 'ö', 'ö'], + ['Oslash', '\\O', false, 'Ø', 'O', 'Ø', 'Ø'], + ['oslash', '\\o{}', false, 'ø', 'o', 'ø', 'ø'], + ['OElig', '\\OE{}', false, 'Œ', 'OE', 'OE', 'Œ'], + ['oelig', '\\oe{}', false, 'œ', 'oe', 'oe', 'œ'], + ['Scaron', '\\v{S}', false, 'Š', 'S', 'S', 'Š'], + ['scaron', '\\v{s}', false, 'š', 's', 's', 'š'], + ['szlig', '\\ss{}', false, 'ß', 'ss', 'ß', 'ß'], + ['Ugrave', '\\`{U}', false, 'Ù', 'U', 'Ù', 'Ù'], + ['ugrave', '\\`{u}', false, 'ù', 'u', 'ù', 'ù'], + ['Uacute', "\\'{U}", false, 'Ú', 'U', 'Ú', 'Ú'], + ['uacute', "\\'{u}", false, 'ú', 'u', 'ú', 'ú'], + ['Ucirc', '\\^{U}', false, 'Û', 'U', 'Û', 'Û'], + ['ucirc', '\\^{u}', false, 'û', 'u', 'û', 'û'], + ['Uuml', '\\"{U}', false, 'Ü', 'Ue', 'Ü', 'Ü'], + ['uuml', '\\"{u}', false, 'ü', 'ue', 'ü', 'ü'], + ['Yacute', "\\'{Y}", false, 'Ý', 'Y', 'Ý', 'Ý'], + ['yacute', "\\'{y}", false, 'ý', 'y', 'ý', 'ý'], + ['Yuml', '\\"{Y}', false, 'Ÿ', 'Y', 'Y', 'Ÿ'], + ['yuml', '\\"{y}', false, 'ÿ', 'y', 'ÿ', 'ÿ'], + // ** Latin (special face) + ['fnof', '\\textit{f}', false, 'ƒ', 'f', 'f', 'ƒ'], + ['real', '\\Re', true, 'ℜ', 'R', 'R', 'ℜ'], + ['image', '\\Im', true, 'ℑ', 'I', 'I', 'ℑ'], + ['weierp', '\\wp', true, '℘', 'P', 'P', '℘'], + ['ell', '\\ell', true, 'ℓ', 'ell', 'ell', 'ℓ'], + ['imath', '\\imath', true, 'ı', '[dotless i]', 'dotless i', 'ı'], + ['jmath', '\\jmath', true, 'ȷ', '[dotless j]', 'dotless j', 'ȷ'], + // ** Greek + ['Alpha', 'A', false, 'Α', 'Alpha', 'Alpha', 'Α'], + ['alpha', '\\alpha', true, 'α', 'alpha', 'alpha', 'α'], + ['Beta', 'B', false, 'Β', 'Beta', 'Beta', 'Β'], + ['beta', '\\beta', true, 'β', 'beta', 'beta', 'β'], + ['Gamma', '\\Gamma', true, 'Γ', 'Gamma', 'Gamma', 'Γ'], + ['gamma', '\\gamma', true, 'γ', 'gamma', 'gamma', 'γ'], + ['Delta', '\\Delta', true, 'Δ', 'Delta', 'Delta', 'Δ'], + ['delta', '\\delta', true, 'δ', 'delta', 'delta', 'δ'], + ['Epsilon', 'E', false, 'Ε', 'Epsilon', 'Epsilon', 'Ε'], + ['epsilon', '\\epsilon', true, 'ε', 'epsilon', 'epsilon', 'ε'], + [ + 'varepsilon', + '\\varepsilon', + true, + 'ε', + 'varepsilon', + 'varepsilon', + 'ε', + ], + ['Zeta', 'Z', false, 'Ζ', 'Zeta', 'Zeta', 'Ζ'], + ['zeta', '\\zeta', true, 'ζ', 'zeta', 'zeta', 'ζ'], + ['Eta', 'H', false, 'Η', 'Eta', 'Eta', 'Η'], + ['eta', '\\eta', true, 'η', 'eta', 'eta', 'η'], + ['Theta', '\\Theta', true, 'Θ', 'Theta', 'Theta', 'Θ'], + ['theta', '\\theta', true, 'θ', 'theta', 'theta', 'θ'], + ['thetasym', '\\vartheta', true, 'ϑ', 'theta', 'theta', 'ϑ'], + ['vartheta', '\\vartheta', true, 'ϑ', 'theta', 'theta', 'ϑ'], + ['Iota', 'I', false, 'Ι', 'Iota', 'Iota', 'Ι'], + ['iota', '\\iota', true, 'ι', 'iota', 'iota', 'ι'], + ['Kappa', 'K', false, 'Κ', 'Kappa', 'Kappa', 'Κ'], + ['kappa', '\\kappa', true, 'κ', 'kappa', 'kappa', 'κ'], + ['Lambda', '\\Lambda', true, 'Λ', 'Lambda', 'Lambda', 'Λ'], + ['lambda', '\\lambda', true, 'λ', 'lambda', 'lambda', 'λ'], + ['Mu', 'M', false, 'Μ', 'Mu', 'Mu', 'Μ'], + ['mu', '\\mu', true, 'μ', 'mu', 'mu', 'μ'], + ['nu', '\\nu', true, 'ν', 'nu', 'nu', 'ν'], + ['Nu', 'N', false, 'Ν', 'Nu', 'Nu', 'Ν'], + ['Xi', '\\Xi', true, 'Ξ', 'Xi', 'Xi', 'Ξ'], + ['xi', '\\xi', true, 'ξ', 'xi', 'xi', 'ξ'], + ['Omicron', 'O', false, 'Ο', 'Omicron', 'Omicron', 'Ο'], + ['omicron', '\\textit{o}', false, 'ο', 'omicron', 'omicron', 'ο'], + ['Pi', '\\Pi', true, 'Π', 'Pi', 'Pi', 'Π'], + ['pi', '\\pi', true, 'π', 'pi', 'pi', 'π'], + ['Rho', 'P', false, 'Ρ', 'Rho', 'Rho', 'Ρ'], + ['rho', '\\rho', true, 'ρ', 'rho', 'rho', 'ρ'], + ['Sigma', '\\Sigma', true, 'Σ', 'Sigma', 'Sigma', 'Σ'], + ['sigma', '\\sigma', true, 'σ', 'sigma', 'sigma', 'σ'], + ['sigmaf', '\\varsigma', true, 'ς', 'sigmaf', 'sigmaf', 'ς'], + ['varsigma', '\\varsigma', true, 'ς', 'varsigma', 'varsigma', 'ς'], + ['Tau', 'T', false, 'Τ', 'Tau', 'Tau', 'Τ'], + ['Upsilon', '\\Upsilon', true, 'Υ', 'Upsilon', 'Upsilon', 'Υ'], + ['upsih', '\\Upsilon', true, 'ϒ', 'upsilon', 'upsilon', 'ϒ'], + ['upsilon', '\\upsilon', true, 'υ', 'upsilon', 'upsilon', 'υ'], + ['Phi', '\\Phi', true, 'Φ', 'Phi', 'Phi', 'Φ'], + ['phi', '\\phi', true, 'φ', 'phi', 'phi', 'ɸ'], + ['varphi', '\\varphi', true, 'ϕ', 'varphi', 'varphi', 'φ'], + ['Chi', 'X', false, 'Χ', 'Chi', 'Chi', 'Χ'], + ['chi', '\\chi', true, 'χ', 'chi', 'chi', 'χ'], + ['acutex', '\\acute x', true, '´x', "'x", "'x", '𝑥́'], + ['Psi', '\\Psi', true, 'Ψ', 'Psi', 'Psi', 'Ψ'], + ['psi', '\\psi', true, 'ψ', 'psi', 'psi', 'ψ'], + ['tau', '\\tau', true, 'τ', 'tau', 'tau', 'τ'], + ['Omega', '\\Omega', true, 'Ω', 'Omega', 'Omega', 'Ω'], + ['omega', '\\omega', true, 'ω', 'omega', 'omega', 'ω'], + ['piv', '\\varpi', true, 'ϖ', 'omega-pi', 'omega-pi', 'ϖ'], + ['varpi', '\\varpi', true, 'ϖ', 'omega-pi', 'omega-pi', 'ϖ'], + [ + 'partial', + '\\partial', + true, + '∂', + '[partial differential]', + '[partial differential]', + '∂', + ], + // ** Hebrew + ['alefsym', '\\aleph', true, 'ℵ', 'aleph', 'aleph', 'ℵ'], + ['aleph', '\\aleph', true, 'ℵ', 'aleph', 'aleph', 'ℵ'], + ['gimel', '\\gimel', true, 'ℷ', 'gimel', 'gimel', 'ℷ'], + ['beth', '\\beth', true, 'ℶ', 'beth', 'beth', 'ב'], + ['dalet', '\\daleth', true, 'ℸ', 'dalet', 'dalet', 'ד'], + // ** Icelandic + ['ETH', '\\DH{}', false, 'Ð', 'D', 'Ð', 'Ð'], + ['eth', '\\dh{}', false, 'ð', 'dh', 'ð', 'ð'], + ['THORN', '\\TH{}', false, 'Þ', 'TH', 'Þ', 'Þ'], + ['thorn', '\\th{}', false, 'þ', 'th', 'þ', 'þ'], + // * Punctuation + // ** Dots and Marks + ['dots', '\\dots{}', false, '…', '...', '...', '…'], + ['cdots', '\\cdots{}', true, '⋯', '...', '...', '⋯'], + ['hellip', '\\dots{}', false, '…', '...', '...', '…'], + ['middot', '\\textperiodcentered{}', false, '·', '.', '·', '·'], + ['iexcl', '!`', false, '¡', '!', '¡', '¡'], + ['iquest', '?`', false, '¿', '?', '¿', '¿'], + // ** Dash-like + ['shy', '\\-', false, '­', '', '', ''], + ['ndash', '--', false, '–', '-', '-', '–'], + ['mdash', '---', false, '—', '--', '--', '—'], + // ** Quotations + ['quot', '\\textquotedbl{}', false, '"', '"', '"', '"'], + ['acute', '\\textasciiacute{}', false, '´', "'", '´', '´'], + ['ldquo', '\\textquotedblleft{}', false, '“', '"', '"', '“'], + ['rdquo', '\\textquotedblright{}', false, '”', '"', '"', '”'], + ['bdquo', '\\quotedblbase{}', false, '„', '"', '"', '„'], + ['lsquo', '\\textquoteleft{}', false, '‘', '`', '`', '‘'], + ['rsquo', '\\textquoteright{}', false, '’', "'", "'", '’'], + ['sbquo', '\\quotesinglbase{}', false, '‚', ',', ',', '‚'], + ['laquo', '\\guillemotleft{}', false, '«', '<<', '«', '«'], + ['raquo', '\\guillemotright{}', false, '»', '>>', '»', '»'], + ['lsaquo', '\\guilsinglleft{}', false, '‹', '<', '<', '‹'], + ['rsaquo', '\\guilsinglright{}', false, '›', '>', '>', '›'], + // * Other + // ** Misc. (often used) + ['circ', '\\^{}', false, 'ˆ', '^', '^', '∘'], + ['vert', '\\vert{}', true, '|', '|', '|', '|'], + ['vbar', '|', false, '|', '|', '|', '|'], + ['brvbar', '\\textbrokenbar{}', false, '¦', '|', '¦', '¦'], + ['S', '\\S', false, '§', 'paragraph', '§', '§'], + ['sect', '\\S', false, '§', 'paragraph', '§', '§'], + ['amp', '\\&', false, '&', '&', '&', '&'], + ['lt', '\\textless{}', false, '<', '<', '<', '<'], + ['gt', '\\textgreater{}', false, '>', '>', '>', '>'], + ['tilde', '\\textasciitilde{}', false, '~', '~', '~', '~'], + ['slash', '/', false, '/', '/', '/', '/'], + ['plus', '+', false, '+', '+', '+', '+'], + ['under', '\\_', false, '_', '_', '_', '_'], + ['equal', '=', false, '=', '=', '=', '='], + ['asciicirc', '\\textasciicircum{}', false, '^', '^', '^', '^'], + [ + 'dagger', + '\\textdagger{}', + false, + '†', + '[dagger]', + '[dagger]', + '†', + ], + ['dag', '\\dag{}', false, '†', '[dagger]', '[dagger]', '†'], + [ + 'Dagger', + '\\textdaggerdbl{}', + false, + '‡', + '[doubledagger]', + '[doubledagger]', + '‡', + ], + [ + 'ddag', + '\\ddag{}', + false, + '‡', + '[doubledagger]', + '[doubledagger]', + '‡', + ], + // ** Whitespace + ['nbsp', '~', false, ' ', ' ', ' ', ' '], + ['ensp', '\\hspace*{.5em}', false, ' ', ' ', ' ', ' '], + ['emsp', '\\hspace*{1em}', false, ' ', ' ', ' ', ' '], + ['thinsp', '\\hspace*{.2em}', false, ' ', ' ', ' ', ' '], + // ** Currency + ['curren', '\\textcurrency{}', false, '¤', 'curr.', '¤', '¤'], + ['cent', '\\textcent{}', false, '¢', 'cent', '¢', '¢'], + ['pound', '\\pounds{}', false, '£', 'pound', '£', '£'], + ['yen', '\\textyen{}', false, '¥', 'yen', '¥', '¥'], + ['euro', '\\texteuro{}', false, '€', 'EUR', 'EUR', '€'], + ['EUR', '\\texteuro{}', false, '€', 'EUR', 'EUR', '€'], + ['dollar', '\\$', false, '$', '$', '$', '$'], + ['USD', '\\$', false, '$', '$', '$', '$'], + // ** Property Marks + ['copy', '\\textcopyright{}', false, '©', '(c)', '©', '©'], + ['reg', '\\textregistered{}', false, '®', '(r)', '®', '®'], + ['trade', '\\texttrademark{}', false, '™', 'TM', 'TM', '™'], + // ** Science et al. + ['minus', '\\minus', true, '−', '-', '-', '−'], + ['pm', '\\textpm{}', false, '±', '+-', '±', '±'], + ['plusmn', '\\textpm{}', false, '±', '+-', '±', '±'], + ['times', '\\texttimes{}', false, '×', '*', '×', '×'], + ['frasl', '/', false, '⁄', '/', '/', '⁄'], + ['colon', '\\colon', true, ':', ':', ':', ':'], + ['div', '\\textdiv{}', false, '÷', '/', '÷', '÷'], + ['frac12', '\\textonehalf{}', false, '½', '1/2', '½', '½'], + ['frac14', '\\textonequarter{}', false, '¼', '1/4', '¼', '¼'], + ['frac34', '\\textthreequarters{}', false, '¾', '3/4', '¾', '¾'], + [ + 'permil', + '\\textperthousand{}', + false, + '‰', + 'per thousand', + 'per thousand', + '‰', + ], + ['sup1', '\\textonesuperior{}', false, '¹', '^1', '¹', '¹'], + ['sup2', '\\texttwosuperior{}', false, '²', '^2', '²', '²'], + ['sup3', '\\textthreesuperior{}', false, '³', '^3', '³', '³'], + [ + 'radic', + '\\sqrt{\\,}', + true, + '√', + '[square root]', + '[square root]', + '√', + ], + ['sum', '\\sum', true, '∑', '[sum]', '[sum]', '∑'], + ['prod', '\\prod', true, '∏', '[product]', '[n-ary product]', '∏'], + ['micro', '\\textmu{}', false, 'µ', 'micro', 'µ', 'µ'], + ['macr', '\\textasciimacron{}', false, '¯', '[macron]', '¯', '¯'], + ['deg', '\\textdegree{}', false, '°', 'degree', '°', '°'], + ['prime', '\\prime', true, '′', "'", "'", '′'], + ['Prime', '\\prime{}\\prime', true, '″', "''", "''", '″'], + ['infin', '\\infty', true, '∞', '[infinity]', '[infinity]', '∞'], + ['infty', '\\infty', true, '∞', '[infinity]', '[infinity]', '∞'], + [ + 'prop', + '\\propto', + true, + '∝', + '[proportional to]', + '[proportional to]', + '∝', + ], + [ + 'propto', + '\\propto', + true, + '∝', + '[proportional to]', + '[proportional to]', + '∝', + ], + ['not', '\\textlnot{}', false, '¬', '[angled dash]', '¬', '¬'], + ['neg', '\\neg{}', true, '¬', '[angled dash]', '¬', '¬'], + ['land', '\\land', true, '∧', '[logical and]', '[logical and]', '∧'], + ['wedge', '\\wedge', true, '∧', '[logical and]', '[logical and]', '∧'], + ['lor', '\\lor', true, '∨', '[logical or]', '[logical or]', '∨'], + ['vee', '\\vee', true, '∨', '[logical or]', '[logical or]', '∨'], + ['cap', '\\cap', true, '∩', '[intersection]', '[intersection]', '∩'], + ['cup', '\\cup', true, '∪', '[union]', '[union]', '∪'], + [ + 'smile', + '\\smile', + true, + '⌣', + '[cup product]', + '[cup product]', + '⌣', + ], + [ + 'frown', + '\\frown', + true, + '⌢', + '[Cap product]', + '[cap product]', + '⌢', + ], + ['int', '\\int', true, '∫', '[integral]', '[integral]', '∫'], + [ + 'therefore', + '\\therefore', + true, + '∴', + '[therefore]', + '[therefore]', + '∴', + ], + [ + 'there4', + '\\therefore', + true, + '∴', + '[therefore]', + '[therefore]', + '∴', + ], + ['because', '\\because', true, '∵', '[because]', '[because]', '∵'], + ['sim', '\\sim', true, '∼', '~', '~', '∼'], + [ + 'cong', + '\\cong', + true, + '≅', + '[approx. equal to]', + '[approx. equal to]', + '≅', + ], + [ + 'simeq', + '\\simeq', + true, + '≅', + '[approx. equal to]', + '[approx. equal to]', + '≅', + ], + [ + 'asymp', + '\\asymp', + true, + '≈', + '[almost equal to]', + '[almost equal to]', + '≈', + ], + [ + 'approx', + '\\approx', + true, + '≈', + '[almost equal to]', + '[almost equal to]', + '≈', + ], + ['ne', '\\ne', true, '≠', '[not equal to]', '[not equal to]', '≠'], + ['neq', '\\neq', true, '≠', '[not equal to]', '[not equal to]', '≠'], + [ + 'equiv', + '\\equiv', + true, + '≡', + '[identical to]', + '[identical to]', + '≡', + ], + [ + 'triangleq', + '\\triangleq', + true, + '≜', + '[defined to]', + '[defined to]', + '≜', + ], + ['le', '\\le', true, '≤', '<=', '<=', '≤'], + ['leq', '\\le', true, '≤', '<=', '<=', '≤'], + ['ge', '\\ge', true, '≥', '>=', '>=', '≥'], + ['geq', '\\ge', true, '≥', '>=', '>=', '≥'], + [ + 'lessgtr', + '\\lessgtr', + true, + '≶', + '[less than or greater than]', + '[less than or greater than]', + '≶', + ], + [ + 'lesseqgtr', + '\\lesseqgtr', + true, + '⋚', + '[less than or equal or greater than or equal]', + '[less than or equal or greater than or equal]', + '⋚', + ], + ['ll', '\\ll', true, '≪', '<<', '<<', '≪'], + ['Ll', '\\lll', true, '⋘', '<<<', '<<<', '⋘'], + ['lll', '\\lll', true, '⋘', '<<<', '<<<', '⋘'], + ['gg', '\\gg', true, '≫', '>>', '>>', '≫'], + ['Gg', '\\ggg', true, '⋙', '>>>', '>>>', '⋙'], + ['ggg', '\\ggg', true, '⋙', '>>>', '>>>', '⋙'], + ['prec', '\\prec', true, '≺', '[precedes]', '[precedes]', '≺'], + [ + 'preceq', + '\\preceq', + true, + '≼', + '[precedes or equal]', + '[precedes or equal]', + '≼', + ], + [ + 'preccurlyeq', + '\\preccurlyeq', + true, + '≼', + '[precedes or equal]', + '[precedes or equal]', + '≼', + ], + ['succ', '\\succ', true, '≻', '[succeeds]', '[succeeds]', '≻'], + [ + 'succeq', + '\\succeq', + true, + '≽', + '[succeeds or equal]', + '[succeeds or equal]', + '≽', + ], + [ + 'succcurlyeq', + '\\succcurlyeq', + true, + '≽', + '[succeeds or equal]', + '[succeeds or equal]', + '≽', + ], + ['sub', '\\subset', true, '⊂', '[subset of]', '[subset of]', '⊂'], + ['subset', '\\subset', true, '⊂', '[subset of]', '[subset of]', '⊂'], + ['sup', '\\supset', true, '⊃', '[superset of]', '[superset of]', '⊃'], + [ + 'supset', + '\\supset', + true, + '⊃', + '[superset of]', + '[superset of]', + '⊃', + ], + [ + 'nsub', + '\\not\\subset', + true, + '⊄', + '[not a subset of]', + '[not a subset of', + '⊄', + ], + [ + 'sube', + '\\subseteq', + true, + '⊆', + '[subset of or equal to]', + '[subset of or equal to]', + '⊆', + ], + [ + 'nsup', + '\\not\\supset', + true, + '⊅', + '[not a superset of]', + '[not a superset of]', + '⊅', + ], + [ + 'supe', + '\\supseteq', + true, + '⊇', + '[superset of or equal to]', + '[superset of or equal to]', + '⊇', + ], + ['setminus', '\\setminus', true, '∖', '" ', '"', '⧵'], + ['forall', '\\forall', true, '∀', '[for all]', '[for all]', '∀'], + [ + 'exist', + '\\exists', + true, + '∃', + '[there exists]', + '[there exists]', + '∃', + ], + [ + 'exists', + '\\exists', + true, + '∃', + '[there exists]', + '[there exists]', + '∃', + ], + [ + 'nexist', + '\\nexists', + true, + '∃', + '[there does not exists]', + '[there does not exists]', + '∄', + ], + [ + 'nexists', + '\\nexists', + true, + '∃', + '[there does not exists]', + '[there does not exists]', + '∄', + ], + ['empty', '\\emptyset', true, '∅', '[empty set]', '[empty set]', '∅'], + [ + 'emptyset', + '\\emptyset', + true, + '∅', + '[empty set]', + '[empty set]', + '∅', + ], + ['isin', '\\in', true, '∈', '[element of]', '[element of]', '∈'], + ['in', '\\in', true, '∈', '[element of]', '[element of]', '∈'], + [ + 'notin', + '\\notin', + true, + '∉', + '[not an element of]', + '[not an element of]', + '∉', + ], + [ + 'ni', + '\\ni', + true, + '∋', + '[contains as member]', + '[contains as member]', + '∋', + ], + ['nabla', '\\nabla', true, '∇', '[nabla]', '[nabla]', '∇'], + ['ang', '\\angle', true, '∠', '[angle]', '[angle]', '∠'], + ['angle', '\\angle', true, '∠', '[angle]', '[angle]', '∠'], + ['perp', '\\perp', true, '⊥', '[up tack]', '[up tack]', '⊥'], + ['parallel', '\\parallel', true, '∥', '||', '||', '∥'], + ['sdot', '\\cdot', true, '⋅', '[dot]', '[dot]', '⋅'], + ['cdot', '\\cdot', true, '⋅', '[dot]', '[dot]', '⋅'], + [ + 'lceil', + '\\lceil', + true, + '⌈', + '[left ceiling]', + '[left ceiling]', + '⌈', + ], + [ + 'rceil', + '\\rceil', + true, + '⌉', + '[right ceiling]', + '[right ceiling]', + '⌉', + ], + [ + 'lfloor', + '\\lfloor', + true, + '⌊', + '[left floor]', + '[left floor]', + '⌊', + ], + [ + 'rfloor', + '\\rfloor', + true, + '⌋', + '[right floor]', + '[right floor]', + '⌋', + ], + ['lang', '\\langle', true, '⟨', '<', '<', '⟨'], + ['rang', '\\rangle', true, '⟩', '>', '>', '⟩'], + ['langle', '\\langle', true, '⟨', '<', '<', '⟨'], + ['rangle', '\\rangle', true, '⟩', '>', '>', '⟩'], + ['hbar', '\\hbar', true, 'ℏ', 'hbar', 'hbar', 'ℏ'], + ['mho', '\\mho', true, '℧', 'mho', 'mho', '℧'], + // ** Arrows + ['larr', '\\leftarrow', true, '←', '<-', '<-', '←'], + ['leftarrow', '\\leftarrow', true, '←', '<-', '<-', '←'], + ['gets', '\\gets', true, '←', '<-', '<-', '←'], + ['lArr', '\\Leftarrow', true, '⇐', '<=', '<=', '⇐'], + ['Leftarrow', '\\Leftarrow', true, '⇐', '<=', '<=', '⇐'], + ['uarr', '\\uparrow', true, '↑', '[uparrow]', '[uparrow]', '↑'], + ['uparrow', '\\uparrow', true, '↑', '[uparrow]', '[uparrow]', '↑'], + ['uArr', '\\Uparrow', true, '⇑', '[dbluparrow]', '[dbluparrow]', '⇑'], + [ + 'Uparrow', + '\\Uparrow', + true, + '⇑', + '[dbluparrow]', + '[dbluparrow]', + '⇑', + ], + ['rarr', '\\rightarrow', true, '→', '->', '->', '→'], + ['to', '\\to', true, '→', '->', '->', '→'], + ['rightarrow', '\\rightarrow', true, '→', '->', '->', '→'], + ['rArr', '\\Rightarrow', true, '⇒', '=>', '=>', '⇒'], + ['Rightarrow', '\\Rightarrow', true, '⇒', '=>', '=>', '⇒'], + ['darr', '\\downarrow', true, '↓', '[downarrow]', '[downarrow]', '↓'], + [ + 'downarrow', + '\\downarrow', + true, + '↓', + '[downarrow]', + '[downarrow]', + '↓', + ], + [ + 'dArr', + '\\Downarrow', + true, + '⇓', + '[dbldownarrow]', + '[dbldownarrow]', + '⇓', + ], + [ + 'Downarrow', + '\\Downarrow', + true, + '⇓', + '[dbldownarrow]', + '[dbldownarrow]', + '⇓', + ], + ['harr', '\\leftrightarrow', true, '↔', '<->', '<->', '↔'], + ['leftrightarrow', '\\leftrightarrow', true, '↔', '<->', '<->', '↔'], + ['hArr', '\\Leftrightarrow', true, '⇔', '<=>', '<=>', '⇔'], + ['Leftrightarrow', '\\Leftrightarrow', true, '⇔', '<=>', '<=>', '⇔'], + ['crarr', '\\hookleftarrow', true, '↵', "<-'", "<-'", '↵'], + ['hookleftarrow', '\\hookleftarrow', true, '↵', "<-'", "<-'", '↵'], + // ** Function names + ['arccos', '\\arccos', true, 'arccos', 'arccos', 'arccos', 'arccos'], + ['arcsin', '\\arcsin', true, 'arcsin', 'arcsin', 'arcsin', 'arcsin'], + ['arctan', '\\arctan', true, 'arctan', 'arctan', 'arctan', 'arctan'], + ['arg', '\\arg', true, 'arg', 'arg', 'arg', 'arg'], + ['cos', '\\cos', true, 'cos', 'cos', 'cos', 'cos'], + ['cosh', '\\cosh', true, 'cosh', 'cosh', 'cosh', 'cosh'], + ['cot', '\\cot', true, 'cot', 'cot', 'cot', 'cot'], + ['coth', '\\coth', true, 'coth', 'coth', 'coth', 'coth'], + ['csc', '\\csc', true, 'csc', 'csc', 'csc', 'csc'], + ['deg', '\\deg', true, '°', 'deg', 'deg', 'deg'], + ['det', '\\det', true, 'det', 'det', 'det', 'det'], + ['dim', '\\dim', true, 'dim', 'dim', 'dim', 'dim'], + ['exp', '\\exp', true, 'exp', 'exp', 'exp', 'exp'], + ['gcd', '\\gcd', true, 'gcd', 'gcd', 'gcd', 'gcd'], + ['hom', '\\hom', true, 'hom', 'hom', 'hom', 'hom'], + ['inf', '\\inf', true, 'inf', 'inf', 'inf', 'inf'], + ['ker', '\\ker', true, 'ker', 'ker', 'ker', 'ker'], + ['lg', '\\lg', true, 'lg', 'lg', 'lg', 'lg'], + ['lim', '\\lim', true, 'lim', 'lim', 'lim', 'lim'], + ['liminf', '\\liminf', true, 'liminf', 'liminf', 'liminf', 'liminf'], + ['limsup', '\\limsup', true, 'limsup', 'limsup', 'limsup', 'limsup'], + ['ln', '\\ln', true, 'ln', 'ln', 'ln', 'ln'], + ['log', '\\log', true, 'log', 'log', 'log', 'log'], + ['max', '\\max', true, 'max', 'max', 'max', 'max'], + ['min', '\\min', true, 'min', 'min', 'min', 'min'], + ['Pr', '\\Pr', true, 'Pr', 'Pr', 'Pr', 'Pr'], + ['sec', '\\sec', true, 'sec', 'sec', 'sec', 'sec'], + ['sin', '\\sin', true, 'sin', 'sin', 'sin', 'sin'], + ['sinh', '\\sinh', true, 'sinh', 'sinh', 'sinh', 'sinh'], + ['sup', '\\sup', true, '⊃', 'sup', 'sup', 'sup'], + ['tan', '\\tan', true, 'tan', 'tan', 'tan', 'tan'], + ['tanh', '\\tanh', true, 'tanh', 'tanh', 'tanh', 'tanh'], + // ** Signs & Symbols + ['bull', '\\textbullet{}', false, '•', '*', '*', '•'], + ['bullet', '\\textbullet{}', false, '•', '*', '*', '•'], + ['star', '\\star', true, '*', '*', '*', '⋆'], + ['lowast', '\\ast', true, '∗', '*', '*', '∗'], + ['ast', '\\ast', true, '∗', '*', '*', '*'], + ['odot', '\\odot', true, 'o', '[circled dot]', '[circled dot]', 'ʘ'], + [ + 'oplus', + '\\oplus', + true, + '⊕', + '[circled plus]', + '[circled plus]', + '⊕', + ], + [ + 'otimes', + '\\otimes', + true, + '⊗', + '[circled times]', + '[circled times]', + '⊗', + ], + [ + 'check', + '\\checkmark', + true, + '✓', + '[checkmark]', + '[checkmark]', + '✓', + ], + [ + 'checkmark', + '\\checkmark', + true, + '✓', + '[checkmark]', + '[checkmark]', + '✓', + ], + // ** Miscellaneous (seldom used) + ['para', '\\P{}', false, '¶', '[pilcrow]', '¶', '¶'], + ['ordf', '\\textordfeminine{}', false, 'ª', '_a_', 'ª', 'ª'], + ['ordm', '\\textordmasculine{}', false, 'º', '_o_', 'º', 'º'], + ['cedil', '\\c{}', false, '¸', '[cedilla]', '¸', '¸'], + ['oline', '\\overline{~}', true, '‾', '[overline]', '¯', '‾'], + ['uml', '\\textasciidieresis{}', false, '¨', '[diaeresis]', '¨', '¨'], + ['zwnj', '\\/{}', false, '‌', '', '', '‌'], + ['zwj', '', false, '‍', '', '', '‍'], + ['lrm', '', false, '‎', '', '', '‎'], + ['rlm', '', false, '‏', '', '', '‏'], + // ** Smilies + ['smiley', '\\ddot\\smile', true, '☺', ':-)', ':-)', '☺'], + ['blacksmile', '\\ddot\\smile', true, '☻', ':-)', ':-)', '☻'], + ['sad', '\\ddot\\frown', true, '☹', ':-(', ':-(', '☹'], + ['frowny', '\\ddot\\frown', true, '☹', ':-(', ':-(', '☹'], + // ** Suits + ['clubs', '\\clubsuit', true, '♣', '[clubs]', '[clubs]', '♣'], + ['clubsuit', '\\clubsuit', true, '♣', '[clubs]', '[clubs]', '♣'], + ['spades', '\\spadesuit', true, '♠', '[spades]', '[spades]', '♠'], + [ + 'spadesuit', + '\\spadesuit', + true, + '♠', + '[spades]', + '[spades]', + '♠', + ], + ['hearts', '\\heartsuit', true, '♥', '[hearts]', '[hearts]', '♥'], + [ + 'heartsuit', + '\\heartsuit', + true, + '♥', + '[hearts]', + '[hearts]', + '♥', + ], + [ + 'diams', + '\\diamondsuit', + true, + '♦', + '[diamonds]', + '[diamonds]', + '◆', + ], + [ + 'diamondsuit', + '\\diamondsuit', + true, + '♦', + '[diamonds]', + '[diamonds]', + '◆', + ], + [ + 'diamond', + '\\diamondsuit', + true, + '⋄', + '[diamond]', + '[diamond]', + '◆', + ], + [ + 'Diamond', + '\\diamondsuit', + true, + '⋄', + '[diamond]', + '[diamond]', + '◆', + ], + ['loz', '\\lozenge', true, '◊', '[lozenge]', '[lozenge]', '⧫'], + ['_ ', '\\hspace*{0.5em}', false, ' ', ' ', ' ', ' '], + ['_ ', '\\hspace*{1.0em}', false, '  ', ' ', ' ', '  '], + [ + '_ ', + '\\hspace*{1.5em}', + false, + '   ', + ' ', + ' ', + '   ', + ], + [ + '_ ', + '\\hspace*{2.0em}', + false, + '    ', + ' ', + ' ', + '    ', + ], + [ + '_ ', + '\\hspace*{2.5em}', + false, + '     ', + ' ', + ' ', + '     ', + ], + [ + '_ ', + '\\hspace*{3.0em}', + false, + '      ', + ' ', + ' ', + '      ', + ], + [ + '_ ', + '\\hspace*{3.5em}', + false, + '       ', + ' ', + ' ', + '       ', + ], + [ + '_ ', + '\\hspace*{4.0em}', + false, + '        ', + ' ', + ' ', + '        ', + ], + [ + '_ ', + '\\hspace*{4.5em}', + false, + '         ', + ' ', + ' ', + '         ', + ], + [ + '_ ', + '\\hspace*{5.0em}', + false, + '          ', + ' ', + ' ', + '          ', + ], + [ + '_ ', + '\\hspace*{5.5em}', + false, + '           ', + ' ', + ' ', + '           ', + ], + [ + '_ ', + '\\hspace*{6.0em}', + false, + '            ', + ' ', + ' ', + '            ', + ], + [ + '_ ', + '\\hspace*{6.5em}', + false, + '             ', + ' ', + ' ', + '             ', + ], + [ + '_ ', + '\\hspace*{7.0em}', + false, + '              ', + ' ', + ' ', + '              ', + ], + [ + '_ ', + '\\hspace*{7.5em}', + false, + '               ', + ' ', + ' ', + '               ', + ], + [ + '_ ', + '\\hspace*{8.0em}', + false, + '                ', + ' ', + ' ', + '                ', + ], + [ + '_ ', + '\\hspace*{8.5em}', + false, + '                 ', + ' ', + ' ', + '                 ', + ], + [ + '_ ', + '\\hspace*{9.0em}', + false, + '                  ', + ' ', + ' ', + '                  ', + ], + [ + '_ ', + '\\hspace*{9.5em}', + false, + '                   ', + ' ', + ' ', + '                   ', + ], + [ + '_ ', + '\\hspace*{10.0em}', + false, + '                    ', + ' ', + ' ', + '                    ', + ], + ]; diff --git a/packages/uniorg-parse/src/parser.ts b/packages/uniorg-parse/src/parser.ts index 781acef..4e93e3a 100644 --- a/packages/uniorg-parse/src/parser.ts +++ b/packages/uniorg-parse/src/parser.ts @@ -1100,7 +1100,8 @@ class Parser { } private parseNodeProperty(): NodeProperty { - const propertyRe = /^[ \t]*:(?\S+):(?:(?$)|[ \t]+(?.*?))[ \t]*$/m; + const propertyRe = + /^[ \t]*:(?\S+):(?:(?$)|[ \t]+(?.*?))[ \t]*$/m; const m = this.r.forceLookingAt(propertyRe); const key = m.groups!['key']; const value = m.groups!['value1'] ?? m.groups!['value2']; @@ -1308,8 +1309,8 @@ class Parser { const listType = item.tag ? ('descriptive' as const) : '-+*'.includes(item.bullet[0]) - ? ('unordered' as const) - : ('ordered' as const); + ? ('unordered' as const) + : ('ordered' as const); let pos = item.end; while (true) { const next = structure.find( @@ -1347,10 +1348,10 @@ class Parser { m.groups!.checkbox === '[ ]' ? ('off' as const) : m.groups!.checkbox?.toLowerCase() === '[x]' - ? ('on' as const) - : m.groups!.checkbox === '[-]' - ? ('trans' as const) - : null; + ? ('on' as const) + : m.groups!.checkbox === '[-]' + ? ('trans' as const) + : null; const item = structure.find((x) => x.begin === offset)!; const contentsBegin = this.r.offset(); const contentsEnd = item.end; @@ -1933,7 +1934,8 @@ class Parser { // TODO: Type 1: Text targeted from a radio target. // Type 2: Standard link. - const linkBracketRe = /\[\[(?([^\[\]]|\\(\\\\)*[\[\]]|\\+[^\[\]])+)\](\[(?[\s\S]+?)\])?\]/m; + const linkBracketRe = + /\[\[(?([^\[\]]|\\(\\\\)*[\[\]]|\\+[^\[\]])+)\](\[(?[\s\S]+?)\])?\]/m; const bracketM = this.r.advance(this.r.lookingAt(linkBracketRe)); if (bracketM) { const m = bracketM; @@ -2084,12 +2086,12 @@ class Parser { | 'diary' = diary ? 'diary' : active && (dateEnd || timeRange) - ? 'active-range' - : active - ? 'active' - : dateEnd || timeRange - ? 'inactive-range' - : 'inactive'; + ? 'active-range' + : active + ? 'active' + : dateEnd || timeRange + ? 'inactive-range' + : 'inactive'; // TODO: repeater props // TODO: warning props @@ -2098,10 +2100,10 @@ class Parser { const end = !start ? null : dateEnd - ? Parser.parseDate(dateEnd) - : timeRange - ? { ...start, ...timeRange } - : null; + ? Parser.parseDate(dateEnd) + : timeRange + ? { ...start, ...timeRange } + : null; return u('timestamp', { timestampType, @@ -2113,9 +2115,7 @@ class Parser { // Helpers - private static parseDate( - s: string - ): { + private static parseDate(s: string): { year: number; month: number; day: number; @@ -2215,7 +2215,8 @@ const affiliatedRe = new RegExp( 'i' ); -const footnoteRe = /\[fn:(?:(?[-_\w]+)?(?:)|(?