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: 124c57690eaf97b0b173c8bcfb780ba7ec74db7e
Choose a base ref
...
head repository: markedjs/marked
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1ad8e69e9b959d0be03e6a345767daad28993f5d
Choose a head ref
Loading
Showing with 19,108 additions and 2,634 deletions.
  1. +1 −0 .eslintignore
  2. +7 −8 .eslintrc.json
  3. +66 −0 .github/workflows/tests.yml
  4. +3 −0 .nowignore
  5. +0 −46 .travis.yml
  6. +2 −2 README.md
  7. +19 −19 bin/marked
  8. +33 −0 docs/.eslintrc.json
  9. +5 −5 docs/AUTHORS.md
  10. +31 −5 docs/CONTRIBUTING.md
  11. +3 −3 docs/PUBLISHING.md
  12. +6 −6 docs/README.md
  13. +11 −13 docs/USING_ADVANCED.md
  14. +233 −44 docs/USING_PRO.md
  15. +9 −9 docs/demo/demo.js
  16. +54 −50 docs/demo/quickref.md
  17. +40 −22 docs/demo/worker.js
  18. BIN docs/favicon.ico
  19. +4 −1 docs/index.html
  20. +2,472 −0 lib/marked.esm.js
  21. +2,333 −1,434 lib/marked.js
  22. +1 −4 man/marked.1
  23. +4 −7 man/marked.1.txt
  24. +2 −2 marked.min.js
  25. +11 −0 now.json
  26. +2,573 −673 package-lock.json
  27. +37 −23 package.json
  28. +26 −0 rollup.config.esm.js
  29. +31 −0 rollup.config.js
  30. +455 −0 src/Lexer.js
  31. +255 −0 src/Parser.js
  32. +164 −0 src/Renderer.js
  33. +33 −0 src/Slugger.js
  34. +42 −0 src/TextRenderer.js
  35. +659 −0 src/Tokenizer.js
  36. +32 −0 src/defaults.js
  37. +243 −0 src/helpers.js
  38. +234 −0 src/marked.js
  39. +337 −0 src/rules.js
  40. +4 −0 test/.eslintrc.json
  41. +57 −25 test/bench.js
  42. +33 −6 test/helpers/helpers.js
  43. +22 −23 test/helpers/html-differ.js
  44. +7 −1 test/helpers/load.js
  45. +74 −0 test/rules.js
  46. +43 −86 test/specs/commonmark/commonmark.0.29.json
  47. +5,284 −0 test/specs/gfm/commonmark.0.29.json
  48. +26 −26 test/specs/gfm/gfm.0.29.json
  49. +38 −0 test/specs/new/blockquote_following_nptable.html
  50. +11 −0 test/specs/new/blockquote_following_nptable.md
  51. +38 −0 test/specs/new/blockquote_following_table.html
  52. +11 −0 test/specs/new/blockquote_following_table.md
  53. +7 −0 test/specs/new/code_compensation_indent.html
  54. +11 −0 test/specs/new/code_compensation_indent.md
  55. +3 −0 test/specs/new/code_consistent_newline.html
  56. +10 −0 test/specs/new/code_consistent_newline.md
  57. +43 −0 test/specs/new/code_following_nptable.html
  58. +13 −0 test/specs/new/code_following_nptable.md
  59. +43 −0 test/specs/new/code_following_table.html
  60. +13 −0 test/specs/new/code_following_table.md
  61. +5 −0 test/specs/new/codespan_newline.html
  62. +5 −0 test/specs/new/codespan_newline.md
  63. +10 −0 test/specs/new/double_link.html
  64. +12 −0 test/specs/new/double_link.md
  65. +2 −2 test/specs/new/em_2char.html
  66. +2 −2 test/specs/new/em_2char.md
  67. +5 −0 test/specs/new/em_and_reflinks.html
  68. +15 −0 test/specs/new/em_and_reflinks.md
  69. +1 −1 test/specs/new/emphasis_extra tests.html
  70. +6 −1 test/specs/new/emphasis_extra tests.md
  71. +14 −0 test/specs/new/fences_breaking_paragraphs.html
  72. +27 −0 test/specs/new/fences_breaking_paragraphs.md
  73. +19 −0 test/specs/new/fences_following_nptable.html
  74. +7 −0 test/specs/new/fences_following_nptable.md
  75. +19 −0 test/specs/new/fences_following_table.html
  76. +7 −0 test/specs/new/fences_following_table.md
  77. +19 −0 test/specs/new/heading_following_nptable.html
  78. +5 −0 test/specs/new/heading_following_nptable.md
  79. +19 −0 test/specs/new/heading_following_table.html
  80. +5 −0 test/specs/new/heading_following_table.md
  81. +3 −1 test/specs/new/headings_id.html
  82. +3 −1 test/specs/new/headings_id.md
  83. +19 −0 test/specs/new/hr_following_nptables.html
  84. +5 −0 test/specs/new/hr_following_nptables.md
  85. +19 −0 test/specs/new/hr_following_tables.html
  86. +5 −0 test/specs/new/hr_following_tables.md
  87. +19 −0 test/specs/new/html_following_nptable.html
  88. +5 −0 test/specs/new/html_following_nptable.md
  89. +19 −0 test/specs/new/html_following_table.html
  90. +5 −0 test/specs/new/html_following_table.md
  91. +11 −0 test/specs/new/image_links.html
  92. +3 −0 test/specs/new/image_links.md
  93. +3 −0 test/specs/new/image_paren.html
  94. +3 −0 test/specs/new/image_paren.md
  95. +22 −0 test/specs/new/inlinecode_following_nptables.html
  96. +5 −0 test/specs/new/inlinecode_following_nptables.md
  97. +22 −0 test/specs/new/inlinecode_following_tables.html
  98. +5 −0 test/specs/new/inlinecode_following_tables.md
  99. +26 −0 test/specs/new/lheading_following_nptable.html
  100. +6 −0 test/specs/new/lheading_following_nptable.md
  101. +26 −0 test/specs/new/lheading_following_table.html
  102. +6 −0 test/specs/new/lheading_following_table.md
  103. +5 −0 test/specs/new/links_paren.html
  104. +5 −0 test/specs/new/links_paren.md
  105. +23 −0 test/specs/new/list_following_nptable.html
  106. +7 −0 test/specs/new/list_following_nptable.md
  107. +23 −0 test/specs/new/list_following_table.html
  108. +7 −0 test/specs/new/list_following_table.md
  109. +15 −0 test/specs/new/list_loose_tasks.html
  110. +6 −0 test/specs/new/list_loose_tasks.md
  111. +11 −0 test/specs/new/list_paren_delimiter.html
  112. +8 −0 test/specs/new/list_paren_delimiter.md
  113. +1 −1 test/specs/new/nested_square_link.md
  114. +1 −0 test/specs/new/nogfm_hashtag.md
  115. +5 −0 test/specs/new/pedantic_heading_interrupts_paragraph.html
  116. +10 −0 test/specs/new/pedantic_heading_interrupts_paragraph.md
  117. +35 −0 test/specs/new/relative_base_urls.html
  118. +30 −0 test/specs/new/relative_base_urls.md
  119. +22 −0 test/specs/new/strong_following_nptables.html
  120. +5 −0 test/specs/new/strong_following_nptables.md
  121. +22 −0 test/specs/new/strong_following_tables.html
  122. +5 −0 test/specs/new/strong_following_tables.md
  123. +3 −0 test/specs/new/substitutions.html
  124. +3 −0 test/specs/new/substitutions.md
  125. +22 −0 test/specs/new/text_following_nptables.html
  126. +5 −0 test/specs/new/text_following_nptables.md
  127. +22 −0 test/specs/new/text_following_tables.html
  128. +5 −0 test/specs/new/text_following_tables.md
  129. +0 −6 test/specs/new/toplevel_paragraphs.html
  130. +0 −7 test/specs/new/toplevel_paragraphs.md
  131. +1 −0 test/specs/redos/link_code.html
  132. +9 −0 test/specs/redos/link_code.md
  133. +19 −6 test/specs/run-spec.js
  134. +6 −0 test/specs/security/sanitizer_bypass.html
  135. +9 −0 test/specs/security/sanitizer_bypass.md
  136. +2 −0 test/specs/security/sanitizer_bypass_remove_generic.html
  137. +6 −0 test/specs/security/sanitizer_bypass_remove_generic.md
  138. +1 −0 test/specs/security/sanitizer_bypass_remove_script.html
  139. +5 −0 test/specs/security/sanitizer_bypass_remove_script.md
  140. +1 −0 test/specs/security/sanitizer_bypass_remove_tag.html
  141. +5 −0 test/specs/security/sanitizer_bypass_remove_tag.md
  142. +1,102 −0 test/unit/Lexer-spec.js
  143. +449 −0 test/unit/Parser-spec.js
  144. +383 −3 test/unit/marked-spec.js
  145. +56 −60 test/update-specs.js
  146. +42 −0 test/vuln-regex.js
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib
*.min.js
15 changes: 7 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -3,10 +3,6 @@
"plugins": [
"standard"
],
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "script"
},
"rules": {
"semi": ["error", "always"],
"indent": ["error", 2, {
@@ -19,11 +15,14 @@
"no-cond-assign": "off",
"no-useless-escape": "off",
"one-var": "off",
"no-control-regex": "off"
"no-control-regex": "off",
"no-prototype-builtins": "off",
"no-extra-semi": "error",

"prefer-const": "error",
"no-var": "error"
},
"env": {
"node": true,
"browser": true,
"amd": true
"node": true
}
}
66 changes: 66 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "Tests"
on:
pull_request:
push:
branches:
- master

jobs:
Test:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
strategy:
matrix:
node_version: ['lts/*', 'node']
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Node
uses: dcodeIO/setup-node-nvm@master
with:
node-version: ${{ matrix.node_version }}
- name: Install Dependencies
run: npm ci
- name: Run Unit Tests 👩🏽‍💻
run: npm run test:unit
- name: Run Spec Tests 👩🏽‍💻
run: npm run test:specs

Lint:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
run: npm ci
- name: Lint ✨
run: npm run test:lint

Build:
needs: [Test, Lint]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
run: npm ci
- name: Build 🗜️
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run build
if ! git diff --quiet; then
git config --global user.email "<>"
git config --global user.name "MarkedJS bot"
git commit -am "🗜️ build [skip ci]"
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/markedjs/marked.git" HEAD:master
fi
Skip:
if: contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- name: Skip CI 🚫
run: echo skip ci
3 changes: 3 additions & 0 deletions .nowignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!docs
!docs/**
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
[![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked)
[![dep](https://badgen.net/david/dep/markedjs/marked?label=deps)](https://david-dm.org/markedjs/marked)
[![dev dep](https://badgen.net/david/dev/markedjs/marked?label=devDeps)](https://david-dm.org/markedjs/marked?type=dev)
[![travis](https://badgen.net/travis/markedjs/marked)](https://travis-ci.org/markedjs/marked)
[![github actions](https://github.com/markedjs/marked/workflows/Tests/badge.svg)](https://github.com/markedjs/marked/actions)
[![snyk](https://snyk.io/test/npm/marked/badge.svg)](https://snyk.io/test/npm/marked)

- ⚡ built for speed
@@ -39,7 +39,7 @@ Also read about:

## Usage

### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/#/USING_ADVANCED.md#options) the output HTML by default 🚨
### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/#/USING_ADVANCED.md#options) the output HTML. Please use a sanitize library, like [DOMPurify](https://github.com/cure53/DOMPurify) (recommended), [sanitize-html](https://github.com/apostrophecms/sanitize-html) or [insane](https://github.com/bevacqua/insane) on the output HTML! 🚨

**CLI**

38 changes: 19 additions & 19 deletions bin/marked
Original file line number Diff line number Diff line change
@@ -5,35 +5,35 @@
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
*/

var fs = require('fs'),
path = require('path'),
marked = require('../');
const fs = require('fs'),
path = require('path'),
marked = require('../');

/**
* Man Page
*/

function help() {
var spawn = require('child_process').spawn;
const spawn = require('child_process').spawn;

var options = {
const options = {
cwd: process.cwd(),
env: process.env,
setsid: false,
stdio: 'inherit'
};

spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
spawn('man', [path.resolve(__dirname, '../man/marked.1')], options)
.on('error', function() {
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
fs.readFile(path.resolve(__dirname, '../man/marked.1.txt'), 'utf8', function(err, data) {
if (err) throw err;
console.log(data);
});
});
}

function version() {
var pkg = require('../package.json');
const pkg = require('../package.json');
console.log(pkg.version);
}

@@ -42,17 +42,17 @@ function version() {
*/

function main(argv, callback) {
var files = [],
options = {},
input,
output,
string,
arg,
tokens,
opt;
const files = [],
options = {};
let input,
output,
string,
arg,
tokens,
opt;

function getarg() {
var arg = argv.shift();
let arg = argv.shift();

if (arg.indexOf('--') === 0) {
// e.g. --opt
@@ -162,8 +162,8 @@ function main(argv, callback) {
*/

function getStdin(callback) {
var stdin = process.stdin,
buff = '';
const stdin = process.stdin;
let buff = '';

stdin.setEncoding('utf8');

33 changes: 33 additions & 0 deletions docs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": "standard",
"plugins": [
"standard"
],
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "script"
},
"rules": {
"semi": ["error", "always"],
"indent": ["error", 2, {
"SwitchCase": 1,
"VariableDeclarator": { "var": 2 },
"outerIIFEBody": 0
}],
"operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
"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",

"prefer-const": "off",
"no-var": "off"
},
"env": {
"node": true,
"browser": true,
"amd": true
}
}
10 changes: 5 additions & 5 deletions docs/AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Authors

Marked takes an encompassing approach to its community. As such, you can think of these as [concentric circles](https://medium.com/the-node-js-collection/healthy-open-source-967fa8be7951), where each group encompases the following groups.
Marked takes an encompassing approach to its community. As such, you can think of these as [concentric circles](https://medium.com/the-node-js-collection/healthy-open-source-967fa8be7951), where each group encompasses the following groups.

<table>
<tbody>
@@ -170,7 +170,7 @@ To be removed: You can remove yourself through the [GitHub UI](https://help.gith
A note on volunteering:

1. Please do not volunteer unless you believe you can demonstrate to your peers you can do the work required.
2. Please do not overcommit yourself; we count on those committed to the project to be responsive. Really consider, with all you have going on, wehther you able to really commit to it.
2. Please do not overcommit yourself; we count on those committed to the project to be responsive. Really consider, with all you have going on, whether you able to really commit to it.
3. Don't let the previous frighten you away, it can always be changed later by you or your peers.

[Details on badges](#badges)
@@ -227,7 +227,7 @@ Badges? If you *want* 'em, we got 'em, and here's how you get 'em (and&hellip;dr
</blockquote>
</dd>
<dt>Dr. Docs</dt>
<dd>Someone who has contributed a great deal to the creation and maintainance of the non-code areas of marked.</dd>
<dd>Someone who has contributed a great deal to the creation and maintenance of the non-code areas of marked.</dd>
<dt>Eye for the CLI</dt>
<dd>At this point? Pretty much anyone who can update that `man` file to the current Marked version without regression in the CLI tool itself.</dd>
<dt>GitHub Guru</dt>
@@ -259,9 +259,9 @@ Badges? If you *want* 'em, we got 'em, and here's how you get 'em (and&hellip;dr

<dl>
<dt>Defibrillator</dt>
<dd>A contributor who stepped up to help bring Marked back to life by contriuting solutions to help Marked pass when compared against the CommonMark and GitHub Flavored Markdown specifications.</dd>
<dd>A contributor who stepped up to help bring Marked back to life by contributing solutions to help Marked pass when compared against the CommonMark and GitHub Flavored Markdown specifications.</dd>
<dt>Maker of the Marked mark</dt>
<dd>This badge is given to the person or oganization credited with creating the logo (or logotype) used in Marked communications for a given period of time. **Maker of the Marked mark from 2017 to present**, for example.</dd>
<dd>This badge is given to the person or organization credited with creating the logo (or logotype) used in Marked communications for a given period of time. **Maker of the Marked mark from 2017 to present**, for example.</dd>
<dt>Release Wrangler</dt>
<dd>This is a badge given to all Publishers.</dd>
<dt>Snyk's Security Saint</dt>
36 changes: 31 additions & 5 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -5,9 +5,10 @@
- [ ] Make sure you are on the `master` branch.
- [ ] Be sure to run `npm install` or `npm update`.
- [ ] Create a branch.
- [ ] Make as small a change as possible.
- [ ] Run `npm test`, fix any broken things (for linting, you can run `npm run lint` to have the linter fix them for you).
- [ ] Submit a PR.
- [ ] Update code in `src` folder. (`lib` folder is for auto compiled code)
- [ ] Run `npm run test:all`, fix any broken things (for linting, you can run `npm run lint` to have the linter fix them for you).
- [ ] Run `npm run build:reset` to remove changes to compiled files.
- [ ] Submit a Pull Request.

## Design principles

@@ -30,6 +31,7 @@ The following table lists the ticket type labels we use when there is work to be
|RR - refactor and re-engineer |Results in an improvement to developers using Marked (improved readability) or end-users (faster performance) or both. |
|NFS - new feature (spec related) |A capability Marked does not currently provide but is in one of the [supported specifications](#/README.md#specifications) |
|NFU - new feature (user requested) |A capability Marked does not currently provide but has been requested by users of Marked. |
|NFE - new feature (should be an extension) |A capability Marked does not currently provide and is not part of a spec. |

## Test early, often, and everything

@@ -80,15 +82,39 @@ To see time comparisons between Marked and other popular Markdown libraries:
npm run bench
```

To see the compiled rules from `src/rules.js`:

```bash
npm run rules
```

You can specify one or more `rule path`s to only show certain rules:

```bash
npm run rules -- block.gfm.item inline.pedantic.br

{
block: {
gfm: {
item: /^( *)((?:[*+-]|\\d{1,9}\\.)) ?[^\\n]*(?:\\n(?!\\1(?:[*+-]|\\d{1,9}\\.) ?)[^\\n]*)*/gm
}
},
inline: {
pedantic: {
br: /^( {2,}|\\\\)\\n(?!\\s*$)/
}
}
}
```

To check for (and fix) standardized syntax (lint):

```bash
npm run lint
```

To build your own minified version of Marked:
To build your own es5, esm, and minified versions of Marked:

```bash
npm run build
```

Loading