Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: markedjs/marked
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v12.0.0
Choose a base ref
...
head repository: markedjs/marked
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v15.0.2
Choose a head ref
Loading
Showing with 4,621 additions and 6,128 deletions.
  1. +0 −3 .eslintignore
  2. +0 −33 .eslintrc.json
  3. +2 −1 .github/workflows/tests.yml
  4. +1 −0 .gitignore
  5. +1 −0 CHANGELOG.md
  6. +0 −1 README.md
  7. +3 −3 api/dingus.js
  8. +11 −8 bin/main.js
  9. +0 −23 bower.json
  10. +1 −0 docs/INDEX.md
  11. +6 −0 docs/USING_ADVANCED.md
  12. +103 −59 docs/USING_PRO.md
  13. +1 −1 docs/build.js
  14. +8 −8 docs/demo/demo.js
  15. +4 −4 docs/demo/worker.js
  16. +8 −0 eslint.config.js
  17. +0 −12 jasmine.json
  18. +2,562 −4,596 package-lock.json
  19. +40 −40 package.json
  20. +9 −9 rollup.config.js
  21. +18 −1 src/Hooks.ts
  22. +29 −22 src/Instance.ts
  23. +70 −79 src/Lexer.ts
  24. +21 −19 src/MarkedOptions.ts
  25. +46 −117 src/Parser.ts
  26. +112 −49 src/Renderer.ts
  27. +10 −8 src/TextRenderer.ts
  28. +194 −115 src/Tokenizer.ts
  29. +200 −184 src/Tokens.ts
  30. +1 −1 src/defaults.ts
  31. +15 −40 src/helpers.ts
  32. +6 −5 src/marked.ts
  33. +104 −25 src/rules.ts
  34. +13 −6 test/bench.js
  35. +4 −3 test/recheck.js
  36. +5 −5 test/rules.js
  37. +6 −6 test/run-spec-tests.js
  38. +3 −6 test/specs/commonmark/{commonmark.0.31.json → commonmark.0.31.2.json}
  39. +3 −6 test/specs/gfm/{commonmark.0.31.json → commonmark.0.31.2.json}
  40. +19 −0 test/specs/new/blockquote_setext.html
  41. +16 −0 test/specs/new/blockquote_setext.md
  42. +6 −0 test/specs/new/escape_within_del.html
  43. +11 −0 test/specs/new/escape_within_del.md
  44. +15 −0 test/specs/new/html_following_list.html
  45. +11 −0 test/specs/new/html_following_list.md
  46. +8 −0 test/specs/new/list_with_line_break.html
  47. +6 −0 test/specs/new/list_with_line_break.md
  48. +10 −0 test/specs/new/setext_no_blankline.html
  49. +13 −0 test/specs/new/setext_no_blankline.md
  50. +2 −0 test/specs/new/tabs_code.html
  51. +6 −0 test/specs/new/tabs_code.md
  52. +1 −0 test/specs/new/underscore_link.html
  53. +1 −0 test/specs/new/underscore_link.md
  54. +1 −1 test/specs/redos/quadratic_br.cjs
  55. +5 −5 test/specs/redos/quadratic_em_mask.cjs
  56. +1 −1 test/specs/redos/quadratic_email.cjs
  57. +1 −1 test/specs/redos/quadratic_heading.cjs
  58. +1 −1 test/specs/redos/quadratic_lists.cjs
  59. +1 −1 test/specs/redos/quadratic_underscores.cjs
  60. +87 −33 test/types/marked.ts
  61. +90 −22 test/unit/Hooks.test.js
  62. +449 −344 test/unit/Lexer.test.js
  63. +112 −102 test/unit/Parser.test.js
  64. +13 −13 test/unit/bin.test.js
  65. +1 −1 test/unit/fixtures/bin-config.js
  66. +13 −13 test/unit/instance.test.js
  67. +96 −86 test/unit/marked.test.js
  68. +5 −6 test/update-specs.js
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

33 changes: 0 additions & 33 deletions .eslintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
# lowest verison here should also be in `engines` field
node_version: [18, "lts/*", "*"]
node_version: [18, "lts/*", "latest"]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
@@ -55,6 +55,7 @@ jobs:
Release:
permissions:
contents: write
id-token: write
needs: [UnitTests, OtherTests]
if: |
github.ref == 'refs/heads/master' &&
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -9,3 +9,4 @@ docs/LICENSE.md
vuln.js
man/marked.1
marked.min.js
test.js
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see https://github.com/markedjs/marked/releases
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
# Marked

