chore: consolidate eslint rules (#3368)
This commit is contained in:
parent
62b941d417
commit
9b02e477c6
@ -9,8 +9,8 @@ export default function dingus(req, res) {
|
||||
return res.status(405).json({
|
||||
error: {
|
||||
code: 'method_not_allowed',
|
||||
message: 'Only GET requests are supported for this endpoint.'
|
||||
}
|
||||
message: 'Only GET requests are supported for this endpoint.',
|
||||
},
|
||||
});
|
||||
}
|
||||
const { text = '' } = req.query;
|
||||
|
@ -28,7 +28,7 @@ export async function main(nodeProcess) {
|
||||
const options = {
|
||||
cwd: nodeProcess.cwd(),
|
||||
env: nodeProcess.env,
|
||||
stdio: 'inherit'
|
||||
stdio: 'inherit',
|
||||
};
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
@ -127,7 +127,7 @@ export async function main(nodeProcess) {
|
||||
default:
|
||||
if (arg.indexOf('--') === 0) {
|
||||
opt = camelize(arg.replace(/^--(no-)?/, ''));
|
||||
if (!marked.defaults.hasOwnProperty(opt)) {
|
||||
if (!(opt in marked.defaults)) {
|
||||
continue;
|
||||
}
|
||||
if (arg.indexOf('--no-') === 0) {
|
||||
@ -204,7 +204,7 @@ export async function main(nodeProcess) {
|
||||
const defaultConfig = [
|
||||
'~/.marked.json',
|
||||
'~/.marked.js',
|
||||
'~/.marked/index.js'
|
||||
'~/.marked/index.js',
|
||||
];
|
||||
|
||||
for (const configFile of defaultConfig) {
|
||||
|
@ -38,7 +38,7 @@ async function init() {
|
||||
const ignoredFiles = [
|
||||
join(cwd, 'docs', 'build.js'),
|
||||
join(cwd, 'docs', '.eslintrc.json'),
|
||||
join(cwd, 'docs', '_document.html')
|
||||
join(cwd, 'docs', '_document.html'),
|
||||
];
|
||||
|
||||
async function build(currentDir, tmpl) {
|
||||
|
@ -24,7 +24,7 @@ let $activeOutputElem = null;
|
||||
let latestVersion = 'master';
|
||||
const search = searchToObject();
|
||||
const markedVersions = {
|
||||
master: '../'
|
||||
master: '../',
|
||||
};
|
||||
let delayTime = 1;
|
||||
let checkChangeTimeout = null;
|
||||
@ -55,7 +55,7 @@ Promise.all([
|
||||
setInitialOutputType(),
|
||||
setInitialText(),
|
||||
setInitialVersion()
|
||||
.then(setInitialOptions)
|
||||
.then(setInitialOptions),
|
||||
]).then(() => {
|
||||
handleInputChange();
|
||||
handleOutputChange();
|
||||
@ -177,7 +177,7 @@ function handleChange(panes, visiblePane) {
|
||||
function setDefaultOptions() {
|
||||
return messageWorker({
|
||||
task: 'defaults',
|
||||
version: markedVersions[$markedVerElem.value]
|
||||
version: markedVersions[$markedVerElem.value],
|
||||
});
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ function checkForChanges() {
|
||||
task: 'parse',
|
||||
version,
|
||||
markdown,
|
||||
options
|
||||
options,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -305,7 +305,7 @@ function setResponseTime(ms) {
|
||||
$responseTimeElem.textContent = amount + suffix;
|
||||
$responseTimeElem.animate([
|
||||
{ transform: 'scale(1.2)' },
|
||||
{ transform: 'scale(1)' }
|
||||
{ transform: 'scale(1)' },
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ function mergeOptions(options) {
|
||||
'walkTokens',
|
||||
'extensions',
|
||||
'highlight',
|
||||
'sanitizer'
|
||||
'sanitizer',
|
||||
];
|
||||
for (const prop in defaults) {
|
||||
opts[prop] = invalidOptions.includes(prop) || !(prop in options)
|
||||
@ -56,7 +56,7 @@ function parse(e) {
|
||||
postMessage({
|
||||
id: e.data.id,
|
||||
task: e.data.task,
|
||||
defaults: getDefaults()
|
||||
defaults: getDefaults(),
|
||||
});
|
||||
break;
|
||||
}
|
||||
@ -74,7 +74,7 @@ function parse(e) {
|
||||
task: e.data.task,
|
||||
lexed: lexedList,
|
||||
parsed,
|
||||
time: endTime - startTime
|
||||
time: endTime - startTime,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
@ -1,256 +0,0 @@
|
||||
/*! eslint-config-standard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
||||
|
||||
import pluginN from 'eslint-plugin-n';
|
||||
import globals from 'globals';
|
||||
|
||||
const config = {
|
||||
languageOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
|
||||
parserOptions: {
|
||||
ecmaFeatures: { jsx: true }
|
||||
},
|
||||
|
||||
globals: {
|
||||
...globals.es2021,
|
||||
...globals.node,
|
||||
document: 'readonly',
|
||||
navigator: 'readonly',
|
||||
window: 'readonly'
|
||||
}
|
||||
},
|
||||
|
||||
plugins: {
|
||||
n: pluginN
|
||||
},
|
||||
|
||||
rules: {
|
||||
'no-var': 'warn',
|
||||
'object-shorthand': ['warn', 'properties'],
|
||||
|
||||
'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
|
||||
'array-bracket-spacing': ['error', 'never'],
|
||||
'array-callback-return': ['error', {
|
||||
allowImplicit: false,
|
||||
checkForEach: false
|
||||
}],
|
||||
'arrow-spacing': ['error', { before: true, after: true }],
|
||||
'block-spacing': ['error', 'always'],
|
||||
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
||||
camelcase: ['error', {
|
||||
allow: ['^UNSAFE_'],
|
||||
properties: 'never',
|
||||
ignoreGlobals: true
|
||||
}],
|
||||
'comma-dangle': ['error', {
|
||||
arrays: 'never',
|
||||
objects: 'never',
|
||||
imports: 'never',
|
||||
exports: 'never',
|
||||
functions: 'never'
|
||||
}],
|
||||
'comma-spacing': ['error', { before: false, after: true }],
|
||||
'comma-style': ['error', 'last'],
|
||||
'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
|
||||
'constructor-super': 'error',
|
||||
curly: ['error', 'multi-line'],
|
||||
'default-case-last': 'error',
|
||||
'dot-location': ['error', 'property'],
|
||||
'dot-notation': ['error', { allowKeywords: true }],
|
||||
'eol-last': 'error',
|
||||
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
||||
'func-call-spacing': ['error', 'never'],
|
||||
'generator-star-spacing': ['error', { before: true, after: true }],
|
||||
indent: ['error', 2, {
|
||||
SwitchCase: 1,
|
||||
VariableDeclarator: 1,
|
||||
outerIIFEBody: 1,
|
||||
MemberExpression: 1,
|
||||
FunctionDeclaration: { parameters: 1, body: 1 },
|
||||
FunctionExpression: { parameters: 1, body: 1 },
|
||||
CallExpression: { arguments: 1 },
|
||||
ArrayExpression: 1,
|
||||
ObjectExpression: 1,
|
||||
ImportDeclaration: 1,
|
||||
flatTernaryExpressions: false,
|
||||
ignoreComments: false,
|
||||
ignoredNodes: [
|
||||
'TemplateLiteral *',
|
||||
'JSXElement',
|
||||
'JSXElement > *',
|
||||
'JSXAttribute',
|
||||
'JSXIdentifier',
|
||||
'JSXNamespacedName',
|
||||
'JSXMemberExpression',
|
||||
'JSXSpreadAttribute',
|
||||
'JSXExpressionContainer',
|
||||
'JSXOpeningElement',
|
||||
'JSXClosingElement',
|
||||
'JSXFragment',
|
||||
'JSXOpeningFragment',
|
||||
'JSXClosingFragment',
|
||||
'JSXText',
|
||||
'JSXEmptyExpression',
|
||||
'JSXSpreadChild'
|
||||
],
|
||||
offsetTernaryExpressions: true
|
||||
}],
|
||||
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
||||
'keyword-spacing': ['error', { before: true, after: true }],
|
||||
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
||||
'multiline-ternary': ['error', 'always-multiline'],
|
||||
'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
|
||||
'new-parens': 'error',
|
||||
'no-array-constructor': 'error',
|
||||
'no-async-promise-executor': 'error',
|
||||
'no-caller': 'error',
|
||||
'no-case-declarations': 'error',
|
||||
'no-class-assign': 'error',
|
||||
'no-compare-neg-zero': 'error',
|
||||
'no-cond-assign': 'error',
|
||||
'no-const-assign': 'error',
|
||||
'no-constant-condition': ['error', { checkLoops: false }],
|
||||
'no-control-regex': 'error',
|
||||
'no-debugger': 'error',
|
||||
'no-delete-var': 'error',
|
||||
'no-dupe-args': 'error',
|
||||
'no-dupe-class-members': 'error',
|
||||
'no-dupe-keys': 'error',
|
||||
'no-duplicate-case': 'error',
|
||||
'no-useless-backreference': 'error',
|
||||
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||
'no-empty-character-class': 'error',
|
||||
'no-empty-pattern': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-ex-assign': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-extra-bind': 'error',
|
||||
'no-extra-boolean-cast': 'error',
|
||||
'no-extra-parens': ['error', 'functions'],
|
||||
'no-fallthrough': 'error',
|
||||
'no-floating-decimal': 'error',
|
||||
'no-func-assign': 'error',
|
||||
'no-global-assign': 'error',
|
||||
'no-implied-eval': 'error',
|
||||
'no-import-assign': 'error',
|
||||
'no-invalid-regexp': 'error',
|
||||
'no-irregular-whitespace': 'error',
|
||||
'no-iterator': 'error',
|
||||
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
||||
'no-lone-blocks': 'error',
|
||||
'no-loss-of-precision': 'error',
|
||||
'no-misleading-character-class': 'error',
|
||||
'no-prototype-builtins': 'error',
|
||||
'no-useless-catch': 'error',
|
||||
'no-mixed-operators': ['error', {
|
||||
groups: [
|
||||
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
||||
['&&', '||'],
|
||||
['in', 'instanceof']
|
||||
],
|
||||
allowSamePrecedence: true
|
||||
}],
|
||||
'no-mixed-spaces-and-tabs': 'error',
|
||||
'no-multi-spaces': 'error',
|
||||
'no-multi-str': 'error',
|
||||
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
||||
'no-new': 'error',
|
||||
'no-new-func': 'error',
|
||||
'no-new-object': 'error',
|
||||
'no-new-symbol': 'error',
|
||||
'no-new-wrappers': 'error',
|
||||
'no-obj-calls': 'error',
|
||||
'no-octal': 'error',
|
||||
'no-octal-escape': 'error',
|
||||
'no-proto': 'error',
|
||||
'no-redeclare': ['error', { builtinGlobals: false }],
|
||||
'no-regex-spaces': 'error',
|
||||
'no-return-assign': ['error', 'except-parens'],
|
||||
'no-self-assign': ['error', { props: true }],
|
||||
'no-self-compare': 'error',
|
||||
'no-sequences': 'error',
|
||||
'no-shadow-restricted-names': 'error',
|
||||
'no-sparse-arrays': 'error',
|
||||
'no-tabs': 'error',
|
||||
'no-template-curly-in-string': 'error',
|
||||
'no-this-before-super': 'error',
|
||||
'no-throw-literal': 'error',
|
||||
'no-trailing-spaces': 'error',
|
||||
'no-undef': 'error',
|
||||
'no-undef-init': 'error',
|
||||
'no-unexpected-multiline': 'error',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
|
||||
'no-unreachable': 'error',
|
||||
'no-unreachable-loop': 'error',
|
||||
'no-unsafe-finally': 'error',
|
||||
'no-unsafe-negation': 'error',
|
||||
'no-unused-expressions': ['error', {
|
||||
allowShortCircuit: true,
|
||||
allowTernary: true,
|
||||
allowTaggedTemplates: true
|
||||
}],
|
||||
'no-unused-vars': ['error', {
|
||||
args: 'none',
|
||||
caughtErrors: 'none',
|
||||
ignoreRestSiblings: true,
|
||||
vars: 'all'
|
||||
}],
|
||||
'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
|
||||
'no-useless-call': 'error',
|
||||
'no-useless-computed-key': 'error',
|
||||
'no-useless-constructor': 'error',
|
||||
'no-useless-escape': 'error',
|
||||
'no-useless-rename': 'error',
|
||||
'no-useless-return': 'error',
|
||||
'no-void': 'error',
|
||||
'no-whitespace-before-property': 'error',
|
||||
'no-with': 'error',
|
||||
'object-curly-newline': ['error', { multiline: true, consistent: true }],
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
|
||||
'one-var': ['error', { initialized: 'never' }],
|
||||
'operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before', '|>': 'before' } }],
|
||||
'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
|
||||
'prefer-const': ['error', { destructuring: 'all' }],
|
||||
'prefer-promise-reject-errors': 'error',
|
||||
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
|
||||
'quote-props': ['error', 'as-needed'],
|
||||
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
|
||||
'rest-spread-spacing': ['error', 'never'],
|
||||
semi: ['error', 'never'],
|
||||
'semi-spacing': ['error', { before: false, after: true }],
|
||||
'space-before-blocks': ['error', 'always'],
|
||||
'space-before-function-paren': ['error', 'always'],
|
||||
'space-in-parens': ['error', 'never'],
|
||||
'space-infix-ops': 'error',
|
||||
'space-unary-ops': ['error', { words: true, nonwords: false }],
|
||||
'spaced-comment': ['error', 'always', {
|
||||
line: { markers: ['*package', '!', '/', ',', '='] },
|
||||
block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] }
|
||||
}],
|
||||
'symbol-description': 'error',
|
||||
'template-curly-spacing': ['error', 'never'],
|
||||
'template-tag-spacing': ['error', 'never'],
|
||||
'unicode-bom': ['error', 'never'],
|
||||
'use-isnan': ['error', {
|
||||
enforceForSwitchCase: true,
|
||||
enforceForIndexOf: true
|
||||
}],
|
||||
'valid-typeof': ['error', { requireStringLiterals: true }],
|
||||
'wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
|
||||
'yield-star-spacing': ['error', 'both'],
|
||||
yoda: ['error', 'never'],
|
||||
|
||||
'n/handle-callback-err': ['error', '^(err|error)$'],
|
||||
'n/no-callback-literal': 'error',
|
||||
'n/no-deprecated-api': 'error',
|
||||
'n/no-exports-assign': 'error',
|
||||
'n/no-new-require': 'error',
|
||||
'n/no-path-concat': 'error',
|
||||
'n/process-exit-as-throw': 'error'
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
238
eslint.config.js
238
eslint.config.js
@ -1,58 +1,232 @@
|
||||
import globals from 'globals';
|
||||
import standardConfig from './eslint-config-standard.js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import pluginN from 'eslint-plugin-n';
|
||||
import tsEslint from 'typescript-eslint';
|
||||
import stylistic from '@stylistic/eslint-plugin';
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: ['**/lib', '**/*.min.js', '**/public']
|
||||
ignores: ['**/lib', '**/*.min.js', '**/public'],
|
||||
},
|
||||
standardConfig,
|
||||
...tseslint.configs.recommended,
|
||||
...tsEslint.configs.recommended,
|
||||
{
|
||||
plugins: {
|
||||
'@n': pluginN,
|
||||
'@stylistic': stylistic,
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
ecmaVersion: 2024,
|
||||
sourceType: 'module',
|
||||
|
||||
globals: {
|
||||
...globals.es2024,
|
||||
...globals.node,
|
||||
...globals.browser
|
||||
}
|
||||
...globals.browser,
|
||||
document: 'readonly',
|
||||
navigator: 'readonly',
|
||||
window: 'readonly',
|
||||
},
|
||||
},
|
||||
|
||||
rules: {
|
||||
semi: ['error', 'always'],
|
||||
'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
|
||||
'array-callback-return': ['error', {
|
||||
allowImplicit: false,
|
||||
checkForEach: false,
|
||||
}],
|
||||
'constructor-super': 'error',
|
||||
curly: ['error', 'multi-line'],
|
||||
'default-case-last': 'error',
|
||||
'dot-notation': ['error', { allowKeywords: true }],
|
||||
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
||||
'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
|
||||
'no-array-constructor': 'error',
|
||||
'no-async-promise-executor': 'error',
|
||||
'no-caller': 'error',
|
||||
'no-case-declarations': 'error',
|
||||
'no-class-assign': 'error',
|
||||
'no-compare-neg-zero': 'error',
|
||||
'no-const-assign': 'error',
|
||||
'no-constant-condition': ['error', { checkLoops: false }],
|
||||
'no-debugger': 'error',
|
||||
'no-delete-var': 'error',
|
||||
'no-dupe-args': 'error',
|
||||
'no-dupe-keys': 'error',
|
||||
'no-duplicate-case': 'error',
|
||||
'no-useless-backreference': 'error',
|
||||
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||
'no-empty-character-class': 'error',
|
||||
'no-empty-pattern': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-ex-assign': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-extra-bind': 'error',
|
||||
'no-extra-boolean-cast': 'error',
|
||||
'no-fallthrough': 'error',
|
||||
'no-func-assign': 'error',
|
||||
'no-global-assign': 'error',
|
||||
'no-implied-eval': 'error',
|
||||
'no-import-assign': 'error',
|
||||
'no-invalid-regexp': 'error',
|
||||
'no-irregular-whitespace': 'error',
|
||||
'no-iterator': 'error',
|
||||
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
||||
'no-lone-blocks': 'error',
|
||||
'no-loss-of-precision': 'error',
|
||||
'no-misleading-character-class': 'error',
|
||||
'no-prototype-builtins': 'error',
|
||||
'no-useless-catch': 'error',
|
||||
'no-multi-str': 'error',
|
||||
'no-new': 'error',
|
||||
'no-new-func': 'error',
|
||||
'no-new-object': 'error',
|
||||
'no-new-symbol': 'error',
|
||||
'no-new-wrappers': 'error',
|
||||
'no-obj-calls': 'error',
|
||||
'no-octal': 'error',
|
||||
'no-octal-escape': 'error',
|
||||
'no-proto': 'error',
|
||||
'no-regex-spaces': 'error',
|
||||
'no-return-assign': ['error', 'except-parens'],
|
||||
'no-self-assign': ['error', { props: true }],
|
||||
'no-self-compare': 'error',
|
||||
'no-sequences': 'error',
|
||||
'no-shadow-restricted-names': 'error',
|
||||
'no-sparse-arrays': 'error',
|
||||
'no-template-curly-in-string': 'error',
|
||||
'no-this-before-super': 'error',
|
||||
'no-throw-literal': 'error',
|
||||
'no-undef': 'error',
|
||||
'no-undef-init': 'error',
|
||||
'no-unexpected-multiline': 'error',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
|
||||
'no-unreachable': 'error',
|
||||
'no-unreachable-loop': 'error',
|
||||
'no-unsafe-finally': 'error',
|
||||
'no-unsafe-negation': 'error',
|
||||
'no-unused-expressions': ['error', {
|
||||
allowShortCircuit: true,
|
||||
allowTernary: true,
|
||||
allowTaggedTemplates: true,
|
||||
}],
|
||||
'no-unused-vars': ['error', {
|
||||
args: 'none',
|
||||
caughtErrors: 'none',
|
||||
ignoreRestSiblings: true,
|
||||
vars: 'all',
|
||||
}],
|
||||
'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
|
||||
'no-useless-call': 'error',
|
||||
'no-useless-computed-key': 'error',
|
||||
'no-useless-constructor': 'error',
|
||||
'no-useless-rename': 'error',
|
||||
'no-useless-return': 'error',
|
||||
'no-var': 'error',
|
||||
'no-void': 'error',
|
||||
'no-with': 'error',
|
||||
'object-shorthand': ['warn', 'properties'],
|
||||
'prefer-const': ['error', { destructuring: 'all' }],
|
||||
'prefer-promise-reject-errors': 'error',
|
||||
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
|
||||
'symbol-description': 'error',
|
||||
'unicode-bom': ['error', 'never'],
|
||||
'use-isnan': ['error', {
|
||||
enforceForSwitchCase: true,
|
||||
enforceForIndexOf: true,
|
||||
}],
|
||||
'valid-typeof': ['error', { requireStringLiterals: true }],
|
||||
yoda: ['error', 'never'],
|
||||
|
||||
indent: ['error', 2, {
|
||||
'@stylistic/array-bracket-spacing': ['error', 'never'],
|
||||
'@stylistic/arrow-spacing': ['error', { before: true, after: true }],
|
||||
'@stylistic/block-spacing': ['error', 'always'],
|
||||
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
||||
camelcase: ['error', {
|
||||
allow: ['^UNSAFE_'],
|
||||
properties: 'never',
|
||||
ignoreGlobals: true,
|
||||
}],
|
||||
'@stylistic/comma-dangle': ['error', 'always-multiline'],
|
||||
'@stylistic/comma-spacing': ['error', { before: false, after: true }],
|
||||
'@stylistic/comma-style': ['error', 'last'],
|
||||
'@stylistic/computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
|
||||
'@stylistic/dot-location': ['error', 'property'],
|
||||
'@stylistic/eol-last': 'error',
|
||||
'@stylistic/func-call-spacing': ['error', 'never'],
|
||||
'@stylistic/generator-star-spacing': ['error', { before: true, after: true }],
|
||||
'@stylistic/indent': ['error', 2, {
|
||||
SwitchCase: 1,
|
||||
|
||||
VariableDeclarator: {
|
||||
var: 2
|
||||
var: 2,
|
||||
},
|
||||
|
||||
outerIIFEBody: 0
|
||||
outerIIFEBody: 0,
|
||||
}],
|
||||
|
||||
'operator-linebreak': ['error', 'before', {
|
||||
'@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
||||
'@stylistic/keyword-spacing': ['error', { before: true, after: true }],
|
||||
'@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
||||
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
|
||||
'@stylistic/new-parens': 'error',
|
||||
'@stylistic/no-extra-semi': 'error',
|
||||
'@stylistic/no-extra-parens': ['error', 'functions'],
|
||||
'@stylistic/no-floating-decimal': 'error',
|
||||
'@stylistic/no-mixed-operators': ['error', {
|
||||
groups: [
|
||||
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
||||
['&&', '||'],
|
||||
['in', 'instanceof'],
|
||||
],
|
||||
allowSamePrecedence: true,
|
||||
}],
|
||||
'@stylistic/no-mixed-spaces-and-tabs': 'error',
|
||||
'@stylistic/no-multi-spaces': 'error',
|
||||
'@stylistic/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
||||
'@stylistic/no-tabs': 'error',
|
||||
'@stylistic/no-trailing-spaces': 'error',
|
||||
'@stylistic/no-whitespace-before-property': 'error',
|
||||
'@stylistic/object-curly-newline': ['error', { multiline: true, consistent: true }],
|
||||
'@stylistic/object-curly-spacing': ['error', 'always'],
|
||||
'@stylistic/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
|
||||
'@stylistic/operator-linebreak': ['error', 'before', {
|
||||
overrides: {
|
||||
'=': 'after'
|
||||
}
|
||||
'=': 'after',
|
||||
},
|
||||
}],
|
||||
'@stylistic/padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
|
||||
'@stylistic/quote-props': ['error', 'as-needed'],
|
||||
'@stylistic/quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
|
||||
'@stylistic/rest-spread-spacing': ['error', 'never'],
|
||||
'@stylistic/semi': ['error', 'always'],
|
||||
'@stylistic/semi-spacing': ['error', { before: false, after: true }],
|
||||
'@stylistic/space-before-blocks': ['error', 'always'],
|
||||
'@stylistic/space-before-function-paren': ['error', 'never'],
|
||||
'@stylistic/space-in-parens': ['error', 'never'],
|
||||
'@stylistic/space-infix-ops': 'error',
|
||||
'@stylistic/space-unary-ops': ['error', { words: true, nonwords: false }],
|
||||
'@stylistic/spaced-comment': ['error', 'always', {
|
||||
line: { markers: ['*package', '!', '/', ',', '='] },
|
||||
block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] },
|
||||
}],
|
||||
'@stylistic/template-curly-spacing': ['error', 'never'],
|
||||
'@stylistic/template-tag-spacing': ['error', 'never'],
|
||||
'@stylistic/wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
|
||||
'@stylistic/yield-star-spacing': ['error', 'both'],
|
||||
|
||||
'@n/handle-callback-err': ['error', '^(err|error)$'],
|
||||
'@n/no-callback-literal': 'error',
|
||||
'@n/no-deprecated-api': 'error',
|
||||
'@n/no-exports-assign': 'error',
|
||||
'@n/no-new-require': 'error',
|
||||
'@n/no-path-concat': 'error',
|
||||
'@n/process-exit-as-throw': 'error',
|
||||
|
||||
'space-before-function-paren': ['error', 'never'],
|
||||
'no-cond-assign': 'off',
|
||||
'no-useless-escape': 'off',
|
||||
'one-var': 'off',
|
||||
'no-control-regex': 'off',
|
||||
'no-prototype-builtins': 'off',
|
||||
'no-extra-semi': 'error',
|
||||
'prefer-const': 'error',
|
||||
'no-var': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'off',
|
||||
'@typescript-eslint/no-namespace': 'off',
|
||||
|
||||
'@typescript-eslint/no-unused-vars': ['error', {
|
||||
args: 'none'
|
||||
}]
|
||||
}
|
||||
}
|
||||
args: 'none',
|
||||
}],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
428
package-lock.json
generated
428
package-lock.json
generated
@ -21,6 +21,7 @@
|
||||
"@semantic-release/github": "^10.1.0",
|
||||
"@semantic-release/npm": "^12.0.1",
|
||||
"@semantic-release/release-notes-generator": "^14.0.1",
|
||||
"@stylistic/eslint-plugin": "^2.3.0",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"commonmark": "0.31.0",
|
||||
"cross-env": "^7.0.3",
|
||||
@ -39,7 +40,7 @@
|
||||
"titleize": "^4.0.0",
|
||||
"ts-expect": "^1.3.0",
|
||||
"tslib": "^2.6.3",
|
||||
"typescript": "^5.5.2",
|
||||
"typescript": "5.5.2",
|
||||
"typescript-eslint": "8.0.0-alpha.41"
|
||||
},
|
||||
"engines": {
|
||||
@ -1407,12 +1408,437 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.3.0.tgz",
|
||||
"integrity": "sha512-rtiz6u5gRyyEZp36FcF1/gHJbsbT3qAgXZ1qkad6Nr/xJ9wrSJkiSFFQhpYVTIZ7FJNRJurEcumZDCwN9dEI4g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@stylistic/eslint-plugin-js": "2.3.0",
|
||||
"@stylistic/eslint-plugin-jsx": "2.3.0",
|
||||
"@stylistic/eslint-plugin-plus": "2.3.0",
|
||||
"@stylistic/eslint-plugin-ts": "2.3.0",
|
||||
"@types/eslint": "^8.56.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=8.40.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-js": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.3.0.tgz",
|
||||
"integrity": "sha512-lQwoiYb0Fs6Yc5QS3uT8+T9CPKK2Eoxc3H8EnYJgM26v/DgtW+1lvy2WNgyBflU+ThShZaHm3a6CdD9QeKx23w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/eslint": "^8.56.10",
|
||||
"acorn": "^8.11.3",
|
||||
"eslint-visitor-keys": "^4.0.0",
|
||||
"espree": "^10.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=8.40.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz",
|
||||
"integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-jsx": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-2.3.0.tgz",
|
||||
"integrity": "sha512-tsQ0IEKB195H6X9A4iUSgLLLKBc8gUBWkBIU8tp1/3g2l8stu+PtMQVV/VmK1+3bem5FJCyvfcZIQ/WF1fsizA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@stylistic/eslint-plugin-js": "^2.3.0",
|
||||
"@types/eslint": "^8.56.10",
|
||||
"estraverse": "^5.3.0",
|
||||
"picomatch": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=8.40.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-jsx/node_modules/picomatch": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
|
||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-2.3.0.tgz",
|
||||
"integrity": "sha512-xboPWGUU5yaPlR+WR57GwXEuY4PSlPqA0C3IdNA/+1o2MuBi95XgDJcZiJ9N+aXsqBXAPIpFFb+WQ7QEHo4f7g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/eslint": "^8.56.10",
|
||||
"@typescript-eslint/utils": "^7.12.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.16.0.tgz",
|
||||
"integrity": "sha512-8gVv3kW6n01Q6TrI1cmTZ9YMFi3ucDT7i7aI5lEikk2ebk1AEjrwX8MDTdaX5D7fPXMBLvnsaa0IFTAu+jcfOw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"@typescript-eslint/visitor-keys": "7.16.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/types": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.16.0.tgz",
|
||||
"integrity": "sha512-fecuH15Y+TzlUutvUl9Cc2XJxqdLr7+93SQIbcZfd4XRGGKoxyljK27b+kxKamjRkU7FYC6RrbSCg0ALcZn/xw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.16.0.tgz",
|
||||
"integrity": "sha512-a5NTvk51ZndFuOLCh5OaJBELYc2O3Zqxfl3Js78VFE1zE46J2AaVuW+rEbVkQznjkmlzWsUI15BG5tQMixzZLw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"@typescript-eslint/visitor-keys": "7.16.0",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"minimatch": "^9.0.4",
|
||||
"semver": "^7.6.0",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/utils": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.16.0.tgz",
|
||||
"integrity": "sha512-PqP4kP3hb4r7Jav+NiRCntlVzhxBNWq6ZQ+zQwII1y/G/1gdIPeYDCKr2+dH6049yJQsWZiHU6RlwvIFBXXGNA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "7.16.0",
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"@typescript-eslint/typescript-estree": "7.16.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.56.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.16.0.tgz",
|
||||
"integrity": "sha512-rMo01uPy9C7XxG7AFsxa8zLnWXTF8N3PYclekWSrurvhwiw1eW88mrKiAYe6s53AUY57nTRz8dJsuuXdkAhzCg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"eslint-visitor-keys": "^3.4.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/brace-expansion": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/minimatch": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
||||
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-plus/node_modules/slash": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
|
||||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.3.0.tgz",
|
||||
"integrity": "sha512-wqOR38/uz/0XPnHX68ftp8sNMSAqnYGjovOTN7w00xnjS6Lxr3Sk7q6AaxWWqbMvOj7V2fQiMC5HWAbTruJsCg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@stylistic/eslint-plugin-js": "2.3.0",
|
||||
"@types/eslint": "^8.56.10",
|
||||
"@typescript-eslint/utils": "^7.12.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=8.40.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.16.0.tgz",
|
||||
"integrity": "sha512-8gVv3kW6n01Q6TrI1cmTZ9YMFi3ucDT7i7aI5lEikk2ebk1AEjrwX8MDTdaX5D7fPXMBLvnsaa0IFTAu+jcfOw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"@typescript-eslint/visitor-keys": "7.16.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/types": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.16.0.tgz",
|
||||
"integrity": "sha512-fecuH15Y+TzlUutvUl9Cc2XJxqdLr7+93SQIbcZfd4XRGGKoxyljK27b+kxKamjRkU7FYC6RrbSCg0ALcZn/xw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.16.0.tgz",
|
||||
"integrity": "sha512-a5NTvk51ZndFuOLCh5OaJBELYc2O3Zqxfl3Js78VFE1zE46J2AaVuW+rEbVkQznjkmlzWsUI15BG5tQMixzZLw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"@typescript-eslint/visitor-keys": "7.16.0",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"minimatch": "^9.0.4",
|
||||
"semver": "^7.6.0",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/utils": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.16.0.tgz",
|
||||
"integrity": "sha512-PqP4kP3hb4r7Jav+NiRCntlVzhxBNWq6ZQ+zQwII1y/G/1gdIPeYDCKr2+dH6049yJQsWZiHU6RlwvIFBXXGNA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "7.16.0",
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"@typescript-eslint/typescript-estree": "7.16.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.56.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.16.0.tgz",
|
||||
"integrity": "sha512-rMo01uPy9C7XxG7AFsxa8zLnWXTF8N3PYclekWSrurvhwiw1eW88mrKiAYe6s53AUY57nTRz8dJsuuXdkAhzCg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "7.16.0",
|
||||
"eslint-visitor-keys": "^3.4.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || >=20.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/brace-expansion": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/minimatch": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
||||
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin-ts/node_modules/slash": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
|
||||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/eslint": {
|
||||
"version": "8.56.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz",
|
||||
"integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/estree": "*",
|
||||
"@types/json-schema": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
|
||||
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/json-schema": {
|
||||
"version": "7.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/normalize-package-data": {
|
||||
"version": "2.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"@semantic-release/github": "^10.1.0",
|
||||
"@semantic-release/npm": "^12.0.1",
|
||||
"@semantic-release/release-notes-generator": "^14.0.1",
|
||||
"@stylistic/eslint-plugin": "^2.3.0",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"commonmark": "0.31.0",
|
||||
"cross-env": "^7.0.3",
|
||||
|
@ -26,14 +26,14 @@ export default defineConfig([
|
||||
file: 'lib/marked.esm.js',
|
||||
format: 'esm',
|
||||
sourcemap: true,
|
||||
banner
|
||||
banner,
|
||||
},
|
||||
{
|
||||
file: 'lib/marked.umd.js',
|
||||
format: 'umd',
|
||||
name: 'marked',
|
||||
sourcemap: true,
|
||||
banner
|
||||
banner,
|
||||
},
|
||||
{
|
||||
file: 'marked.min.js',
|
||||
@ -47,19 +47,19 @@ export default defineConfig([
|
||||
if (comment.type === 'comment2') {
|
||||
return comment.value.includes('Copyright (c)');
|
||||
}
|
||||
}
|
||||
}
|
||||
})]
|
||||
},
|
||||
},
|
||||
})],
|
||||
},
|
||||
{
|
||||
file: 'lib/marked.cjs',
|
||||
format: 'cjs',
|
||||
name: 'marked',
|
||||
sourcemap: true,
|
||||
banner
|
||||
banner,
|
||||
}],
|
||||
plugins: [
|
||||
typescript()
|
||||
]
|
||||
}
|
||||
typescript(),
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
@ -12,7 +12,7 @@ export class _Hooks {
|
||||
static passThroughHooks = new Set([
|
||||
'preprocess',
|
||||
'postprocess',
|
||||
'processAllTokens'
|
||||
'processAllTokens',
|
||||
]);
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@ import { _Tokenizer } from './Tokenizer.ts';
|
||||
import { _TextRenderer } from './TextRenderer.ts';
|
||||
import {
|
||||
escape,
|
||||
unescape
|
||||
unescape,
|
||||
} from './helpers.ts';
|
||||
import type { MarkedExtension, MarkedOptions } from './MarkedOptions.ts';
|
||||
import type { Token, Tokens, TokensList } from './Tokens.ts';
|
||||
@ -270,7 +270,7 @@ export class Marked {
|
||||
this,
|
||||
renderer.parser.parseInline(token.tokens),
|
||||
token.depth,
|
||||
unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer))
|
||||
unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)),
|
||||
);
|
||||
};
|
||||
case 'code':
|
||||
@ -285,7 +285,7 @@ export class Marked {
|
||||
this,
|
||||
token.text,
|
||||
token.lang,
|
||||
!!token.escaped
|
||||
!!token.escaped,
|
||||
);
|
||||
};
|
||||
case 'table':
|
||||
@ -305,8 +305,8 @@ export class Marked {
|
||||
text: token.header[j].text,
|
||||
tokens: token.header[j].tokens,
|
||||
header: true,
|
||||
align: token.align[j]
|
||||
}
|
||||
align: token.align[j],
|
||||
},
|
||||
);
|
||||
}
|
||||
header += this.tablerow({ text: cell });
|
||||
@ -322,8 +322,8 @@ export class Marked {
|
||||
text: row[k].text,
|
||||
tokens: row[k].tokens,
|
||||
header: false,
|
||||
align: token.align[k]
|
||||
}
|
||||
align: token.align[k],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ export class Marked {
|
||||
} else {
|
||||
item.tokens.unshift({
|
||||
type: 'text',
|
||||
text: checkbox + ' '
|
||||
text: checkbox + ' ',
|
||||
} as Tokens.Text);
|
||||
}
|
||||
} else {
|
||||
@ -389,7 +389,7 @@ export class Marked {
|
||||
task,
|
||||
checked: !!checked,
|
||||
loose,
|
||||
tokens: item.tokens
|
||||
tokens: item.tokens,
|
||||
});
|
||||
}
|
||||
|
||||
|
10
src/Lexer.ts
10
src/Lexer.ts
@ -17,7 +17,7 @@ export class _Lexer {
|
||||
};
|
||||
|
||||
private tokenizer: _Tokenizer;
|
||||
private inlineQueue: {src: string, tokens: Token[]}[];
|
||||
private inlineQueue: { src: string, tokens: Token[] }[];
|
||||
|
||||
constructor(options?: MarkedOptions) {
|
||||
// TokenList cannot be created in one go
|
||||
@ -32,12 +32,12 @@ export class _Lexer {
|
||||
this.state = {
|
||||
inLink: false,
|
||||
inRawBlock: false,
|
||||
top: true
|
||||
top: true,
|
||||
};
|
||||
|
||||
const rules = {
|
||||
block: block.normal,
|
||||
inline: inline.normal
|
||||
inline: inline.normal,
|
||||
};
|
||||
|
||||
if (this.options.pedantic) {
|
||||
@ -60,7 +60,7 @@ export class _Lexer {
|
||||
static get rules() {
|
||||
return {
|
||||
block,
|
||||
inline
|
||||
inline,
|
||||
};
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ export class _Lexer {
|
||||
} else if (!this.tokens.links[token.tag]) {
|
||||
this.tokens.links[token.tag] = {
|
||||
href: token.href,
|
||||
title: token.title
|
||||
title: token.title,
|
||||
};
|
||||
}
|
||||
continue;
|
||||
|
@ -106,7 +106,7 @@ export class _Parser {
|
||||
type: 'paragraph',
|
||||
raw: body,
|
||||
text: body,
|
||||
tokens: [{ type: 'text', raw: body, text: body }]
|
||||
tokens: [{ type: 'text', raw: body, text: body }],
|
||||
});
|
||||
} else {
|
||||
out += body;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { _defaults } from './defaults.ts';
|
||||
import {
|
||||
cleanUrl,
|
||||
escape
|
||||
escape,
|
||||
} from './helpers.ts';
|
||||
import type { MarkedOptions } from './MarkedOptions.ts';
|
||||
import type { Tokens } from './Tokens.ts';
|
||||
@ -85,7 +85,7 @@ export class _Renderer {
|
||||
item.tokens.unshift({
|
||||
type: 'text',
|
||||
raw: checkbox + ' ',
|
||||
text: checkbox + ' '
|
||||
text: checkbox + ' ',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@ import {
|
||||
rtrim,
|
||||
splitCells,
|
||||
escape,
|
||||
findClosingBracket
|
||||
findClosingBracket,
|
||||
} from './helpers.ts';
|
||||
import type { Rules } from './rules.ts';
|
||||
import type { _Lexer } from './Lexer.ts';
|
||||
@ -23,7 +23,7 @@ function outputLink(cap: string[], link: Pick<Tokens.Link, 'href' | 'title'>, ra
|
||||
href,
|
||||
title,
|
||||
text,
|
||||
tokens: lexer.inlineTokens(text)
|
||||
tokens: lexer.inlineTokens(text),
|
||||
};
|
||||
lexer.state.inLink = false;
|
||||
return token;
|
||||
@ -33,7 +33,7 @@ function outputLink(cap: string[], link: Pick<Tokens.Link, 'href' | 'title'>, ra
|
||||
raw,
|
||||
href,
|
||||
title,
|
||||
text: escape(text)
|
||||
text: escape(text),
|
||||
};
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ export class _Tokenizer {
|
||||
if (cap && cap[0].length > 0) {
|
||||
return {
|
||||
type: 'space',
|
||||
raw: cap[0]
|
||||
raw: cap[0],
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ export class _Tokenizer {
|
||||
codeBlockStyle: 'indented',
|
||||
text: !this.options.pedantic
|
||||
? rtrim(text, '\n')
|
||||
: text
|
||||
: text,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -112,7 +112,7 @@ export class _Tokenizer {
|
||||
type: 'code',
|
||||
raw,
|
||||
lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
|
||||
text
|
||||
text,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -138,7 +138,7 @@ export class _Tokenizer {
|
||||
raw: cap[0],
|
||||
depth: cap[1].length,
|
||||
text,
|
||||
tokens: this.lexer.inline(text)
|
||||
tokens: this.lexer.inline(text),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ export class _Tokenizer {
|
||||
if (cap) {
|
||||
return {
|
||||
type: 'hr',
|
||||
raw: rtrim(cap[0], '\n')
|
||||
raw: rtrim(cap[0], '\n'),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -232,7 +232,7 @@ export class _Tokenizer {
|
||||
type: 'blockquote',
|
||||
raw,
|
||||
tokens,
|
||||
text
|
||||
text,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -249,7 +249,7 @@ export class _Tokenizer {
|
||||
ordered: isordered,
|
||||
start: isordered ? +bull.slice(0, -1) : '',
|
||||
loose: false,
|
||||
items: []
|
||||
items: [],
|
||||
};
|
||||
|
||||
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
||||
@ -398,7 +398,7 @@ export class _Tokenizer {
|
||||
checked: ischecked,
|
||||
loose: false,
|
||||
text: itemContents,
|
||||
tokens: []
|
||||
tokens: [],
|
||||
});
|
||||
|
||||
list.raw += raw;
|
||||
@ -442,7 +442,7 @@ export class _Tokenizer {
|
||||
block: true,
|
||||
raw: cap[0],
|
||||
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
|
||||
text: cap[0]
|
||||
text: cap[0],
|
||||
};
|
||||
return token;
|
||||
}
|
||||
@ -459,7 +459,7 @@ export class _Tokenizer {
|
||||
tag,
|
||||
raw: cap[0],
|
||||
href,
|
||||
title
|
||||
title,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -484,7 +484,7 @@ export class _Tokenizer {
|
||||
raw: cap[0],
|
||||
header: [],
|
||||
align: [],
|
||||
rows: []
|
||||
rows: [],
|
||||
};
|
||||
|
||||
if (headers.length !== aligns.length) {
|
||||
@ -509,7 +509,7 @@ export class _Tokenizer {
|
||||
text: headers[i],
|
||||
tokens: this.lexer.inline(headers[i]),
|
||||
header: true,
|
||||
align: item.align[i]
|
||||
align: item.align[i],
|
||||
});
|
||||
}
|
||||
|
||||
@ -519,7 +519,7 @@ export class _Tokenizer {
|
||||
text: cell,
|
||||
tokens: this.lexer.inline(cell),
|
||||
header: false,
|
||||
align: item.align[i]
|
||||
align: item.align[i],
|
||||
};
|
||||
}));
|
||||
}
|
||||
@ -535,7 +535,7 @@ export class _Tokenizer {
|
||||
raw: cap[0],
|
||||
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
||||
text: cap[1],
|
||||
tokens: this.lexer.inline(cap[1])
|
||||
tokens: this.lexer.inline(cap[1]),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -550,7 +550,7 @@ export class _Tokenizer {
|
||||
type: 'paragraph',
|
||||
raw: cap[0],
|
||||
text,
|
||||
tokens: this.lexer.inline(text)
|
||||
tokens: this.lexer.inline(text),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -562,7 +562,7 @@ export class _Tokenizer {
|
||||
type: 'text',
|
||||
raw: cap[0],
|
||||
text: cap[0],
|
||||
tokens: this.lexer.inline(cap[0])
|
||||
tokens: this.lexer.inline(cap[0]),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -573,7 +573,7 @@ export class _Tokenizer {
|
||||
return {
|
||||
type: 'escape',
|
||||
raw: cap[0],
|
||||
text: escape(cap[1])
|
||||
text: escape(cap[1]),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -598,7 +598,7 @@ export class _Tokenizer {
|
||||
inLink: this.lexer.state.inLink,
|
||||
inRawBlock: this.lexer.state.inRawBlock,
|
||||
block: false,
|
||||
text: cap[0]
|
||||
text: cap[0],
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -654,7 +654,7 @@ export class _Tokenizer {
|
||||
}
|
||||
return outputLink(cap, {
|
||||
href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
|
||||
title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
|
||||
title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title,
|
||||
}, cap[0], this.lexer);
|
||||
}
|
||||
}
|
||||
@ -670,7 +670,7 @@ export class _Tokenizer {
|
||||
return {
|
||||
type: 'text',
|
||||
raw: text,
|
||||
text
|
||||
text,
|
||||
};
|
||||
}
|
||||
return outputLink(cap, link, cap[0], this.lexer);
|
||||
@ -731,7 +731,7 @@ export class _Tokenizer {
|
||||
type: 'em',
|
||||
raw,
|
||||
text,
|
||||
tokens: this.lexer.inlineTokens(text)
|
||||
tokens: this.lexer.inlineTokens(text),
|
||||
};
|
||||
}
|
||||
|
||||
@ -741,7 +741,7 @@ export class _Tokenizer {
|
||||
type: 'strong',
|
||||
raw,
|
||||
text,
|
||||
tokens: this.lexer.inlineTokens(text)
|
||||
tokens: this.lexer.inlineTokens(text),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -760,7 +760,7 @@ export class _Tokenizer {
|
||||
return {
|
||||
type: 'codespan',
|
||||
raw: cap[0],
|
||||
text
|
||||
text,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -770,7 +770,7 @@ export class _Tokenizer {
|
||||
if (cap) {
|
||||
return {
|
||||
type: 'br',
|
||||
raw: cap[0]
|
||||
raw: cap[0],
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -782,7 +782,7 @@ export class _Tokenizer {
|
||||
type: 'del',
|
||||
raw: cap[0],
|
||||
text: cap[2],
|
||||
tokens: this.lexer.inlineTokens(cap[2])
|
||||
tokens: this.lexer.inlineTokens(cap[2]),
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -808,9 +808,9 @@ export class _Tokenizer {
|
||||
{
|
||||
type: 'text',
|
||||
raw: text,
|
||||
text
|
||||
}
|
||||
]
|
||||
text,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -845,9 +845,9 @@ export class _Tokenizer {
|
||||
{
|
||||
type: 'text',
|
||||
raw: text,
|
||||
text
|
||||
}
|
||||
]
|
||||
text,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -864,7 +864,7 @@ export class _Tokenizer {
|
||||
return {
|
||||
type: 'text',
|
||||
raw: cap[0],
|
||||
text
|
||||
text,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +200,7 @@ export namespace Tokens {
|
||||
}
|
||||
|
||||
export interface Generic {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[index: string]: any;
|
||||
|
||||
type: string;
|
||||
|
@ -14,7 +14,7 @@ export function _getDefaults(): MarkedOptions {
|
||||
renderer: null,
|
||||
silent: false,
|
||||
tokenizer: null,
|
||||
walkTokens: null
|
||||
walkTokens: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,12 @@ const escapeTest = /[&<>"']/;
|
||||
const escapeReplace = new RegExp(escapeTest.source, 'g');
|
||||
const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
||||
const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
|
||||
const escapeReplacements: {[index: string]: string} = {
|
||||
const escapeReplacements: { [index: string]: string } = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
"'": ''',
|
||||
};
|
||||
const getEscapeReplacement = (ch: string) => escapeReplacements[ch];
|
||||
|
||||
@ -58,7 +58,7 @@ export function edit(regex: string | RegExp, opt?: string) {
|
||||
},
|
||||
getRegex: () => {
|
||||
return new RegExp(source, opt);
|
||||
}
|
||||
},
|
||||
};
|
||||
return obj;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import { Marked } from './Instance.ts';
|
||||
import {
|
||||
_getDefaults,
|
||||
changeDefaults,
|
||||
_defaults
|
||||
_defaults,
|
||||
} from './defaults.ts';
|
||||
import type { MarkedExtension, MarkedOptions } from './MarkedOptions.ts';
|
||||
import type { Token, TokensList } from './Tokens.ts';
|
||||
|
20
src/rules.ts
20
src/rules.ts
@ -1,5 +1,5 @@
|
||||
import {
|
||||
edit, noopTest
|
||||
edit, noopTest,
|
||||
} from './helpers.ts';
|
||||
|
||||
/**
|
||||
@ -88,7 +88,7 @@ const blockNormal = {
|
||||
newline,
|
||||
paragraph,
|
||||
table: noopTest,
|
||||
text: blockText
|
||||
text: blockText,
|
||||
};
|
||||
|
||||
type BlockKeys = keyof typeof blockNormal;
|
||||
@ -124,7 +124,7 @@ const blockGfm: Record<BlockKeys, RegExp> = {
|
||||
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
||||
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
||||
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
|
||||
.getRegex()
|
||||
.getRegex(),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -157,7 +157,7 @@ const blockPedantic: Record<BlockKeys, RegExp> = {
|
||||
.replace('|list', '')
|
||||
.replace('|html', '')
|
||||
.replace('|tag', '')
|
||||
.getRegex()
|
||||
.getRegex(),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -271,7 +271,7 @@ const inlineNormal = {
|
||||
reflinkSearch,
|
||||
tag,
|
||||
text: inlineText,
|
||||
url: noopTest
|
||||
url: noopTest,
|
||||
};
|
||||
|
||||
type InlineKeys = keyof typeof inlineNormal;
|
||||
@ -287,7 +287,7 @@ const inlinePedantic: Record<InlineKeys, RegExp> = {
|
||||
.getRegex(),
|
||||
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
||||
.replace('label', _inlineLabel)
|
||||
.getRegex()
|
||||
.getRegex(),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -302,7 +302,7 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
|
||||
.getRegex(),
|
||||
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
||||
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
||||
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
||||
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -315,7 +315,7 @@ const inlineBreaks: Record<InlineKeys, RegExp> = {
|
||||
text: edit(inlineGfm.text)
|
||||
.replace('\\b_', '\\b_| {2,}\\n')
|
||||
.replace(/\{2,\}/g, '*')
|
||||
.getRegex()
|
||||
.getRegex(),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -325,14 +325,14 @@ const inlineBreaks: Record<InlineKeys, RegExp> = {
|
||||
export const block = {
|
||||
normal: blockNormal,
|
||||
gfm: blockGfm,
|
||||
pedantic: blockPedantic
|
||||
pedantic: blockPedantic,
|
||||
};
|
||||
|
||||
export const inline = {
|
||||
normal: inlineNormal,
|
||||
gfm: inlineGfm,
|
||||
breaks: inlineBreaks,
|
||||
pedantic: inlinePedantic
|
||||
pedantic: inlinePedantic,
|
||||
};
|
||||
|
||||
export interface Rules {
|
||||
|
12
test/bench.js
vendored
12
test/bench.js
vendored
@ -36,7 +36,7 @@ export async function runBench(options) {
|
||||
cjsMarked.setOptions({
|
||||
gfm: false,
|
||||
breaks: false,
|
||||
pedantic: false
|
||||
pedantic: false,
|
||||
});
|
||||
if (options.marked) {
|
||||
cjsMarked.setOptions(options.marked);
|
||||
@ -46,7 +46,7 @@ export async function runBench(options) {
|
||||
esmMarked.setOptions({
|
||||
gfm: false,
|
||||
breaks: false,
|
||||
pedantic: false
|
||||
pedantic: false,
|
||||
});
|
||||
if (options.marked) {
|
||||
esmMarked.setOptions(options.marked);
|
||||
@ -84,7 +84,7 @@ export async function bench(tests, specs) {
|
||||
for (const name in tests) {
|
||||
stats[name] = {
|
||||
elapsed: 0n,
|
||||
correct: 0
|
||||
correct: 0,
|
||||
};
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ export async function bench(tests, specs) {
|
||||
process.stdout.write(
|
||||
`${((i * 100) / specs.length).toFixed(1).padStart(5)}% ${i
|
||||
.toString()
|
||||
.padStart(specs.length.toString().length)} of ${specs.length}\r`
|
||||
.padStart(specs.length.toString().length)} of ${specs.length}\r`,
|
||||
);
|
||||
for (const name in tests) {
|
||||
const test = tests[name];
|
||||
@ -106,7 +106,7 @@ export async function bench(tests, specs) {
|
||||
stats[name].elapsed += after - before;
|
||||
stats[name].correct += (await htmlIsEqual(
|
||||
spec.html,
|
||||
await test(spec.markdown)
|
||||
await test(spec.markdown),
|
||||
))
|
||||
? 1
|
||||
: 0;
|
||||
@ -165,7 +165,7 @@ function parseArg(argv) {
|
||||
const arg = getArg();
|
||||
if (arg.indexOf('--') === 0) {
|
||||
const opt = camelize(arg.replace(/^--(no-)?/, ''));
|
||||
if (!defaults.hasOwnProperty(opt)) {
|
||||
if (!(opt in defaults)) {
|
||||
continue;
|
||||
}
|
||||
options.marked = options.marked || {};
|
||||
|
2
test/recheck.js
vendored
2
test/recheck.js
vendored
@ -34,7 +34,7 @@ const start = Date.now();
|
||||
|
||||
await Promise.all([
|
||||
checkRegexp(inline, 'inline'),
|
||||
checkRegexp(block, 'block')
|
||||
checkRegexp(block, 'block'),
|
||||
]);
|
||||
|
||||
console.log(`
|
||||
|
2
test/rules.js
vendored
2
test/rules.js
vendored
@ -26,7 +26,7 @@ const COLOR = {
|
||||
bgBlue: '\x1b[44m',
|
||||
bgMagenta: '\x1b[45m',
|
||||
bgCyan: '\x1b[46m',
|
||||
bgWhite: '\x1b[47m'
|
||||
bgWhite: '\x1b[47m',
|
||||
};
|
||||
|
||||
function propsToString(obj) {
|
||||
|
12
test/run-spec-tests.js
vendored
12
test/run-spec-tests.js
vendored
@ -16,35 +16,35 @@ const [commonMarkTests, gfmTests, newTests, originalTests, redosTests] =
|
||||
resolve(__dirname, './specs/gfm'),
|
||||
resolve(__dirname, './specs/new'),
|
||||
resolve(__dirname, './specs/original'),
|
||||
resolve(__dirname, './specs/redos')
|
||||
resolve(__dirname, './specs/redos'),
|
||||
]);
|
||||
|
||||
outputCompletionTable('CommonMark', commonMarkTests);
|
||||
runTests({
|
||||
tests: commonMarkTests,
|
||||
parse,
|
||||
defaultMarkedOptions: { gfm: false, pedantic: false }
|
||||
defaultMarkedOptions: { gfm: false, pedantic: false },
|
||||
});
|
||||
|
||||
outputCompletionTable('GFM', gfmTests);
|
||||
runTests({
|
||||
tests: gfmTests,
|
||||
parse,
|
||||
defaultMarkedOptions: { gfm: true, pedantic: false }
|
||||
defaultMarkedOptions: { gfm: true, pedantic: false },
|
||||
});
|
||||
|
||||
runTests({
|
||||
tests: newTests,
|
||||
parse
|
||||
parse,
|
||||
});
|
||||
|
||||
runTests({
|
||||
tests: originalTests,
|
||||
parse,
|
||||
defaultMarkedOptions: { gfm: false, pedantic: true }
|
||||
defaultMarkedOptions: { gfm: false, pedantic: true },
|
||||
});
|
||||
|
||||
runTests({
|
||||
tests: redosTests,
|
||||
parse
|
||||
parse,
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
markdown: `[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x`,
|
||||
html: `<p>[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x</p>`
|
||||
html: `<p>[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x</p>`,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
markdown: `a${' '.repeat(50000)}`,
|
||||
html: `<p>a${' '.repeat(50000)}</p>`
|
||||
html: `<p>a${' '.repeat(50000)}</p>`,
|
||||
};
|
||||
|
@ -1,18 +1,18 @@
|
||||
module.exports = [
|
||||
{
|
||||
markdown: '['.repeat(100000),
|
||||
html: `<p>${'['.repeat(100000)}</p>`
|
||||
html: `<p>${'['.repeat(100000)}</p>`,
|
||||
},
|
||||
{
|
||||
markdown: '[.'.repeat(50000),
|
||||
html: `<p>${'[.'.repeat(50000)}</p>`
|
||||
html: `<p>${'[.'.repeat(50000)}</p>`,
|
||||
},
|
||||
{
|
||||
markdown: '<'.repeat(100000),
|
||||
html: `<p>${'<'.repeat(100000)}</p>`
|
||||
html: `<p>${'<'.repeat(100000)}</p>`,
|
||||
},
|
||||
{
|
||||
markdown: '<.'.repeat(50000),
|
||||
html: `<p>${'<.'.repeat(50000)}</p>`
|
||||
}
|
||||
html: `<p>${'<.'.repeat(50000)}</p>`,
|
||||
},
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
markdown: 'a'.repeat(50000),
|
||||
html: `<p>${'a'.repeat(50000)}</p>`
|
||||
html: `<p>${'a'.repeat(50000)}</p>`,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
markdown: `# #${' '.repeat(50000)}a`,
|
||||
html: '<h1># a</h1>'
|
||||
html: '<h1># a</h1>',
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
markdown: '- a\n'.repeat(10000),
|
||||
html: `<ul>${'<li>a</li>'.repeat(10000)}</ul>`
|
||||
html: `<ul>${'<li>a</li>'.repeat(10000)}</ul>`,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
markdown: `${'_'.repeat(101)} a`,
|
||||
html: `<p>${'_'.repeat(101)} a</p>`
|
||||
html: `<p>${'_'.repeat(101)} a</p>`,
|
||||
};
|
||||
|
@ -10,8 +10,8 @@ function createHeadingToken(text) {
|
||||
depth: 1,
|
||||
text,
|
||||
tokens: [
|
||||
{ type: 'text', raw: text, text }
|
||||
]
|
||||
{ type: 'text', raw: text, text },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@ -26,8 +26,8 @@ describe('Hooks', () => {
|
||||
hooks: {
|
||||
preprocess(markdown) {
|
||||
return `# preprocess\n\n${markdown}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const html = marked.parse('*text*');
|
||||
assert.strictEqual(html.trim(), '<h1>preprocess</h1>\n<p><em>text</em></p>');
|
||||
@ -40,8 +40,8 @@ describe('Hooks', () => {
|
||||
async preprocess(markdown) {
|
||||
await timeout();
|
||||
return `# preprocess async\n\n${markdown}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const promise = marked.parse('*text*');
|
||||
assert.ok(promise instanceof Promise);
|
||||
@ -55,8 +55,8 @@ describe('Hooks', () => {
|
||||
preprocess(markdown) {
|
||||
this.options.breaks = true;
|
||||
return markdown;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const html = marked.parse('line1\nline2');
|
||||
assert.strictEqual(html.trim(), '<p>line1<br>line2</p>');
|
||||
@ -70,8 +70,8 @@ describe('Hooks', () => {
|
||||
await timeout();
|
||||
this.options.breaks = true;
|
||||
return markdown;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const html = await marked.parse('line1\nline2');
|
||||
assert.strictEqual(html.trim(), '<p>line1<br>line2</p>');
|
||||
@ -82,8 +82,8 @@ describe('Hooks', () => {
|
||||
hooks: {
|
||||
postprocess(html) {
|
||||
return html + '<h1>postprocess</h1>';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const html = marked.parse('*text*');
|
||||
assert.strictEqual(html.trim(), '<p><em>text</em></p>\n<h1>postprocess</h1>');
|
||||
@ -96,8 +96,8 @@ describe('Hooks', () => {
|
||||
async postprocess(html) {
|
||||
await timeout();
|
||||
return html + '<h1>postprocess async</h1>\n';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const promise = marked.parse('*text*');
|
||||
assert.ok(promise instanceof Promise);
|
||||
@ -111,14 +111,14 @@ describe('Hooks', () => {
|
||||
processAllTokens(tokens) {
|
||||
tokens.push(createHeadingToken('processAllTokens'));
|
||||
return tokens;
|
||||
}
|
||||
},
|
||||
},
|
||||
walkTokens(token) {
|
||||
if (token.type === 'heading') {
|
||||
token.tokens[0].text += ' walked';
|
||||
}
|
||||
return token;
|
||||
}
|
||||
},
|
||||
});
|
||||
const html = marked.parse('*text*');
|
||||
assert.strictEqual(html.trim(), '<p><em>text</em></p>\n<h1>processAllTokens walked</h1>');
|
||||
@ -132,14 +132,14 @@ describe('Hooks', () => {
|
||||
await timeout();
|
||||
tokens.push(createHeadingToken('processAllTokens async'));
|
||||
return tokens;
|
||||
}
|
||||
},
|
||||
},
|
||||
walkTokens(token) {
|
||||
if (token.type === 'heading') {
|
||||
token.tokens[0].text += ' walked';
|
||||
}
|
||||
return token;
|
||||
}
|
||||
},
|
||||
});
|
||||
const promise = marked.parse('*text*');
|
||||
assert.ok(promise instanceof Promise);
|
||||
@ -159,8 +159,8 @@ describe('Hooks', () => {
|
||||
processAllTokens(tokens) {
|
||||
tokens.push(createHeadingToken('processAllTokens1'));
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
marked.use({
|
||||
async: true,
|
||||
@ -175,8 +175,8 @@ describe('Hooks', () => {
|
||||
processAllTokens(tokens) {
|
||||
tokens.push(createHeadingToken('processAllTokens2'));
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const promise = marked.parse('*text*');
|
||||
assert.ok(promise instanceof Promise);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,16 +18,16 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'paragraph',
|
||||
text: 'paragraph 1',
|
||||
tokens: [{ type: 'text', text: 'paragraph 1' }]
|
||||
tokens: [{ type: 'text', text: 'paragraph 1' }],
|
||||
},
|
||||
{ type: 'space' },
|
||||
{
|
||||
type: 'paragraph',
|
||||
text: 'paragraph 2',
|
||||
tokens: [{ type: 'text', text: 'paragraph 2' }]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'paragraph 2' }],
|
||||
},
|
||||
],
|
||||
html: '<p>paragraph 1</p><p>paragraph 2</p>'
|
||||
html: '<p>paragraph 1</p><p>paragraph 2</p>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -35,10 +35,10 @@ describe('Parser', () => {
|
||||
await expectHtml({
|
||||
tokens: [
|
||||
{
|
||||
type: 'hr'
|
||||
}
|
||||
type: 'hr',
|
||||
},
|
||||
],
|
||||
html: '<hr />'
|
||||
html: '<hr />',
|
||||
});
|
||||
});
|
||||
|
||||
@ -49,10 +49,10 @@ describe('Parser', () => {
|
||||
type: 'heading',
|
||||
depth: 1,
|
||||
text: 'heading',
|
||||
tokens: [{ type: 'text', text: 'heading' }]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'heading' }],
|
||||
},
|
||||
],
|
||||
html: '<h1>heading</h1>'
|
||||
html: '<h1>heading</h1>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -61,10 +61,10 @@ describe('Parser', () => {
|
||||
tokens: [
|
||||
{
|
||||
type: 'code',
|
||||
text: 'code'
|
||||
}
|
||||
text: 'code',
|
||||
},
|
||||
],
|
||||
html: '<pre><code>code</code></pre>'
|
||||
html: '<pre><code>code</code></pre>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -79,14 +79,14 @@ describe('Parser', () => {
|
||||
text: 'a',
|
||||
tokens: [{ type: 'text', raw: 'a', text: 'a' }],
|
||||
header: true,
|
||||
align: 'left'
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
text: 'b',
|
||||
tokens: [{ type: 'text', raw: 'b', text: 'b' }],
|
||||
header: true,
|
||||
align: 'right'
|
||||
}
|
||||
align: 'right',
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
[
|
||||
@ -94,17 +94,17 @@ describe('Parser', () => {
|
||||
text: '1',
|
||||
tokens: [{ type: 'text', raw: '1', text: '1' }],
|
||||
header: false,
|
||||
align: 'left'
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
text: '2',
|
||||
tokens: [{ type: 'text', raw: '2', text: '2' }],
|
||||
header: false,
|
||||
align: 'right'
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
align: 'right',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
html: `
|
||||
<table>
|
||||
@ -120,7 +120,7 @@ describe('Parser', () => {
|
||||
<td align="right">2</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>`
|
||||
</table>`,
|
||||
});
|
||||
});
|
||||
|
||||
@ -133,12 +133,12 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'paragraph',
|
||||
text: 'blockquote',
|
||||
tokens: [{ type: 'text', text: 'blockquote' }]
|
||||
}
|
||||
]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'blockquote' }],
|
||||
},
|
||||
],
|
||||
html: '<blockquote><p>blockquote</p></blockquote>'
|
||||
},
|
||||
],
|
||||
html: '<blockquote><p>blockquote</p></blockquote>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -159,9 +159,9 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 1',
|
||||
tokens: [{ type: 'text', text: 'item 1' }]
|
||||
}
|
||||
]
|
||||
tokens: [{ type: 'text', text: 'item 1' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
task: false,
|
||||
@ -170,18 +170,18 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 2',
|
||||
tokens: [{ type: 'text', text: 'item 2' }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'item 2' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
html: `
|
||||
<ul>
|
||||
<li>item 1</li>
|
||||
<li>item 2</li>
|
||||
</ul>`
|
||||
</ul>`,
|
||||
});
|
||||
});
|
||||
|
||||
@ -201,9 +201,9 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 1',
|
||||
tokens: [{ type: 'text', text: 'item 1' }]
|
||||
}
|
||||
]
|
||||
tokens: [{ type: 'text', text: 'item 1' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
task: false,
|
||||
@ -212,18 +212,18 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 2',
|
||||
tokens: [{ type: 'text', text: 'item 2' }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'item 2' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
html: `
|
||||
<ol start='2'>
|
||||
<li>item 1</li>
|
||||
<li>item 2</li>
|
||||
</ol>`
|
||||
</ol>`,
|
||||
});
|
||||
});
|
||||
|
||||
@ -243,9 +243,9 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 1',
|
||||
tokens: [{ type: 'text', text: 'item 1' }]
|
||||
}
|
||||
]
|
||||
tokens: [{ type: 'text', text: 'item 1' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
task: true,
|
||||
@ -254,18 +254,18 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 2',
|
||||
tokens: [{ type: 'text', text: 'item 2' }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'item 2' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
html: `
|
||||
<ul>
|
||||
<li><input disabled type="checkbox"> item 1</li>
|
||||
<li><input checked disabled type="checkbox"> item 2</li>
|
||||
</ul>`
|
||||
</ul>`,
|
||||
});
|
||||
});
|
||||
|
||||
@ -286,9 +286,9 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 1',
|
||||
tokens: [{ type: 'text', text: 'item 1' }]
|
||||
}
|
||||
]
|
||||
tokens: [{ type: 'text', text: 'item 1' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
task: false,
|
||||
@ -298,18 +298,18 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'text',
|
||||
text: 'item 2',
|
||||
tokens: [{ type: 'text', text: 'item 2' }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'item 2' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
html: `
|
||||
<ul>
|
||||
<li><p>item 1</p></li>
|
||||
<li><p>item 2</p></li>
|
||||
</ul>`
|
||||
</ul>`,
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -319,10 +319,10 @@ describe('Parser', () => {
|
||||
tokens: [
|
||||
{
|
||||
type: 'html',
|
||||
text: '<div>html</div>'
|
||||
}
|
||||
text: '<div>html</div>',
|
||||
},
|
||||
],
|
||||
html: '<div>html</div>'
|
||||
html: '<div>html</div>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -332,10 +332,10 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'paragraph',
|
||||
text: 'paragraph 1',
|
||||
tokens: [{ type: 'text', text: 'paragraph 1' }]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'paragraph 1' }],
|
||||
},
|
||||
],
|
||||
html: '<p>paragraph 1</p>'
|
||||
html: '<p>paragraph 1</p>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -343,9 +343,9 @@ describe('Parser', () => {
|
||||
await expectHtml({
|
||||
tokens: [
|
||||
{ type: 'text', text: 'text 1' },
|
||||
{ type: 'text', text: 'text 2' }
|
||||
{ type: 'text', text: 'text 2' },
|
||||
],
|
||||
html: '<p>text 1\ntext 2</p>'
|
||||
html: '<p>text 1\ntext 2</p>',
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -355,7 +355,7 @@ describe('Parser', () => {
|
||||
await expectHtml({
|
||||
inline: true,
|
||||
tokens: [{ type: 'escape', text: '>' }],
|
||||
html: '>'
|
||||
html: '>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -365,9 +365,9 @@ describe('Parser', () => {
|
||||
tokens: [
|
||||
{ type: 'html', text: '<div>' },
|
||||
{ type: 'text', text: 'html' },
|
||||
{ type: 'html', text: '</div>' }
|
||||
{ type: 'html', text: '</div>' },
|
||||
],
|
||||
html: '<div>html</div>'
|
||||
html: '<div>html</div>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -380,10 +380,10 @@ describe('Parser', () => {
|
||||
text: 'link',
|
||||
href: 'https://example.com',
|
||||
title: 'title',
|
||||
tokens: [{ type: 'text', text: 'link' }]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'link' }],
|
||||
},
|
||||
],
|
||||
html: '<a href="https://example.com" title="title">link</a>'
|
||||
html: '<a href="https://example.com" title="title">link</a>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -395,10 +395,10 @@ describe('Parser', () => {
|
||||
type: 'image',
|
||||
text: 'image',
|
||||
href: 'image.png',
|
||||
title: 'title'
|
||||
}
|
||||
title: 'title',
|
||||
},
|
||||
],
|
||||
html: '<img src="image.png" alt="image" title="title">'
|
||||
html: '<img src="image.png" alt="image" title="title">',
|
||||
});
|
||||
});
|
||||
|
||||
@ -409,10 +409,10 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'strong',
|
||||
text: 'strong',
|
||||
tokens: [{ type: 'text', text: 'strong' }]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'strong' }],
|
||||
},
|
||||
],
|
||||
html: '<strong>strong</strong>'
|
||||
html: '<strong>strong</strong>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -423,10 +423,10 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'em',
|
||||
text: 'em',
|
||||
tokens: [{ type: 'text', text: 'em' }]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'em' }],
|
||||
},
|
||||
],
|
||||
html: '<em>em</em>'
|
||||
html: '<em>em</em>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -436,10 +436,10 @@ describe('Parser', () => {
|
||||
tokens: [
|
||||
{
|
||||
type: 'codespan',
|
||||
text: 'code'
|
||||
}
|
||||
text: 'code',
|
||||
},
|
||||
],
|
||||
html: '<code>code</code>'
|
||||
html: '<code>code</code>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -448,10 +448,10 @@ describe('Parser', () => {
|
||||
inline: true,
|
||||
tokens: [
|
||||
{
|
||||
type: 'br'
|
||||
}
|
||||
type: 'br',
|
||||
},
|
||||
],
|
||||
html: '<br />'
|
||||
html: '<br />',
|
||||
});
|
||||
});
|
||||
|
||||
@ -462,10 +462,10 @@ describe('Parser', () => {
|
||||
{
|
||||
type: 'del',
|
||||
text: 'del',
|
||||
tokens: [{ type: 'text', text: 'del' }]
|
||||
}
|
||||
tokens: [{ type: 'text', text: 'del' }],
|
||||
},
|
||||
],
|
||||
html: '<del>del</del>'
|
||||
html: '<del>del</del>',
|
||||
});
|
||||
});
|
||||
|
||||
@ -474,9 +474,9 @@ describe('Parser', () => {
|
||||
inline: true,
|
||||
tokens: [
|
||||
{ type: 'text', text: 'text 1' },
|
||||
{ type: 'text', text: 'text 2' }
|
||||
{ type: 'text', text: 'text 2' },
|
||||
],
|
||||
html: 'text 1text 2'
|
||||
html: 'text 1text 2',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -15,27 +15,27 @@ function createMocks() {
|
||||
stdin: {
|
||||
data: null,
|
||||
error: null,
|
||||
end: null
|
||||
end: null,
|
||||
},
|
||||
process: {
|
||||
cwd: mock.fn(() => '/cwd'),
|
||||
env: [],
|
||||
argv: [],
|
||||
stdout: {
|
||||
write: mock.fn((str) => { mocks.stdout += str; })
|
||||
write: mock.fn((str) => { mocks.stdout += str; }),
|
||||
},
|
||||
stderr: {
|
||||
write: mock.fn((str) => { mocks.stderr += str; })
|
||||
write: mock.fn((str) => { mocks.stderr += str; }),
|
||||
},
|
||||
stdin: {
|
||||
setEncoding: mock.fn(),
|
||||
on: mock.fn((method, func) => {
|
||||
mocks.stdin[method] = func;
|
||||
}),
|
||||
resume: mock.fn()
|
||||
resume: mock.fn(),
|
||||
},
|
||||
exit: mock.fn((code) => { mocks.code = code; }),
|
||||
},
|
||||
exit: mock.fn((code) => { mocks.code = code; })
|
||||
}
|
||||
};
|
||||
|
||||
return mocks;
|
||||
@ -71,30 +71,30 @@ describe('bin/marked', () => {
|
||||
describe('string', () => {
|
||||
it('-s', testInput({
|
||||
args: ['-s', '# test'],
|
||||
stdout: '<h1>test</h1>'
|
||||
stdout: '<h1>test</h1>',
|
||||
}));
|
||||
|
||||
it('--string', testInput({
|
||||
args: ['--string', '# test'],
|
||||
stdout: '<h1>test</h1>'
|
||||
stdout: '<h1>test</h1>',
|
||||
}));
|
||||
});
|
||||
|
||||
describe('config', () => {
|
||||
it('-c', testInput({
|
||||
args: ['-c', fixturePath('bin-config.js'), '-s', 'line1\nline2'],
|
||||
stdout: '<p>line1<br>line2</p>'
|
||||
stdout: '<p>line1<br>line2</p>',
|
||||
}));
|
||||
|
||||
it('--config', testInput({
|
||||
args: ['--config', fixturePath('bin-config.js'), '-s', 'line1\nline2'],
|
||||
stdout: '<p>line1<br>line2</p>'
|
||||
stdout: '<p>line1<br>line2</p>',
|
||||
}));
|
||||
|
||||
it('config not found', testInput({
|
||||
args: ['--config', fixturePath('does-not-exist.js'), '-s', 'line1\nline2'],
|
||||
stderr: `Cannot load config file '${fixturePath('does-not-exist.js')}'`,
|
||||
code: 1
|
||||
code: 1,
|
||||
}));
|
||||
});
|
||||
|
||||
@ -102,13 +102,13 @@ describe('bin/marked', () => {
|
||||
it('input file not found', testInput({
|
||||
args: [fixturePath('does-not-exist.md')],
|
||||
stderr: `marked: ${fixturePath('does-not-exist.md')}: No such file or directory`,
|
||||
code: 1
|
||||
code: 1,
|
||||
}));
|
||||
|
||||
it('input file not found --input', testInput({
|
||||
args: ['--input', fixturePath('does-not-exist.md')],
|
||||
stderr: `marked: ${fixturePath('does-not-exist.md')}: No such file or directory`,
|
||||
code: 1
|
||||
code: 1,
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@ -1,3 +1,3 @@
|
||||
export default {
|
||||
breaks: true
|
||||
breaks: true,
|
||||
};
|
||||
|
@ -9,8 +9,8 @@ describe('Marked', () => {
|
||||
renderer: {
|
||||
heading() {
|
||||
return 'im marked1';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const marked2 = new Marked({
|
||||
@ -18,8 +18,8 @@ describe('Marked', () => {
|
||||
renderer: {
|
||||
heading() {
|
||||
return 'im marked2';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(marked1.parse('# header'), 'im marked1');
|
||||
@ -34,8 +34,8 @@ describe('Marked', () => {
|
||||
renderer: {
|
||||
heading() {
|
||||
return 'im marked1';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const marked2 = new Marked();
|
||||
@ -44,8 +44,8 @@ describe('Marked', () => {
|
||||
renderer: {
|
||||
heading() {
|
||||
return 'im marked2';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(marked1.parse('# header'), 'im marked1');
|
||||
@ -59,7 +59,7 @@ describe('Marked', () => {
|
||||
marked1Renderer.heading = () => 'im marked1';
|
||||
marked1.setOptions({
|
||||
silent: true,
|
||||
renderer: marked1Renderer
|
||||
renderer: marked1Renderer,
|
||||
});
|
||||
|
||||
const marked2 = new Marked();
|
||||
@ -67,7 +67,7 @@ describe('Marked', () => {
|
||||
marked2Renderer.heading = () => 'im marked2';
|
||||
marked2.setOptions({
|
||||
silent: true,
|
||||
renderer: marked2Renderer
|
||||
renderer: marked2Renderer,
|
||||
});
|
||||
|
||||
assert.strictEqual(marked1.parse('# header'), 'im marked1');
|
||||
@ -81,8 +81,8 @@ describe('Marked', () => {
|
||||
renderer: {
|
||||
heading() {
|
||||
return 'test';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
const tokens = marked1.lexer('# hi');
|
||||
const html = marked1.parser(tokens);
|
||||
@ -116,7 +116,7 @@ describe('Marked', () => {
|
||||
raw: src,
|
||||
depth: 1,
|
||||
text: 'im marked tokenizer',
|
||||
tokens: this.lexer.inlineTokens('im marked tokenizer')
|
||||
tokens: this.lexer.inlineTokens('im marked tokenizer'),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -84,13 +84,13 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'underline',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
|
||||
text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<u>${token.text}</u>\n`;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use({ extensions: [underline] });
|
||||
let html = marked.parse('Not Underlined\n:Underlined\nNot Underlined');
|
||||
@ -113,14 +113,14 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'underline',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
|
||||
text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<u>${token.text}</u>\n`;
|
||||
}
|
||||
}]
|
||||
},
|
||||
}],
|
||||
};
|
||||
marked.use(underline);
|
||||
const html = marked.parse('Not Underlined A\n:Underlined B:\nNot Underlined C\n:Not Underlined D');
|
||||
@ -139,13 +139,13 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'underline',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
|
||||
text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<u>${token.text}</u>`;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use({ extensions: [underline] });
|
||||
const html = marked.parse('Not Underlined =Underlined= Not Underlined');
|
||||
@ -170,7 +170,7 @@ describe('marked unit', () => {
|
||||
type: 'descriptionList',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[0].trim(), // You can add additional properties to your tokens to pass along to the renderer
|
||||
tokens: []
|
||||
tokens: [],
|
||||
};
|
||||
this.lexer.inlineTokens(token.text, token.tokens);
|
||||
return token;
|
||||
@ -178,7 +178,7 @@ describe('marked unit', () => {
|
||||
},
|
||||
renderer(token) {
|
||||
return `<dl>${this.parser.parseInline(token.tokens)}\n</dl>`;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const description = {
|
||||
@ -193,7 +193,7 @@ describe('marked unit', () => {
|
||||
type: 'description',
|
||||
raw: match[0],
|
||||
dt: [],
|
||||
dd: []
|
||||
dd: [],
|
||||
};
|
||||
this.lexer.inline(match[1].trim(), token.dt);
|
||||
this.lexer.inline(match[2].trim(), token.dd);
|
||||
@ -202,7 +202,7 @@ describe('marked unit', () => {
|
||||
},
|
||||
renderer(token) {
|
||||
return `\n<dt>${this.parser.parseInline(token.dt)}</dt><dd>${this.parser.parseInline(token.dd)}</dd>`;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use({ extensions: [descriptionlist, description] });
|
||||
const html = marked.parse('A Description List with One Description:\n'
|
||||
@ -227,13 +227,13 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'underline',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
|
||||
text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<u>${token.text}</u>\n`;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use({ silent: true, extensions: [extension] });
|
||||
const html = marked.parse(':test:\ntest\n<div></div>');
|
||||
@ -251,7 +251,7 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'test',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
|
||||
text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
|
||||
};
|
||||
}
|
||||
},
|
||||
@ -260,7 +260,7 @@ describe('marked unit', () => {
|
||||
return 'test';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
const fallbackRenderer = {
|
||||
name: 'test',
|
||||
@ -270,7 +270,7 @@ describe('marked unit', () => {
|
||||
return 'fallback';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use({ extensions: [fallbackRenderer, extension] });
|
||||
const html = marked.parse(':Test:\n\n:test:\n\n:none:');
|
||||
@ -288,14 +288,14 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'test',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
|
||||
text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
|
||||
};
|
||||
}
|
||||
return false;
|
||||
},
|
||||
renderer(token) {
|
||||
return token.text;
|
||||
}
|
||||
},
|
||||
};
|
||||
const extension2 = {
|
||||
name: 'test',
|
||||
@ -308,12 +308,12 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'test',
|
||||
raw: match[0],
|
||||
text: match[1].trim().toUpperCase()
|
||||
text: match[1].trim().toUpperCase(),
|
||||
};
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use({ extensions: [extension, extension2] });
|
||||
const html = marked.parse(':Test:\n\n:test:');
|
||||
@ -330,7 +330,7 @@ describe('marked unit', () => {
|
||||
},
|
||||
renderer(token) {
|
||||
return '<h' + token.depth + '>' + token.text + ' RENDERER EXTENSION</h' + token.depth + '>\n';
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'code',
|
||||
@ -342,14 +342,14 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: 'code',
|
||||
raw: match[0],
|
||||
text: match[1].trim() + ' TOKENIZER EXTENSION'
|
||||
text: match[1].trim() + ' TOKENIZER EXTENSION',
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return false; // fall back to default `code` renderer
|
||||
}
|
||||
}]
|
||||
},
|
||||
}],
|
||||
};
|
||||
marked.use(extension);
|
||||
const html = marked.parse('# extension1\n:extension2:');
|
||||
@ -371,7 +371,7 @@ describe('marked unit', () => {
|
||||
raw: match[0],
|
||||
dt: this.lexer.inline(match[1].trim()),
|
||||
dd: [],
|
||||
tokens: []
|
||||
tokens: [],
|
||||
};
|
||||
this.lexer.inline(match[2].trim(), token.dd);
|
||||
this.lexer.inline('unwalked', token.tokens);
|
||||
@ -381,13 +381,13 @@ describe('marked unit', () => {
|
||||
renderer(token) {
|
||||
return `\n<dt>${this.parser.parseInline(token.dt)} - ${this.parser.parseInline(token.tokens)}</dt><dd>${this.parser.parseInline(token.dd)}</dd>`;
|
||||
},
|
||||
childTokens: ['dd', 'dt']
|
||||
childTokens: ['dd', 'dt'],
|
||||
}],
|
||||
walkTokens(token) {
|
||||
if (token.type === 'text') {
|
||||
token.text += ' walked';
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use(walkableDescription);
|
||||
const html = marked.parse(': Topic 1 : Description 1\n'
|
||||
@ -410,7 +410,7 @@ describe('marked unit', () => {
|
||||
type: 'walkableDescription',
|
||||
raw: match[0],
|
||||
dt: [this.lexer.inline(match[1].trim())],
|
||||
dd: [[this.lexer.inline(match[2].trim())]]
|
||||
dd: [[this.lexer.inline(match[2].trim())]],
|
||||
};
|
||||
return token;
|
||||
}
|
||||
@ -418,13 +418,13 @@ describe('marked unit', () => {
|
||||
renderer(token) {
|
||||
return `\n<dt>${this.parser.parseInline(token.dt[0])}</dt><dd>${this.parser.parseInline(token.dd[0][0])}</dd>`;
|
||||
},
|
||||
childTokens: ['dd', 'dt']
|
||||
childTokens: ['dd', 'dt'],
|
||||
}],
|
||||
walkTokens(token) {
|
||||
if (token.type === 'text') {
|
||||
token.text += ' walked';
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use(walkableDescription);
|
||||
const html = marked.parse(': Topic 1 : Description 1\n'
|
||||
@ -447,7 +447,7 @@ describe('marked unit', () => {
|
||||
type: `block-${name}`,
|
||||
raw: `::${name}\n`,
|
||||
text,
|
||||
tokens: []
|
||||
tokens: [],
|
||||
};
|
||||
this.lexer.inline(token.text, token.tokens);
|
||||
return token;
|
||||
@ -455,7 +455,7 @@ describe('marked unit', () => {
|
||||
},
|
||||
renderer(token) {
|
||||
return `<${token.type}>${this.parser.parseInline(token.tokens)}</${token.type}>\n`;
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: `inline-${name}`,
|
||||
level: 'inline',
|
||||
@ -465,13 +465,13 @@ describe('marked unit', () => {
|
||||
return {
|
||||
type: `inline-${name}`,
|
||||
raw: `:${name}`,
|
||||
text: `used ${name}`
|
||||
text: `used ${name}`,
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return token.text;
|
||||
}
|
||||
},
|
||||
}],
|
||||
tokenizer: {
|
||||
heading(src) {
|
||||
@ -481,13 +481,13 @@ describe('marked unit', () => {
|
||||
raw: `# ${name}`,
|
||||
text: `used ${name}`,
|
||||
depth: 1,
|
||||
tokens: []
|
||||
tokens: [],
|
||||
};
|
||||
this.lexer.inline(token.text, token.tokens);
|
||||
return token;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
useNewRenderer: true,
|
||||
renderer: {
|
||||
@ -496,13 +496,13 @@ describe('marked unit', () => {
|
||||
return `<h${depth}>${text}</h${depth}>\n`;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
walkTokens(token) {
|
||||
if (token.text === `used ${name}`) {
|
||||
token.text += ' walked';
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ describe('marked unit', () => {
|
||||
},
|
||||
renderer(token) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}, {
|
||||
name: `inline-${name}`,
|
||||
level: 'inline',
|
||||
@ -527,8 +527,8 @@ describe('marked unit', () => {
|
||||
},
|
||||
renderer(token) {
|
||||
return false;
|
||||
}
|
||||
}]
|
||||
},
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ used extension2 walked</p>
|
||||
it('should merge extensions when calling marked.use with multiple extensions', () => {
|
||||
marked.use(
|
||||
createExtension('extension1'),
|
||||
createExtension('extension2')
|
||||
createExtension('extension2'),
|
||||
);
|
||||
|
||||
runTest();
|
||||
@ -579,7 +579,7 @@ used extension2 walked</p>
|
||||
createExtension('extension1'),
|
||||
createExtension('extension2'),
|
||||
createFalseExtension('extension1'),
|
||||
createFalseExtension('extension2')
|
||||
createFalseExtension('extension2'),
|
||||
);
|
||||
|
||||
runTest();
|
||||
@ -591,7 +591,7 @@ used extension2 walked</p>
|
||||
{ tokenizer: {} },
|
||||
{ renderer: {} },
|
||||
{ walkTokens: () => {} },
|
||||
{ extensions: [] }
|
||||
{ extensions: [] },
|
||||
);
|
||||
|
||||
// should not throw
|
||||
@ -602,7 +602,7 @@ used extension2 walked</p>
|
||||
it('should be async if any extension in use args is async', () => {
|
||||
marked.use(
|
||||
{ async: true },
|
||||
{ async: false }
|
||||
{ async: false },
|
||||
);
|
||||
|
||||
assert.ok(marked.defaults.async);
|
||||
@ -654,10 +654,10 @@ used extension2 walked</p>
|
||||
return {
|
||||
type: 'inlineStyleTag',
|
||||
raw: match[0], // This is the text that you want your token to consume from the source
|
||||
text: match[1]
|
||||
text: match[1],
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styled',
|
||||
@ -669,7 +669,7 @@ used extension2 walked</p>
|
||||
return `${openingTag[1]} ${token.style}${openingTag[2]}`;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
},
|
||||
}],
|
||||
walkTokens(token) {
|
||||
if (token.tokens) {
|
||||
@ -681,7 +681,7 @@ used extension2 walked</p>
|
||||
token.tokens.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use(styleTags);
|
||||
const html = marked.parse('This is a *paragraph* with blue text. {blue}\n'
|
||||
@ -696,8 +696,8 @@ used extension2 walked</p>
|
||||
renderer: {
|
||||
paragraph() {
|
||||
return 'extension';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
mock.method(extension.renderer, 'paragraph');
|
||||
marked.use(extension);
|
||||
@ -714,12 +714,12 @@ used extension2 walked</p>
|
||||
type: 'paragraph',
|
||||
raw: text,
|
||||
text: 'extension',
|
||||
tokens: []
|
||||
tokens: [],
|
||||
};
|
||||
this.lexer.inline(token.text, token.tokens);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
mock.method(extension.tokenizer, 'paragraph');
|
||||
marked.use(extension);
|
||||
@ -733,7 +733,7 @@ used extension2 walked</p>
|
||||
const extension = {
|
||||
walkTokens(token) {
|
||||
walked++;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use(extension);
|
||||
marked.parse('text');
|
||||
@ -742,7 +742,7 @@ used extension2 walked</p>
|
||||
|
||||
it('should use options from extension', () => {
|
||||
const extension = {
|
||||
breaks: true
|
||||
breaks: true,
|
||||
};
|
||||
marked.use(extension);
|
||||
const html = marked.parse('line1\nline2');
|
||||
@ -757,13 +757,13 @@ used extension2 walked</p>
|
||||
if (token.walkedOnce) {
|
||||
walkedTwice++;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
const extension2 = {
|
||||
walkTokens(token) {
|
||||
walkedOnce++;
|
||||
token.walkedOnce = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
marked.use(extension1);
|
||||
marked.use(extension2);
|
||||
@ -781,16 +781,16 @@ used extension2 walked</p>
|
||||
},
|
||||
html() {
|
||||
return 'extension1 html\n';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
const extension2 = {
|
||||
useNewRenderer: true,
|
||||
renderer: {
|
||||
paragraph() {
|
||||
return 'extension2 paragraph\n';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
marked.use(extension1);
|
||||
marked.use(extension2);
|
||||
@ -813,8 +813,8 @@ paragraph
|
||||
return 'extension1 paragraph\n';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
const extension2 = {
|
||||
useNewRenderer: true,
|
||||
@ -824,8 +824,8 @@ paragraph
|
||||
return 'extension2 paragraph\n';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
marked.use(extension1);
|
||||
marked.use(extension2);
|
||||
@ -851,8 +851,8 @@ original
|
||||
},
|
||||
paragraph() {
|
||||
return this.options ? 'shorthand options\n' : 'shorthand no options\n';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
marked.use(extension);
|
||||
const html = marked.parse(`
|
||||
@ -964,7 +964,7 @@ br
|
||||
['paragraph', 'brbr'],
|
||||
['text', 'br'],
|
||||
['br', ''],
|
||||
['text', 'br']
|
||||
['text', 'br'],
|
||||
]);
|
||||
});
|
||||
|
||||
@ -975,7 +975,7 @@ br
|
||||
token.text += ' walked';
|
||||
token.tokens = this.Lexer.lexInline(token.text);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
assert.strictEqual(marked.parse('*text*').trim(), '<p><em>text walked</em></p>');
|
||||
});
|
||||
@ -989,7 +989,7 @@ br
|
||||
token.text += ' walked';
|
||||
token.tokens = this.Lexer.lexInline(token.text);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
const promise = marked.parse('*text*');
|
||||
assert.ok(promise instanceof Promise);
|
||||
@ -999,7 +999,7 @@ br
|
||||
|
||||
it('should return promise if async and no walkTokens function', async() => {
|
||||
marked.use({
|
||||
async: true
|
||||
async: true,
|
||||
});
|
||||
const promise = marked.parse('*text*');
|
||||
assert.ok(promise instanceof Promise);
|
||||
|
2
test/update-specs.js
vendored
2
test/update-specs.js
vendored
@ -57,7 +57,7 @@ async function updateGfm(dir) {
|
||||
section: `[extension] ${section}`,
|
||||
html,
|
||||
markdown,
|
||||
example
|
||||
example,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user