Compare commits
75 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b4eb83bbb4 | ||
|
7a6b2d7191 | ||
|
9b8b1117ba | ||
|
d04a040f85 | ||
|
5672651e7c | ||
|
89818b26e6 | ||
|
2516064051 | ||
|
ed78e7f000 | ||
|
9fcb8bbe64 | ||
|
f455d412f1 | ||
|
440cebdb54 | ||
|
71d3e95f38 | ||
|
ea13bbe1e6 | ||
|
2c0e47a4ce | ||
|
d5bc76eb3c | ||
|
e071e25d13 | ||
|
c37336c241 | ||
|
72b63739f4 | ||
|
d5e5f8fbbc | ||
|
16b34a064b | ||
|
7e188fea12 | ||
|
1dc18c6fe9 | ||
|
3fc5c1d3e6 | ||
|
fc85f92607 | ||
|
721dc58ceb | ||
|
1ac6bc1f83 | ||
|
d120e014d3 | ||
|
b5bcd7c8ba | ||
|
11b82b9015 | ||
|
0efaf92110 | ||
|
7fee000577 | ||
|
a530fb41c6 | ||
|
7c30e003e3 | ||
|
c057321c2e | ||
|
7b0a4cc1c7 | ||
|
20b49ff6dd | ||
|
603a64a977 | ||
|
f92bdceb2c | ||
|
b9df3fe1d7 | ||
|
0177389ca1 | ||
|
aa7a8a2b89 | ||
|
9c9fb82ed6 | ||
|
74a36bf74c | ||
|
9cbb7a6c33 | ||
|
13a385ecc6 | ||
|
f967af5b3b | ||
|
bf4952f495 | ||
|
2b996929b2 | ||
|
9ae87de7cb | ||
|
a1113e02ca | ||
|
eb61090b41 | ||
|
00576d2daa | ||
|
570450c419 | ||
|
5fccfb29ef | ||
|
b114f210e2 | ||
|
29cf001226 | ||
|
9f2926c53f | ||
|
dba110830b | ||
|
218d77a40a | ||
|
c71d355737 | ||
|
5624378bd3 | ||
|
e6a5413393 | ||
|
1ae07972db | ||
|
6ae1e9d46d | ||
|
7430f4307d | ||
|
7712a5324f | ||
|
42ac48b9b4 | ||
|
8a01658cac | ||
|
33eb5c6a3a | ||
|
476b85e99a | ||
|
efa72f913e | ||
|
eeb7bb46f8 | ||
|
32008109fe | ||
|
b43380068a | ||
|
97343e1aa8 |
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -31,6 +31,8 @@ jobs:
|
|||||||
run: npm run test:unit
|
run: npm run test:unit
|
||||||
- name: Run Spec Tests 👩🏽💻
|
- name: Run Spec Tests 👩🏽💻
|
||||||
run: npm run test:specs
|
run: npm run test:specs
|
||||||
|
- name: Run CJS Tests 👩🏽💻
|
||||||
|
run: npm run test:cjs
|
||||||
|
|
||||||
OtherTests:
|
OtherTests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { marked } from '../lib/marked.esm.js';
|
import { marked } from '../lib/marked.esm.js';
|
||||||
import { createRequire } from 'node:module';
|
import pkg from '../package.json' with { type: 'json' };
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
const version = require('../package.json').version;
|
const version = pkg.version;
|
||||||
const name = 'Marked';
|
const name = 'Marked';
|
||||||
|
|
||||||
export default function dingus(req, res) {
|
export default function dingus(req, res) {
|
||||||
|
@ -85,6 +85,7 @@ Marked can be extended using [custom extensions](/using_pro#extensions). This is
|
|||||||
|[Alert](https://github.com/bent10/marked-extensions/tree/main/packages/alert)|[`marked-alert`](https://www.npmjs.com/package/marked-alert)|Enables [GFM alerts](https://github.com/orgs/community/discussions/16925)|
|
|[Alert](https://github.com/bent10/marked-extensions/tree/main/packages/alert)|[`marked-alert`](https://www.npmjs.com/package/marked-alert)|Enables [GFM alerts](https://github.com/orgs/community/discussions/16925)|
|
||||||
|[Base URL](https://github.com/markedjs/marked-base-url)|[`marked-base-url`](https://www.npmjs.com/package/marked-base-url)|Prefix relative urls with a base URL.|
|
|[Base URL](https://github.com/markedjs/marked-base-url)|[`marked-base-url`](https://www.npmjs.com/package/marked-base-url)|Prefix relative urls with a base URL.|
|
||||||
|[Bidi](https://github.com/markedjs/marked-bidi)|[`marked-bidi`](https://www.npmjs.com/package/marked-bidi)|Add Bidirectional text support to the HTML|
|
|[Bidi](https://github.com/markedjs/marked-bidi)|[`marked-bidi`](https://www.npmjs.com/package/marked-bidi)|Add Bidirectional text support to the HTML|
|
||||||
|
|[CJK Breaks](https://github.com/chirsz-ever/marked-cjk-breaks)|[`marked-cjk-breaks`](https://www.npmjs.com/package/marked-cjk-breaks)|Suppress soft linebreaks between east asian characters.|
|
||||||
|[Code Format](https://github.com/bent10/marked-extensions/tree/main/packages/code-format)|[`marked-code-format`](https://www.npmjs.com/package/marked-code-format)|Formatting code blocks using Prettier|
|
|[Code Format](https://github.com/bent10/marked-extensions/tree/main/packages/code-format)|[`marked-code-format`](https://www.npmjs.com/package/marked-code-format)|Formatting code blocks using Prettier|
|
||||||
|[Code JSX Renderer](https://github.com/bent10/marked-extensions/tree/main/packages/code-jsx-renderer)|[`marked-code-jsx-renderer`](https://www.npmjs.com/package/marked-code-jsx-renderer)|Render JSX code blocks using a custom renderer and components|
|
|[Code JSX Renderer](https://github.com/bent10/marked-extensions/tree/main/packages/code-jsx-renderer)|[`marked-code-jsx-renderer`](https://www.npmjs.com/package/marked-code-jsx-renderer)|Render JSX code blocks using a custom renderer and components|
|
||||||
|[Code Preview](https://github.com/bent10/marked-extensions/tree/main/packages/code-preview)|[`marked-code-preview`](https://www.npmjs.com/package/marked-code-preview)|Transform code blocks into code previews|
|
|[Code Preview](https://github.com/bent10/marked-extensions/tree/main/packages/code-preview)|[`marked-code-preview`](https://www.npmjs.com/package/marked-code-preview)|Transform code blocks into code previews|
|
||||||
@ -105,6 +106,7 @@ Marked can be extended using [custom extensions](/using_pro#extensions). This is
|
|||||||
|[Sequential Hooks](https://github.com/bent10/marked-extensions/tree/main/packages/sequential-hooks)|[`marked-sequential-hooks`](https://www.npmjs.com/package/marked-sequential-hooks)|Enables the sequential preprocessing and post-processing within [sequential hooks](https://github.com/bent10/marked-extensions#sequential-hooks)|
|
|[Sequential Hooks](https://github.com/bent10/marked-extensions/tree/main/packages/sequential-hooks)|[`marked-sequential-hooks`](https://www.npmjs.com/package/marked-sequential-hooks)|Enables the sequential preprocessing and post-processing within [sequential hooks](https://github.com/bent10/marked-extensions#sequential-hooks)|
|
||||||
|[Smartypants](https://github.com/markedjs/marked-smartypants)|[`marked-smartypants`](https://www.npmjs.com/package/marked-smartypants)|Use [smartypants](https://www.npmjs.com/package/smartypants) to use "smart" typographic punctuation for things like quotes and dashes.|
|
|[Smartypants](https://github.com/markedjs/marked-smartypants)|[`marked-smartypants`](https://www.npmjs.com/package/marked-smartypants)|Use [smartypants](https://www.npmjs.com/package/smartypants) to use "smart" typographic punctuation for things like quotes and dashes.|
|
||||||
|[Smartypants lite](https://github.com/calculuschild/marked-smartypants-lite)|[`marked-smartypants-lite`](https://www.npmjs.com/package/marked-smartypants-lite)|A faster lighter version of marked-smartypants that doesn't use any external dependencies to create "smart" typographic punctuation for things like quotes and dashes.|
|
|[Smartypants lite](https://github.com/calculuschild/marked-smartypants-lite)|[`marked-smartypants-lite`](https://www.npmjs.com/package/marked-smartypants-lite)|A faster lighter version of marked-smartypants that doesn't use any external dependencies to create "smart" typographic punctuation for things like quotes and dashes.|
|
||||||
|
|[Typograf](https://github.com/laidrivm/marked-typograf)|[`marked-typograf`](https://www.npmjs.com/package/marked-typograf)|Use [typograf](https://www.npmjs.com/package/typograf) as a more powerful and extendable alternative to Smartypants for creating “smart” typographic punctuation, such as quotes and dashes.|
|
||||||
|[XHTML](https://github.com/markedjs/marked-xhtml)|[`marked-xhtml`](https://www.npmjs.com/package/marked-xhtml)|Emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.|
|
|[XHTML](https://github.com/markedjs/marked-xhtml)|[`marked-xhtml`](https://www.npmjs.com/package/marked-xhtml)|Emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.|
|
||||||
|
|
||||||
<h2 id="inline">Inline Markdown</h2>
|
<h2 id="inline">Inline Markdown</h2>
|
||||||
|
61
esbuild.config.js
Normal file
61
esbuild.config.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import * as esbuild from 'esbuild';
|
||||||
|
import { umdWrapper } from 'esbuild-plugin-umd-wrapper';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(fs.readFileSync('./package.json')).version;
|
||||||
|
|
||||||
|
console.log('building version:', version);
|
||||||
|
|
||||||
|
const banner = `/**
|
||||||
|
* marked v${version} - a markdown parser
|
||||||
|
* Copyright (c) 2011-${new Date().getFullYear()}, Christopher Jeffrey. (MIT Licensed)
|
||||||
|
* https://github.com/markedjs/marked
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT EDIT THIS FILE
|
||||||
|
* The code in this file is generated from files in ./src/
|
||||||
|
*/
|
||||||
|
`;
|
||||||
|
|
||||||
|
function config(options) {
|
||||||
|
return {
|
||||||
|
entryPoints: ['src/marked.ts'],
|
||||||
|
banner: {
|
||||||
|
js: banner,
|
||||||
|
},
|
||||||
|
sourcemap: true,
|
||||||
|
bundle: true,
|
||||||
|
minify: false,
|
||||||
|
...(options.format === 'umd'
|
||||||
|
? {
|
||||||
|
plugins: [umdWrapper({
|
||||||
|
libraryName: 'marked',
|
||||||
|
})],
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
await esbuild.build(config({
|
||||||
|
format: 'esm',
|
||||||
|
outfile: 'lib/marked.esm.js',
|
||||||
|
}));
|
||||||
|
|
||||||
|
await esbuild.build(config({
|
||||||
|
format: 'cjs',
|
||||||
|
outfile: 'lib/marked.cjs',
|
||||||
|
}));
|
||||||
|
|
||||||
|
await esbuild.build(config({
|
||||||
|
format: 'umd',
|
||||||
|
outfile: 'lib/marked.umd.js',
|
||||||
|
}));
|
||||||
|
|
||||||
|
await esbuild.build(config({
|
||||||
|
sourcemap: false,
|
||||||
|
minify: true,
|
||||||
|
format: 'umd',
|
||||||
|
outfile: 'marked.min.js',
|
||||||
|
}));
|
1596
package-lock.json
generated
1596
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@ -2,7 +2,7 @@
|
|||||||
"name": "marked",
|
"name": "marked",
|
||||||
"description": "A markdown parser built for speed",
|
"description": "A markdown parser built for speed",
|
||||||
"author": "Christopher Jeffrey",
|
"author": "Christopher Jeffrey",
|
||||||
"version": "15.0.4",
|
"version": "15.0.12",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./lib/marked.cjs",
|
"main": "./lib/marked.cjs",
|
||||||
"module": "./lib/marked.esm.js",
|
"module": "./lib/marked.esm.js",
|
||||||
@ -36,7 +36,10 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"provenance": true
|
"provenance": true
|
||||||
},
|
},
|
||||||
"repository": "git://github.com/markedjs/marked.git",
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/markedjs/marked.git"
|
||||||
|
},
|
||||||
"homepage": "https://marked.js.org",
|
"homepage": "https://marked.js.org",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "http://github.com/markedjs/marked/issues"
|
"url": "http://github.com/markedjs/marked/issues"
|
||||||
@ -53,44 +56,44 @@
|
|||||||
"html"
|
"html"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@arethetypeswrong/cli": "^0.17.1",
|
"@arethetypeswrong/cli": "^0.18.1",
|
||||||
"@markedjs/eslint-config": "^1.0.9",
|
"@markedjs/eslint-config": "^1.0.12",
|
||||||
"@markedjs/testutils": "14.1.1-0",
|
"@markedjs/testutils": "14.1.1-0",
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
||||||
"@rollup/plugin-typescript": "^12.1.1",
|
|
||||||
"@semantic-release/commit-analyzer": "^13.0.0",
|
|
||||||
"@semantic-release/git": "^10.0.1",
|
"@semantic-release/git": "^10.0.1",
|
||||||
"@semantic-release/github": "^11.0.1",
|
"@semantic-release/github": "^11.0.2",
|
||||||
"@semantic-release/npm": "^12.0.1",
|
"@semantic-release/npm": "^12.0.1",
|
||||||
"@semantic-release/release-notes-generator": "^14.0.1",
|
"@semantic-release/release-notes-generator": "^14.0.3",
|
||||||
"cheerio": "1.0.0",
|
"cheerio": "1.0.0",
|
||||||
"commonmark": "0.31.2",
|
"commonmark": "0.31.2",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"dts-bundle-generator": "^9.5.1",
|
"dts-bundle-generator": "^9.5.1",
|
||||||
"eslint": "^9.16.0",
|
"esbuild": "^0.25.3",
|
||||||
"highlight.js": "^11.10.0",
|
"esbuild-plugin-umd-wrapper": "^3.0.0",
|
||||||
|
"eslint": "^9.27.0",
|
||||||
|
"highlight.js": "^11.11.1",
|
||||||
"markdown-it": "14.1.0",
|
"markdown-it": "14.1.0",
|
||||||
"marked-highlight": "^2.2.1",
|
"marked-highlight": "^2.2.1",
|
||||||
"marked-man": "^2.1.0",
|
"marked-man": "^2.1.0",
|
||||||
"recheck": "^4.4.5",
|
"recheck": "^4.5.0",
|
||||||
"rollup": "^4.28.1",
|
"semantic-release": "^24.2.4",
|
||||||
"semantic-release": "^24.2.0",
|
|
||||||
"titleize": "^4.0.0",
|
"titleize": "^4.0.0",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "5.7.2"
|
"typescript": "5.8.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bench": "npm run build && node test/bench.js",
|
"bench": "npm run build && node test/bench.js",
|
||||||
"build": "npm run rollup && npm run build:types && npm run build:man",
|
"build": "npm run build:esbuild && npm run build:types && npm run build:man",
|
||||||
"build:docs": "npm run build && node docs/build.js",
|
"build:docs": "npm run build && node docs/build.js",
|
||||||
|
"build:esbuild": "node esbuild.config.js",
|
||||||
"build:man": "marked-man man/marked.1.md > man/marked.1",
|
"build:man": "marked-man man/marked.1.md > man/marked.1",
|
||||||
"build:reset": "git checkout upstream/master lib/marked.cjs lib/marked.umd.js lib/marked.esm.js marked.min.js",
|
"build:reset": "git checkout upstream/master lib/marked.cjs lib/marked.umd.js lib/marked.esm.js marked.min.js",
|
||||||
"build:types": "tsc && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/marked.d.ts src/marked.ts && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/marked.d.cts src/marked.ts",
|
"build:types": "tsc && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/marked.d.ts src/marked.ts && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/marked.d.cts src/marked.ts",
|
||||||
"lint": "eslint --fix",
|
"lint": "eslint --fix",
|
||||||
"rollup": "rollup -c rollup.config.js",
|
|
||||||
"rules": "node test/rules.js",
|
"rules": "node test/rules.js",
|
||||||
"test": "npm run build && npm run test:specs && npm run test:unit",
|
"test": "npm run build && npm run test:specs && npm run test:unit",
|
||||||
"test:all": "npm test && npm run test:umd && npm run test:types && npm run test:lint",
|
"test:all": "npm test && npm run test:umd && npm run test:cjs && npm run test:types && npm run test:lint",
|
||||||
|
"test:cjs": "node test/cjs-test.cjs",
|
||||||
"test:lint": "eslint",
|
"test:lint": "eslint",
|
||||||
"test:only": "npm run build && npm run test:specs:only && npm run test:unit:only",
|
"test:only": "npm run build && npm run test:specs:only && npm run test:unit:only",
|
||||||
"test:redos": "node test/recheck.js > vuln.js",
|
"test:redos": "node test/recheck.js > vuln.js",
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
import typescript from '@rollup/plugin-typescript';
|
|
||||||
import terser from '@rollup/plugin-terser';
|
|
||||||
import { defineConfig } from 'rollup';
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(fs.readFileSync('./package.json')).version;
|
|
||||||
|
|
||||||
console.log('building version:', version);
|
|
||||||
|
|
||||||
const banner = `/**
|
|
||||||
* marked v${version} - a markdown parser
|
|
||||||
* Copyright (c) 2011-${new Date().getFullYear()}, Christopher Jeffrey. (MIT Licensed)
|
|
||||||
* https://github.com/markedjs/marked
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DO NOT EDIT THIS FILE
|
|
||||||
* The code in this file is generated from files in ./src/
|
|
||||||
*/
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default defineConfig([
|
|
||||||
{
|
|
||||||
input: 'src/marked.ts',
|
|
||||||
output: [{
|
|
||||||
file: 'lib/marked.esm.js',
|
|
||||||
format: 'esm',
|
|
||||||
sourcemap: true,
|
|
||||||
banner,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: 'lib/marked.umd.js',
|
|
||||||
format: 'umd',
|
|
||||||
name: 'marked',
|
|
||||||
sourcemap: true,
|
|
||||||
banner,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: 'marked.min.js',
|
|
||||||
format: 'umd',
|
|
||||||
name: 'marked',
|
|
||||||
sourcemap: false,
|
|
||||||
banner,
|
|
||||||
plugins: [terser({
|
|
||||||
format: {
|
|
||||||
comments: (node, comment) => {
|
|
||||||
if (comment.type === 'comment2') {
|
|
||||||
return comment.value.includes('Copyright (c)');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: 'lib/marked.cjs',
|
|
||||||
format: 'cjs',
|
|
||||||
name: 'marked',
|
|
||||||
sourcemap: true,
|
|
||||||
banner,
|
|
||||||
}],
|
|
||||||
plugins: [
|
|
||||||
typescript(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]);
|
|
@ -312,16 +312,17 @@ export class _Lexer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Mask out other blocks
|
|
||||||
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
||||||
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mask out escaped characters
|
// Mask out escaped characters
|
||||||
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
|
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
|
||||||
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mask out other blocks
|
||||||
|
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
||||||
|
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
||||||
|
}
|
||||||
|
|
||||||
let keepPrevChar = false;
|
let keepPrevChar = false;
|
||||||
let prevChar = '';
|
let prevChar = '';
|
||||||
while (src) {
|
while (src) {
|
||||||
|
@ -193,7 +193,10 @@ export class _Renderer {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
image({ href, title, text }: Tokens.Image): string {
|
image({ href, title, text, tokens }: Tokens.Image): string {
|
||||||
|
if (tokens) {
|
||||||
|
text = this.parser.parseInline(tokens, this.parser.textRenderer);
|
||||||
|
}
|
||||||
const cleanHref = cleanUrl(href);
|
const cleanHref = cleanUrl(href);
|
||||||
if (cleanHref === null) {
|
if (cleanHref === null) {
|
||||||
return escape(text);
|
return escape(text);
|
||||||
|
@ -14,10 +14,9 @@ function outputLink(cap: string[], link: Pick<Tokens.Link, 'href' | 'title'>, ra
|
|||||||
const title = link.title || null;
|
const title = link.title || null;
|
||||||
const text = cap[1].replace(rules.other.outputLinkReplace, '$1');
|
const text = cap[1].replace(rules.other.outputLinkReplace, '$1');
|
||||||
|
|
||||||
if (cap[0].charAt(0) !== '!') {
|
|
||||||
lexer.state.inLink = true;
|
lexer.state.inLink = true;
|
||||||
const token: Tokens.Link = {
|
const token: Tokens.Link | Tokens.Image = {
|
||||||
type: 'link',
|
type: cap[0].charAt(0) === '!' ? 'image' : 'link',
|
||||||
raw,
|
raw,
|
||||||
href,
|
href,
|
||||||
title,
|
title,
|
||||||
@ -26,14 +25,6 @@ function outputLink(cap: string[], link: Pick<Tokens.Link, 'href' | 'title'>, ra
|
|||||||
};
|
};
|
||||||
lexer.state.inLink = false;
|
lexer.state.inLink = false;
|
||||||
return token;
|
return token;
|
||||||
}
|
|
||||||
return {
|
|
||||||
type: 'image',
|
|
||||||
raw,
|
|
||||||
href,
|
|
||||||
title,
|
|
||||||
text,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function indentCodeCompensation(raw: string, text: string, rules: Rules) {
|
function indentCodeCompensation(raw: string, text: string, rules: Rules) {
|
||||||
@ -636,6 +627,11 @@ export class _Tokenizer {
|
|||||||
} else {
|
} else {
|
||||||
// find closing parenthesis
|
// find closing parenthesis
|
||||||
const lastParenIndex = findClosingBracket(cap[2], '()');
|
const lastParenIndex = findClosingBracket(cap[2], '()');
|
||||||
|
if (lastParenIndex === -2) {
|
||||||
|
// more open parens than closed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (lastParenIndex > -1) {
|
if (lastParenIndex > -1) {
|
||||||
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
||||||
const linkLen = start + cap[1].length + lastParenIndex;
|
const linkLen = start + cap[1].length + lastParenIndex;
|
||||||
|
@ -123,6 +123,7 @@ export namespace Tokens {
|
|||||||
href: string;
|
href: string;
|
||||||
title: string | null;
|
title: string | null;
|
||||||
text: string;
|
text: string;
|
||||||
|
tokens: Token[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Link {
|
export interface Link {
|
||||||
|
@ -141,5 +141,9 @@ export function findClosingBracket(str: string, b: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (level > 0) {
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
46
src/rules.ts
46
src/rules.ts
@ -85,13 +85,24 @@ const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\
|
|||||||
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
||||||
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
||||||
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
||||||
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
|
const lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
||||||
|
const lheading = edit(lheadingCore)
|
||||||
.replace(/bull/g, bullet) // lists can interrupt
|
.replace(/bull/g, bullet) // lists can interrupt
|
||||||
.replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
|
.replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
|
||||||
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
|
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
|
||||||
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
|
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
|
||||||
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
|
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
|
||||||
.replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
|
.replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
|
||||||
|
.replace(/\|table/g, '') // table not in commonmark
|
||||||
|
.getRegex();
|
||||||
|
const lheadingGfm = edit(lheadingCore)
|
||||||
|
.replace(/bull/g, bullet) // lists can interrupt
|
||||||
|
.replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
|
||||||
|
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
|
||||||
|
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
|
||||||
|
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
|
||||||
|
.replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
|
||||||
|
.replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/) // table can interrupt
|
||||||
.getRegex();
|
.getRegex();
|
||||||
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
||||||
const blockText = /^[^\n]+/;
|
const blockText = /^[^\n]+/;
|
||||||
@ -186,6 +197,7 @@ const gfmTable = edit(
|
|||||||
|
|
||||||
const blockGfm: Record<BlockKeys, RegExp> = {
|
const blockGfm: Record<BlockKeys, RegExp> = {
|
||||||
...blockNormal,
|
...blockNormal,
|
||||||
|
lheading: lheadingGfm,
|
||||||
table: gfmTable,
|
table: gfmTable,
|
||||||
paragraph: edit(_paragraph)
|
paragraph: edit(_paragraph)
|
||||||
.replace('hr', hr)
|
.replace('hr', hr)
|
||||||
@ -249,14 +261,25 @@ const _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
|
|||||||
const punctuation = edit(/^((?![*_])punctSpace)/, 'u')
|
const punctuation = edit(/^((?![*_])punctSpace)/, 'u')
|
||||||
.replace(/punctSpace/g, _punctuationOrSpace).getRegex();
|
.replace(/punctSpace/g, _punctuationOrSpace).getRegex();
|
||||||
|
|
||||||
|
// GFM allows ~ inside strong and em for strikethrough
|
||||||
|
const _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
|
||||||
|
const _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
|
||||||
|
const _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
|
||||||
|
|
||||||
// sequences em should skip over [title](link), `code`, <html>
|
// sequences em should skip over [title](link), `code`, <html>
|
||||||
const blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
|
const blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
|
||||||
|
|
||||||
const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, 'u')
|
const emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
|
||||||
|
|
||||||
|
const emStrongLDelim = edit(emStrongLDelimCore, 'u')
|
||||||
.replace(/punct/g, _punctuation)
|
.replace(/punct/g, _punctuation)
|
||||||
.getRegex();
|
.getRegex();
|
||||||
|
|
||||||
const emStrongRDelimAst = edit(
|
const emStrongLDelimGfm = edit(emStrongLDelimCore, 'u')
|
||||||
|
.replace(/punct/g, _punctuationGfmStrongEm)
|
||||||
|
.getRegex();
|
||||||
|
|
||||||
|
const emStrongRDelimAstCore =
|
||||||
'^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
|
'^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
|
||||||
+ '|[^*]+(?=[^*])' // Consume to delim
|
+ '|[^*]+(?=[^*])' // Consume to delim
|
||||||
+ '|(?!\\*)punct(\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
|
+ '|(?!\\*)punct(\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
|
||||||
@ -264,12 +287,20 @@ const emStrongRDelimAst = edit(
|
|||||||
+ '|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)' // (3) #***a, ***a can only be Left Delimiter
|
+ '|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)' // (3) #***a, ***a can only be Left Delimiter
|
||||||
+ '|[\\s](\\*+)(?!\\*)(?=punct)' // (4) ***# can only be Left Delimiter
|
+ '|[\\s](\\*+)(?!\\*)(?=punct)' // (4) ***# can only be Left Delimiter
|
||||||
+ '|(?!\\*)punct(\\*+)(?!\\*)(?=punct)' // (5) #***# can be either Left or Right Delimiter
|
+ '|(?!\\*)punct(\\*+)(?!\\*)(?=punct)' // (5) #***# can be either Left or Right Delimiter
|
||||||
+ '|notPunctSpace(\\*+)(?=notPunctSpace)', 'gu') // (6) a***a can be either Left or Right Delimiter
|
+ '|notPunctSpace(\\*+)(?=notPunctSpace)'; // (6) a***a can be either Left or Right Delimiter
|
||||||
|
|
||||||
|
const emStrongRDelimAst = edit(emStrongRDelimAstCore, 'gu')
|
||||||
.replace(/notPunctSpace/g, _notPunctuationOrSpace)
|
.replace(/notPunctSpace/g, _notPunctuationOrSpace)
|
||||||
.replace(/punctSpace/g, _punctuationOrSpace)
|
.replace(/punctSpace/g, _punctuationOrSpace)
|
||||||
.replace(/punct/g, _punctuation)
|
.replace(/punct/g, _punctuation)
|
||||||
.getRegex();
|
.getRegex();
|
||||||
|
|
||||||
|
const emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, 'gu')
|
||||||
|
.replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm)
|
||||||
|
.replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm)
|
||||||
|
.replace(/punct/g, _punctuationGfmStrongEm)
|
||||||
|
.getRegex();
|
||||||
|
|
||||||
// (6) Not allowed for _
|
// (6) Not allowed for _
|
||||||
const emStrongRDelimUnd = edit(
|
const emStrongRDelimUnd = edit(
|
||||||
'^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
|
'^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
|
||||||
@ -307,9 +338,9 @@ const tag = edit(
|
|||||||
|
|
||||||
const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
||||||
|
|
||||||
const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/)
|
const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/)
|
||||||
.replace('label', _inlineLabel)
|
.replace('label', _inlineLabel)
|
||||||
.replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/)
|
.replace('href', /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/)
|
||||||
.replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
|
.replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
|
||||||
.getRegex();
|
.getRegex();
|
||||||
|
|
||||||
@ -375,7 +406,8 @@ const inlinePedantic: Record<InlineKeys, RegExp> = {
|
|||||||
|
|
||||||
const inlineGfm: Record<InlineKeys, RegExp> = {
|
const inlineGfm: Record<InlineKeys, RegExp> = {
|
||||||
...inlineNormal,
|
...inlineNormal,
|
||||||
escape: edit(escape).replace('])', '~|])').getRegex(),
|
emStrongRDelimAst: emStrongRDelimAstGfm,
|
||||||
|
emStrongLDelim: emStrongLDelimGfm,
|
||||||
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
|
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
|
||||||
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
|
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
|
||||||
.getRegex(),
|
.getRegex(),
|
||||||
|
6
test/cjs-test.cjs
vendored
Normal file
6
test/cjs-test.cjs
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
const { marked } = require('../lib/marked.cjs');
|
||||||
|
|
||||||
|
if (!marked.parse('# test').includes('<h1')) {
|
||||||
|
throw new Error('Invalid markdown');
|
||||||
|
}
|
@ -3975,8 +3975,7 @@
|
|||||||
"example": 497,
|
"example": 497,
|
||||||
"start_line": 7666,
|
"start_line": 7666,
|
||||||
"end_line": 7670,
|
"end_line": 7670,
|
||||||
"section": "Links",
|
"section": "Links"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "[link](foo\\(and\\(bar\\))\n",
|
"markdown": "[link](foo\\(and\\(bar\\))\n",
|
||||||
@ -4057,8 +4056,7 @@
|
|||||||
"example": 507,
|
"example": 507,
|
||||||
"start_line": 7776,
|
"start_line": 7776,
|
||||||
"end_line": 7780,
|
"end_line": 7780,
|
||||||
"section": "Links",
|
"section": "Links"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "[link](/url \"title \"and\" title\")\n",
|
"markdown": "[link](/url \"title \"and\" title\")\n",
|
||||||
@ -4598,8 +4596,7 @@
|
|||||||
"example": 573,
|
"example": 573,
|
||||||
"start_line": 8548,
|
"start_line": 8548,
|
||||||
"end_line": 8554,
|
"end_line": 8554,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "](/url2)\n",
|
"markdown": "](/url2)\n",
|
||||||
@ -4607,8 +4604,7 @@
|
|||||||
"example": 574,
|
"example": 574,
|
||||||
"start_line": 8557,
|
"start_line": 8557,
|
||||||
"end_line": 8561,
|
"end_line": 8561,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "](/url2)\n",
|
"markdown": "](/url2)\n",
|
||||||
@ -4616,8 +4612,7 @@
|
|||||||
"example": 575,
|
"example": 575,
|
||||||
"start_line": 8564,
|
"start_line": 8564,
|
||||||
"end_line": 8568,
|
"end_line": 8568,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n",
|
"markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n",
|
||||||
@ -4625,8 +4620,7 @@
|
|||||||
"example": 576,
|
"example": 576,
|
||||||
"start_line": 8578,
|
"start_line": 8578,
|
||||||
"end_line": 8584,
|
"end_line": 8584,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n",
|
"markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n",
|
||||||
@ -4634,8 +4628,7 @@
|
|||||||
"example": 577,
|
"example": 577,
|
||||||
"start_line": 8587,
|
"start_line": 8587,
|
||||||
"end_line": 8593,
|
"end_line": 8593,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "\n",
|
"markdown": "\n",
|
||||||
@ -4699,8 +4692,7 @@
|
|||||||
"example": 585,
|
"example": 585,
|
||||||
"start_line": 8655,
|
"start_line": 8655,
|
||||||
"end_line": 8661,
|
"end_line": 8661,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![Foo][]\n\n[foo]: /url \"title\"\n",
|
"markdown": "![Foo][]\n\n[foo]: /url \"title\"\n",
|
||||||
@ -4732,8 +4724,7 @@
|
|||||||
"example": 589,
|
"example": 589,
|
||||||
"start_line": 8700,
|
"start_line": 8700,
|
||||||
"end_line": 8706,
|
"end_line": 8706,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n",
|
"markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n",
|
||||||
|
@ -3975,8 +3975,7 @@
|
|||||||
"example": 497,
|
"example": 497,
|
||||||
"start_line": 7666,
|
"start_line": 7666,
|
||||||
"end_line": 7670,
|
"end_line": 7670,
|
||||||
"section": "Links",
|
"section": "Links"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "[link](foo\\(and\\(bar\\))\n",
|
"markdown": "[link](foo\\(and\\(bar\\))\n",
|
||||||
@ -4057,8 +4056,7 @@
|
|||||||
"example": 507,
|
"example": 507,
|
||||||
"start_line": 7776,
|
"start_line": 7776,
|
||||||
"end_line": 7780,
|
"end_line": 7780,
|
||||||
"section": "Links",
|
"section": "Links"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "[link](/url \"title \"and\" title\")\n",
|
"markdown": "[link](/url \"title \"and\" title\")\n",
|
||||||
@ -4598,8 +4596,7 @@
|
|||||||
"example": 573,
|
"example": 573,
|
||||||
"start_line": 8548,
|
"start_line": 8548,
|
||||||
"end_line": 8554,
|
"end_line": 8554,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "](/url2)\n",
|
"markdown": "](/url2)\n",
|
||||||
@ -4607,8 +4604,7 @@
|
|||||||
"example": 574,
|
"example": 574,
|
||||||
"start_line": 8557,
|
"start_line": 8557,
|
||||||
"end_line": 8561,
|
"end_line": 8561,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "](/url2)\n",
|
"markdown": "](/url2)\n",
|
||||||
@ -4616,8 +4612,7 @@
|
|||||||
"example": 575,
|
"example": 575,
|
||||||
"start_line": 8564,
|
"start_line": 8564,
|
||||||
"end_line": 8568,
|
"end_line": 8568,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n",
|
"markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n",
|
||||||
@ -4625,8 +4620,7 @@
|
|||||||
"example": 576,
|
"example": 576,
|
||||||
"start_line": 8578,
|
"start_line": 8578,
|
||||||
"end_line": 8584,
|
"end_line": 8584,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n",
|
"markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n",
|
||||||
@ -4634,8 +4628,7 @@
|
|||||||
"example": 577,
|
"example": 577,
|
||||||
"start_line": 8587,
|
"start_line": 8587,
|
||||||
"end_line": 8593,
|
"end_line": 8593,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "\n",
|
"markdown": "\n",
|
||||||
@ -4699,8 +4692,7 @@
|
|||||||
"example": 585,
|
"example": 585,
|
||||||
"start_line": 8655,
|
"start_line": 8655,
|
||||||
"end_line": 8661,
|
"end_line": 8661,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![Foo][]\n\n[foo]: /url \"title\"\n",
|
"markdown": "![Foo][]\n\n[foo]: /url \"title\"\n",
|
||||||
@ -4732,8 +4724,7 @@
|
|||||||
"example": 589,
|
"example": 589,
|
||||||
"start_line": 8700,
|
"start_line": 8700,
|
||||||
"end_line": 8706,
|
"end_line": 8706,
|
||||||
"section": "Images",
|
"section": "Images"
|
||||||
"shouldFail": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n",
|
"markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n",
|
||||||
|
9
test/specs/new/escape_tick.html
Normal file
9
test/specs/new/escape_tick.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<p><em>italics</em></p>
|
||||||
|
<p><strong>bold</strong></p>
|
||||||
|
<p><em><strong>bold italics</strong></em></p>
|
||||||
|
<p><code>*quoted italics*</code></p>
|
||||||
|
<p><code>**quoted bold**</code></p>
|
||||||
|
<p><code>***quoted bold italics***</code></p>
|
||||||
|
<p>`<em>escaped quoted italics</em>`</p>
|
||||||
|
<p>`<strong>escaped quoted bold</strong>`</p>
|
||||||
|
<p>`<em><strong>escaped quoted bold italics</strong></em>`</p>
|
17
test/specs/new/escape_tick.md
Normal file
17
test/specs/new/escape_tick.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
*italics*
|
||||||
|
|
||||||
|
**bold**
|
||||||
|
|
||||||
|
***bold italics***
|
||||||
|
|
||||||
|
`*quoted italics*`
|
||||||
|
|
||||||
|
`**quoted bold**`
|
||||||
|
|
||||||
|
`***quoted bold italics***`
|
||||||
|
|
||||||
|
\`*escaped quoted italics*\`
|
||||||
|
|
||||||
|
\`**escaped quoted bold**\`
|
||||||
|
|
||||||
|
\`***escaped quoted bold italics***\`
|
@ -17,3 +17,44 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>abc</th>
|
||||||
|
<th>def</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>bar</td>
|
||||||
|
<td>foo</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>baz</td>
|
||||||
|
<td>boo</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>text then table</p>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>abc</th>
|
||||||
|
<th>def</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>bar</td>
|
||||||
|
<td>foo</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>baz</td>
|
||||||
|
<td>boo</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
@ -3,3 +3,16 @@
|
|||||||
bar | foo
|
bar | foo
|
||||||
baz | boo
|
baz | boo
|
||||||
___
|
___
|
||||||
|
|
||||||
|
abc | def
|
||||||
|
--- | ---
|
||||||
|
bar | foo
|
||||||
|
baz | boo
|
||||||
|
---
|
||||||
|
|
||||||
|
text then table
|
||||||
|
abc | def
|
||||||
|
--- | ---
|
||||||
|
bar | foo
|
||||||
|
baz | boo
|
||||||
|
---
|
||||||
|
@ -17,3 +17,44 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>abc</th>
|
||||||
|
<th>def</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>bar</td>
|
||||||
|
<td>foo</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>baz</td>
|
||||||
|
<td>boo</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>text then table</p>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>abc</th>
|
||||||
|
<th>def</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>bar</td>
|
||||||
|
<td>foo</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>baz</td>
|
||||||
|
<td>boo</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
@ -3,3 +3,16 @@
|
|||||||
| bar | foo |
|
| bar | foo |
|
||||||
| baz | boo |
|
| baz | boo |
|
||||||
___
|
___
|
||||||
|
|
||||||
|
| abc | def |
|
||||||
|
| --- | --- |
|
||||||
|
| bar | foo |
|
||||||
|
| baz | boo |
|
||||||
|
---
|
||||||
|
|
||||||
|
text then table
|
||||||
|
| abc | def |
|
||||||
|
| --- | --- |
|
||||||
|
| bar | foo |
|
||||||
|
| baz | boo |
|
||||||
|
---
|
||||||
|
7
test/specs/new/link_unbalanced.html
Normal file
7
test/specs/new/link_unbalanced.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<p>[link](foo(bar())</p>
|
||||||
|
|
||||||
|
<p><a href="foo(bar()">link</a></p>
|
||||||
|
|
||||||
|
<p><a href="foo(bar()">link</a></p>
|
||||||
|
|
||||||
|
<p>[link](foo(bar\())</p>
|
7
test/specs/new/link_unbalanced.md
Normal file
7
test/specs/new/link_unbalanced.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[link](foo(bar())
|
||||||
|
|
||||||
|
[link](foo\(bar())
|
||||||
|
|
||||||
|
[link](foo(bar\())
|
||||||
|
|
||||||
|
[link](foo(bar\\())
|
47
test/specs/new/strikethrough_in_em_strong.html
Normal file
47
test/specs/new/strikethrough_in_em_strong.html
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<p><em><del>a</del></em>b</p>
|
||||||
|
|
||||||
|
<p><em><del>a</del></em>b</p>
|
||||||
|
|
||||||
|
<p><strong><del>a</del></strong>b</p>
|
||||||
|
|
||||||
|
<p><strong><del>a</del></strong>b</p>
|
||||||
|
|
||||||
|
<p>_<del>a</del>_b</p>
|
||||||
|
|
||||||
|
<p>_<del>a</del>_b</p>
|
||||||
|
|
||||||
|
<p>__<del>a</del>__b</p>
|
||||||
|
|
||||||
|
<p>__<del>a</del>__b</p>
|
||||||
|
|
||||||
|
<p>b<em><del>a</del></em></p>
|
||||||
|
|
||||||
|
<p>b<em><del>a</del></em></p>
|
||||||
|
|
||||||
|
<p>b<strong><del>a</del></strong></p>
|
||||||
|
|
||||||
|
<p>b<strong><del>a</del></strong></p>
|
||||||
|
|
||||||
|
<p>b_<del>a</del>_</p>
|
||||||
|
|
||||||
|
<p>b_<del>a</del>_</p>
|
||||||
|
|
||||||
|
<p>b__<del>a</del>__</p>
|
||||||
|
|
||||||
|
<p>b__<del>a</del>__</p>
|
||||||
|
|
||||||
|
<p>b<em><del>a</del></em>b</p>
|
||||||
|
|
||||||
|
<p>b<em><del>a</del></em>b</p>
|
||||||
|
|
||||||
|
<p>b<strong><del>a</del></strong>b</p>
|
||||||
|
|
||||||
|
<p>b<strong><del>a</del></strong>b</p>
|
||||||
|
|
||||||
|
<p>b_<del>a</del>_b</p>
|
||||||
|
|
||||||
|
<p>b_<del>a</del>_b</p>
|
||||||
|
|
||||||
|
<p>b__<del>a</del>__b</p>
|
||||||
|
|
||||||
|
<p>b__<del>a</del>__b</p>
|
47
test/specs/new/strikethrough_in_em_strong.md
Normal file
47
test/specs/new/strikethrough_in_em_strong.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
*~a~*b
|
||||||
|
|
||||||
|
*~~a~~*b
|
||||||
|
|
||||||
|
**~a~**b
|
||||||
|
|
||||||
|
**~~a~~**b
|
||||||
|
|
||||||
|
_~a~_b
|
||||||
|
|
||||||
|
_~~a~~_b
|
||||||
|
|
||||||
|
__~a~__b
|
||||||
|
|
||||||
|
__~~a~~__b
|
||||||
|
|
||||||
|
b*~a~*
|
||||||
|
|
||||||
|
b*~~a~~*
|
||||||
|
|
||||||
|
b**~a~**
|
||||||
|
|
||||||
|
b**~~a~~**
|
||||||
|
|
||||||
|
b_~a~_
|
||||||
|
|
||||||
|
b_~~a~~_
|
||||||
|
|
||||||
|
b__~a~__
|
||||||
|
|
||||||
|
b__~~a~~__
|
||||||
|
|
||||||
|
b*~a~*b
|
||||||
|
|
||||||
|
b*~~a~~*b
|
||||||
|
|
||||||
|
b**~a~**b
|
||||||
|
|
||||||
|
b**~~a~~**b
|
||||||
|
|
||||||
|
b_~a~_b
|
||||||
|
|
||||||
|
b_~~a~~_b
|
||||||
|
|
||||||
|
b__~a~__b
|
||||||
|
|
||||||
|
b__~~a~~__b
|
@ -104,7 +104,7 @@ class ExtendedRenderer extends marked.Renderer {
|
|||||||
br = ({ type, raw }: Tokens.Br): string => super.br({ type, raw });
|
br = ({ type, raw }: Tokens.Br): string => super.br({ type, raw });
|
||||||
del = ({ type, raw, text, tokens }: Tokens.Del): string => super.del({ type, raw, text, tokens });
|
del = ({ type, raw, text, tokens }: Tokens.Del): string => super.del({ type, raw, text, tokens });
|
||||||
link = ({ type, raw, href, title, text, tokens }: Tokens.Link): string => super.link({ type, raw, href, title, text, tokens });
|
link = ({ type, raw, href, title, text, tokens }: Tokens.Link): string => super.link({ type, raw, href, title, text, tokens });
|
||||||
image = ({ type, raw, href, title, text }: Tokens.Image): string => super.image({ type, raw, href, title, text });
|
image = ({ type, raw, href, title, text }: Tokens.Image): string => super.image({ type, raw, href, title, text, tokens });
|
||||||
}
|
}
|
||||||
|
|
||||||
const rendererOptions: MarkedOptions = renderer.options;
|
const rendererOptions: MarkedOptions = renderer.options;
|
||||||
|
@ -1340,6 +1340,12 @@ paragraph
|
|||||||
text: 'image',
|
text: 'image',
|
||||||
href: 'https://example.com/image.png',
|
href: 'https://example.com/image.png',
|
||||||
title: null,
|
title: null,
|
||||||
|
tokens: [{
|
||||||
|
type: 'text',
|
||||||
|
raw: 'image',
|
||||||
|
text: 'image',
|
||||||
|
escaped: false,
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -1355,6 +1361,12 @@ paragraph
|
|||||||
text: 'image',
|
text: 'image',
|
||||||
href: 'https://example.com/image.png',
|
href: 'https://example.com/image.png',
|
||||||
title: 'title',
|
title: 'title',
|
||||||
|
tokens: [{
|
||||||
|
type: 'text',
|
||||||
|
raw: 'image',
|
||||||
|
text: 'image',
|
||||||
|
escaped: false,
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -396,6 +396,12 @@ describe('Parser', () => {
|
|||||||
text: 'image',
|
text: 'image',
|
||||||
href: 'image.png',
|
href: 'image.png',
|
||||||
title: 'title',
|
title: 'title',
|
||||||
|
tokens: [{
|
||||||
|
type: 'text',
|
||||||
|
raw: 'image',
|
||||||
|
text: 'image',
|
||||||
|
escaped: false,
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
html: '<img src="image.png" alt="image" title="title">',
|
html: '<img src="image.png" alt="image" title="title">',
|
||||||
|
@ -959,6 +959,7 @@ br
|
|||||||
['space', ''],
|
['space', ''],
|
||||||
['paragraph', ''],
|
['paragraph', ''],
|
||||||
['image', ''],
|
['image', ''],
|
||||||
|
['text', 'image'],
|
||||||
['space', ''],
|
['space', ''],
|
||||||
['paragraph', '**strong**'],
|
['paragraph', '**strong**'],
|
||||||
['strong', '**strong**'],
|
['strong', '**strong**'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user