[![npm](https://badgen.net/npm/v/marked)](https://www.npmjs.com/package/marked)
[![gzip size](https://badgen.net/badgesize/gzip/https://cdn.jsdelivr.net/npm/marked/marked.min.js)](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
[![install size](https://badgen.net/packagephobia/install/marked)](https://packagephobia.now.sh/result?p=marked)
[![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked)
[![github actions](https://github.com/markedjs/marked/workflows/Tests/badge.svg)](https://github.com/markedjs/marked/actions)
6 changes: 3 additions & 3 deletions api/dingus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { marked } from '../src/marked.js';
import { marked } from '../lib/marked.esm.js';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const version = require('../package.json').version;
@@ -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;
19 changes: 11 additions & 8 deletions bin/main.js
Original file line number Diff line number Diff line change
@@ -28,18 +28,21 @@ export async function main(nodeProcess) {
const options = {
cwd: nodeProcess.cwd(),
env: nodeProcess.env,
stdio: 'inherit'
stdio: 'inherit',
};

const __dirname = dirname(fileURLToPath(import.meta.url));
const helpText = await readFile(resolve(__dirname, '../man/marked.1.md'), 'utf8');

// eslint-disable-next-line promise/param-names
await new Promise(res => {
spawn('man', [resolve(__dirname, '../man/marked.1')], options)
.on('error', () => {
console.log(helpText);
})
const manProcess = spawn('man', [resolve(__dirname, '../man/marked.1')], options);
nodeProcess.on('SIGINT', () => {
manProcess.kill('SIGINT');
});

manProcess.on('error', () => {
console.log(helpText);
})
.on('close', res);
});
}
@@ -128,7 +131,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) {
@@ -205,7 +208,7 @@ export async function main(nodeProcess) {
const defaultConfig = [
'~/.marked.json',
'~/.marked.js',
'~/.marked/index.js'
'~/.marked/index.js',
];

for (const configFile of defaultConfig) {
23 changes: 0 additions & 23 deletions bower.json

This file was deleted.

1 change: 1 addition & 0 deletions docs/INDEX.md
Original file line number Diff line number Diff line change
@@ -162,6 +162,7 @@ We actively support the usability of Marked in super-fast markdown transformatio
| [StrapDown.js](https://naereen.github.io/StrapDown.js/) | StrapDown.js is an awesome on-the-fly Markdown to HTML text processor. |
| [raito](https://raito.arnaud.at/) | Mini Markdown Wiki/CMS in 8kb of JavaScript. |
| [Homebrewery](https://homebrewery.naturalcrit.com/) | The Homebrewery is a tool for making authentic looking D&D content using Markdown. It is distributed under the terms of the MIT. |
| [marked_reader](https://github.com/CNOCTAVE/marked_reader) | marked_reader is an open source Markdown reader packed by Electron. |

<h2 id="security">Security</h2>

6 changes: 6 additions & 0 deletions docs/USING_ADVANCED.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ const marked = new Marked([options, extension, ...]);
|:--------|:-------|:----------------------------------------------------------------------|
| options |`object`|The same arguments that can be passed to [`marked.use`](/using_pro#use)|

Be careful: marked.use(...) should not be used in a loop or function. It should only be used directly after new Marked is created or marked is imported.

## The `parse` function

```js
@@ -59,6 +61,7 @@ console.log(marked.parse(markdownString));

|Member |Type |Default |Since |Notes |
|:-----------|:---------|:--------|:--------|:-------------|
|smartLists (**removed**)| `boolean` | `false` |v0.2.8 | Removed in v3.0.0. |
|baseUrl (**removed**)|`string` |`null` |v0.3.9 |Removed in v8.0.0 use [`marked-base-url`](https://www.npmjs.com/package/marked-base-url) to prefix url for any relative link. |
|headerIds (**removed**)|`boolean` |`true` |v0.4.0 |Removed in v8.0.0 use [`marked-gfm-heading-id`](https://www.npmjs.com/package/marked-gfm-heading-id) to include an `id` attribute when emitting headings (h1, h2, h3, etc).|
|headerPrefix (**removed**)|`string` |`''` |v0.3.0 |Removed in v8.0.0 use [`marked-gfm-heading-id`](https://www.npmjs.com/package/marked-gfm-heading-id) to add a string to prefix the `id` attribute when emitting headings (h1, h2, h3, etc).|
@@ -96,6 +99,9 @@ Marked can be extended using [custom extensions](/using_pro#extensions). This is
|[LinkifyIt](https://github.com/UziTech/marked-linkify-it)|[`marked-linkify-it`](https://www.npmjs.com/package/marked-linkify-it)|Use [linkify-it](https://github.com/markdown-it/linkify-it) for urls|
|[Mangle](https://github.com/markedjs/marked-mangle)|[`marked-mangle`](https://www.npmjs.com/package/marked-mangle)|Mangle mailto links with HTML character references|
|[Misskey-flavored Markdown](https://akkoma.dev/sfr/marked-mfm)|[`marked-mfm`](https://www.npmjs.com/package/marked-mfm)|Custom extension for [Misskey-flavored Markdown](https://github.com/misskey-dev/mfm.js/blob/develop/docs/syntax.md).|
|[More Lists](https://github.com/jasny/marked-more-lists)|[`marked-more-lists`](https://www.npmjs.com/package/marked-more-lists)|Support for alphabetical and roman numeral ordered lists|
|[Plaintify](https://github.com/bent10/marked-extensions/tree/main/packages/plaintify)|[`marked-plaintify`](https://www.npmjs.com/package/marked-plaintify)|Converts Markdown to Plaintext|
|[Shiki](https://github.com/bent10/marked-extensions/tree/main/packages/shiki)|[`marked-shiki`](https://www.npmjs.com/package/marked-shiki)|Integrating [Shiki](https://shiki.style/) syntax highlighting|
|[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 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.|
Loading