Ensure that text such as custom tags that happen to
7 | begin with the same letters as the above tags don’t
8 | match and thus benefit from Smartypants-ing.
9 |
10 | Regular text.
5 |
6 | Regular text.
10 |
11 | Regular Text.
16 |
17 | "
6 | ],
7 | "description": "A markdown parser built for speed",
8 | "keywords": [
9 | "markdown",
10 | "markup",
11 | "html"
12 | ],
13 | "main": "lib/marked.js",
14 | "license": "MIT",
15 | "ignore": [
16 | "**/.*",
17 | "node_modules",
18 | "bower_components",
19 | "app/bower_components",
20 | "test",
21 | "tests"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/test/specs/original/amps_and_angles_encoding.md:
--------------------------------------------------------------------------------
1 | ---
2 | pedantic: true
3 | ---
4 |
5 | AT&T has an ampersand in their name.
6 |
7 | AT&T is another way to write it.
8 |
9 | This & that.
10 |
11 | 4 < 5.
12 |
13 | 6 > 5.
14 |
15 | Here's a [link] [1] with an ampersand in the URL.
16 |
17 | Here's a link with an amersand in the link text: [AT&T] [2].
18 |
19 | Here's an inline [link](/script?foo=1&bar=2).
20 |
21 | Here's an inline [link]().
22 |
23 |
24 | [1]: http://example.com/?foo=1&bar=2
25 | [2]: http://att.com/ "AT&T"
26 |
--------------------------------------------------------------------------------
/test/specs/new/smartypants_code.md:
--------------------------------------------------------------------------------
1 | ---
2 | smartypants: true
3 | description: SmartyPants does not modify characters within , , , or
10 |
11 | Ensure that text such as custom tags that happen to
12 | begin with the same letters as the above tags don't
13 | match and thus benefit from Smartypants-ing.
14 | --foo
15 | `--foo`
16 |
--------------------------------------------------------------------------------
/test/specs/original/tabs.html:
--------------------------------------------------------------------------------
1 |
7 |
8 | Code:
9 |
10 | this code block is indented by one tab
11 |
12 |
13 | And:
14 |
15 | this code block is indented by two tabs
16 |
17 |
18 | And:
19 |
20 | + this is an example list item
21 | indented with tabs
22 |
23 | + this is an example list item
24 | indented with spaces
25 |
26 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | The only completely secure system is the one that doesn't exist in the first place.
4 | Having said that, we take the security of Marked very seriously.
5 |
6 | ## Reporting a Vulnerability
7 |
8 | Please disclose potential security issues by email to the project [committers](https://marked.js.org/#/AUTHORS.md) as well as the [listed owners within NPM](https://docs.npmjs.com/cli/owner).
9 | We will provide an initial assessment of security reports within 48 hours and should apply patches within 2 weeks
10 | (also, feel free to contribute a fix for the issue).
11 |
--------------------------------------------------------------------------------
/test/specs/original/links_inline_style.html:
--------------------------------------------------------------------------------
1 | Just a URL.
2 |
3 | URL and title.
4 |
5 | URL and title.
6 |
7 | URL and title.
8 |
9 | URL and title.
10 |
11 | URL and title.
12 |
13 | URL and title.
14 |
15 | Empty.
16 |
--------------------------------------------------------------------------------
/test/specs/new/toplevel_paragraphs.md:
--------------------------------------------------------------------------------
1 | ---
2 | gfm: true
3 | ---
4 | hello world
5 | text after spaces
6 | text after spaces
7 |
8 | paragraph before code
9 | ```
10 | text inside block code
11 | ```
12 |
13 | paragraph before hr
14 | * * *
15 |
16 | paragraph before blockquote
17 | > text for blockquote
18 |
19 | paragraph before list
20 | * text inside list
21 |
22 | paragraph before div
23 | text inside div
24 |
25 | paragraph with span
26 | text inside span
27 |
28 | hello [world][how]
29 |
30 | [how]: /are/you
31 |
32 | hello
33 |
34 | hello
35 |
--------------------------------------------------------------------------------
/test/specs/new/autolinks.html:
--------------------------------------------------------------------------------
1 | (See https://www.example.com/fhqwhgads.)
2 |
3 | ((http://foo.com))
4 |
5 | ((http://foo.com.))
6 |
7 | HTTP://FOO.COM
8 |
9 | hTtP://fOo.CoM
10 |
11 | hello@email.com
12 |
13 | me@example.com
14 |
15 | test@test.com
--------------------------------------------------------------------------------
/test/specs/original/amps_and_angles_encoding.html:
--------------------------------------------------------------------------------
1 | AT&T has an ampersand in their name.
2 |
3 | AT&T is another way to write it.
4 |
5 | This & that.
6 |
7 | 4 < 5.
8 |
9 | 6 > 5.
10 |
11 | Here's a link with an ampersand in the URL.
12 |
13 | Here's a link with an amersand in the link text: AT&T.
14 |
15 | Here's an inline link.
16 |
17 | Here's an inline link.
18 |
--------------------------------------------------------------------------------
/test/specs/original/auto_links.html:
--------------------------------------------------------------------------------
1 | Link: http://example.com/.
2 |
3 | With an ampersand: http://example.com/?foo=1&bar=2
4 |
5 |
10 |
11 |
12 | Blockquoted: http://example.com/
13 |
14 |
15 | Auto-links should not occur here: <http://example.com/>
16 |
17 | or here: <http://example.com/>
18 |
19 |
--------------------------------------------------------------------------------
/test/specs/new/headings_id.html:
--------------------------------------------------------------------------------
1 | Heading with html
2 |
3 | Heading with a link
4 |
5 | Heading with some italic text
6 |
7 | Or some strong
8 |
9 | (which doesn't really make any difference, here)
10 |
11 | Or even code
12 |
13 | What about strikethrough
14 |
15 | And a ref link
16 |
--------------------------------------------------------------------------------
/rollup.config.esm.js:
--------------------------------------------------------------------------------
1 | const commonjs = require('rollup-plugin-commonjs');
2 | const license = require('rollup-plugin-license');
3 |
4 | module.exports = {
5 | input: 'src/marked.js',
6 | output: {
7 | file: 'lib/marked.esm.js',
8 | format: 'esm'
9 | },
10 | plugins: [
11 | license({
12 | banner: `
13 | DO NOT EDIT THIS FILE
14 | The code in this file is generated from files in ./src/
15 | `
16 | }),
17 | license({
18 | banner: `
19 | marked - a markdown parser
20 | Copyright (c) 2011-${new Date().getFullYear()}, Christopher Jeffrey. (MIT Licensed)
21 | https://github.com/markedjs/marked
22 | `
23 | }),
24 | commonjs()
25 | ]
26 | };
27 |
--------------------------------------------------------------------------------
/src/defaults.js:
--------------------------------------------------------------------------------
1 | function getDefaults() {
2 | return {
3 | baseUrl: null,
4 | breaks: false,
5 | gfm: true,
6 | headerIds: true,
7 | headerPrefix: '',
8 | highlight: null,
9 | langPrefix: 'language-',
10 | mangle: true,
11 | pedantic: false,
12 | renderer: null,
13 | sanitize: false,
14 | sanitizer: null,
15 | silent: false,
16 | smartLists: false,
17 | smartypants: false,
18 | xhtml: false
19 | };
20 | }
21 |
22 | function changeDefaults(newDefaults) {
23 | module.exports.defaults = newDefaults;
24 | }
25 |
26 | module.exports = {
27 | defaults: getDefaults(),
28 | getDefaults,
29 | changeDefaults
30 | };
31 |
--------------------------------------------------------------------------------
/test/specs/new/toplevel_paragraphs.html:
--------------------------------------------------------------------------------
1 | hello world
2 | text after spaces
3 | text after spaces
4 |
5 | paragraph before code
6 | text inside block code
7 |
8 | paragraph before hr
9 |
10 |
11 | paragraph before blockquote
12 | text for blockquote
13 |
14 | paragraph before list
15 |
16 |
17 | paragraph before div
18 | text inside div
19 |
20 | paragraph with span
21 | text inside span
22 |
23 | hello world
24 |
25 |
26 | hello
27 |
28 | hello
29 |
--------------------------------------------------------------------------------
/src/TextRenderer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * TextRenderer
3 | * returns only the textual part of the token
4 | */
5 | module.exports = class TextRenderer {
6 | // no need for block level renderers
7 | strong(text) {
8 | return text;
9 | }
10 |
11 | em(text) {
12 | return text;
13 | }
14 |
15 | codespan(text) {
16 | return text;
17 | }
18 |
19 | del(text) {
20 | return text;
21 | }
22 |
23 | html(text) {
24 | return text;
25 | }
26 |
27 | text(text) {
28 | return text;
29 | }
30 |
31 | link(href, title, text) {
32 | return '' + text;
33 | }
34 |
35 | image(href, title, text) {
36 | return '' + text;
37 | }
38 |
39 | br() {
40 | return '';
41 | }
42 | };
43 |
--------------------------------------------------------------------------------
/test/specs/new/relative_base_urls.md:
--------------------------------------------------------------------------------
1 | ---
2 | baseUrl: "/base/"
3 | ---
4 | # Absolutization of RFC 3986 URIs
5 |
6 | ## Absolute URI
7 | [](http://example.com/)
8 |
9 | ## Network-path reference
10 | [](//example.com/)
11 |
12 | ## Absolute path
13 | [](/path/to/content)
14 |
15 | ## Relative path
16 | [](content)
17 |
18 | ## Dot-relative path
19 | [](./content)
20 |
21 | [](../content)
22 |
23 | ## Same-document query
24 | [](?)
25 |
26 | ## Same-document fragment
27 | [](#)
28 |
29 | ## Empty
30 | [section 4.2]()
31 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "standard",
3 | "plugins": [
4 | "standard"
5 | ],
6 | "rules": {
7 | "semi": ["error", "always"],
8 | "indent": ["error", 2, {
9 | "SwitchCase": 1,
10 | "VariableDeclarator": { "var": 2 },
11 | "outerIIFEBody": 0
12 | }],
13 | "operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
14 | "space-before-function-paren": ["error", "never"],
15 | "no-cond-assign": "off",
16 | "no-useless-escape": "off",
17 | "one-var": "off",
18 | "no-control-regex": "off",
19 | "no-prototype-builtins": "off",
20 |
21 | "prefer-const": "error",
22 | "no-var": "error"
23 | },
24 | "env": {
25 | "node": true
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/test/specs/new/relative_urls.md:
--------------------------------------------------------------------------------
1 | ---
2 | baseUrl: "http://example.com/base/"
3 | ---
4 | # Absolutization of RFC 3986 URIs
5 |
6 | ## Absolute URI
7 | [](http://example.com/)
8 |
9 | ## Network-path reference
10 | [](//example.com/)
11 |
12 | ## Absolute path
13 | [](/path/to/content)
14 |
15 | ## Relative path
16 | [](content)
17 |
18 | ## Dot-relative path
19 | [](./content)
20 |
21 | [](../content)
22 |
23 | ## Same-document query
24 | [](?)
25 |
26 | ## Same-document fragment
27 | [](#)
28 |
29 | ## Empty
30 | [section 4.2]()
31 |
--------------------------------------------------------------------------------
/test/specs/new/blockquote_following_table.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | | abc |
5 | def |
6 |
7 |
8 |
9 |
10 | | bar |
11 | foo |
12 |
13 |
14 | | baz |
15 | boo |
16 |
17 |
18 |
19 | a blockquote
20 |
21 |
22 |
23 | | abc |
24 | def |
25 |
26 |
27 |
28 |
29 | | bar |
30 | foo |
31 |
32 |
33 | | baz |
34 | boo |
35 |
36 |
37 |
38 | a blockquote
39 |
--------------------------------------------------------------------------------
/test/specs/new/blockquote_following_nptable.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | | abc |
5 | def |
6 |
7 |
8 |
9 |
10 | | bar |
11 | foo |
12 |
13 |
14 | | baz |
15 | boo |
16 |
17 |
18 |
19 | a blockquote
20 |
21 |
22 |
23 | | abc |
24 | def |
25 |
26 |
27 |
28 |
29 | | bar |
30 | foo |
31 |
32 |
33 | | baz |
34 | boo |
35 |
36 |
37 |
38 | a blockquote
39 |
--------------------------------------------------------------------------------
/test/specs/new/html_comments.md:
--------------------------------------------------------------------------------
1 | ### Example 1
2 |
3 |
4 |
5 | ### Example 2
6 |
7 |
8 |
9 | ### Example 3
10 |
11 |
12 |
13 | ### Example 4
14 |
15 |
16 |
17 | ### Example 5
18 |
19 |
20 |
21 | ### Example 6
22 |
23 |
24 |
25 | ### Example 7
26 |
27 |
28 |
29 | ### Example 8
30 |
31 |
32 |
33 | ### Example 9
34 |
35 |
36 |
37 | ### Example 10
38 |
39 |
43 |
44 | ### Example 11
45 |
46 |
47 |
48 |
49 |
50 | ### Example 12
51 |
52 | not a comment -->
53 |
54 | not a comment -->
55 |
56 | -->
--------------------------------------------------------------------------------
/test/specs/new/code_following_nptable.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | | abc |
5 | def |
6 |
7 |
8 |
9 |
10 | | bar |
11 | foo |
12 |
13 |
14 | | baz |
15 | boo |
16 |
17 |
18 |
19 | a simple
20 | *indented* code block
21 |
22 |
23 |
24 |
25 |
26 | | abc |
27 | def |
28 |
29 |
30 |
31 |
32 | | bar |
33 | foo |
34 |
35 |
36 | | baz |
37 | boo |
38 |
39 |
40 |
41 | a simple
42 | *indented* code block
43 |
44 |
--------------------------------------------------------------------------------
/test/specs/new/code_following_table.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | | abc |
5 | def |
6 |
7 |
8 |
9 |
10 | | bar |
11 | foo |
12 |
13 |
14 | | baz |
15 | boo |
16 |
17 |
18 |
19 | a simple
20 | *indented* code block
21 |
22 |
23 |
24 |
25 |
26 | | abc |
27 | def |
28 |
29 |
30 |
31 |
32 | | bar |
33 | foo |
34 |
35 |
36 | | baz |
37 | boo |
38 |
39 |
40 |
41 | a simple
42 | *indented* code block
43 |
44 |
--------------------------------------------------------------------------------
/test/specs/new/list_table.html:
--------------------------------------------------------------------------------
1 |
45 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | const commonjs = require('rollup-plugin-commonjs');
2 | const babel = require('rollup-plugin-babel');
3 | const license = require('rollup-plugin-license');
4 |
5 | module.exports = {
6 | input: 'src/marked.js',
7 | output: {
8 | file: 'lib/marked.js',
9 | format: 'umd',
10 | name: 'marked'
11 | },
12 | plugins: [
13 | license({
14 | banner: `
15 | DO NOT EDIT THIS FILE
16 | The code in this file is generated from files in ./src/
17 | `
18 | }),
19 | license({
20 | banner: `
21 | marked - a markdown parser
22 | Copyright (c) 2011-${new Date().getFullYear()}, Christopher Jeffrey. (MIT Licensed)
23 | https://github.com/markedjs/marked
24 | `
25 | }),
26 | commonjs(),
27 | babel({
28 | presets: [['@babel/preset-env', { loose: true }]]
29 | })
30 | ]
31 | };
32 |
--------------------------------------------------------------------------------
/test/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "standard",
3 | "plugins": [
4 | "standard"
5 | ],
6 | "globals": {
7 | "expectAsync": "readonly"
8 | },
9 | "rules": {
10 | "semi": ["error", "always"],
11 | "indent": ["error", 2, {
12 | "SwitchCase": 1,
13 | "VariableDeclarator": { "var": 2 },
14 | "outerIIFEBody": 0
15 | }],
16 | "operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
17 | "space-before-function-paren": ["error", "never"],
18 | "no-cond-assign": "off",
19 | "no-useless-escape": "off",
20 | "one-var": "off",
21 | "no-control-regex": "off",
22 | "no-prototype-builtins": "off",
23 |
24 | "prefer-const": "error",
25 | "no-var": "error"
26 | },
27 | "env": {
28 | "node": true,
29 | "jasmine": true
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/specs/original/horizontal_rules.md:
--------------------------------------------------------------------------------
1 | Dashes:
2 |
3 | ---
4 |
5 | ---
6 |
7 | ---
8 |
9 | ---
10 |
11 | ---
12 |
13 | - - -
14 |
15 | - - -
16 |
17 | - - -
18 |
19 | - - -
20 |
21 | - - -
22 |
23 |
24 | Asterisks:
25 |
26 | ***
27 |
28 | ***
29 |
30 | ***
31 |
32 | ***
33 |
34 | ***
35 |
36 | * * *
37 |
38 | * * *
39 |
40 | * * *
41 |
42 | * * *
43 |
44 | * * *
45 |
46 |
47 | Underscores:
48 |
49 | ___
50 |
51 | ___
52 |
53 | ___
54 |
55 | ___
56 |
57 | ___
58 |
59 | _ _ _
60 |
61 | _ _ _
62 |
63 | _ _ _
64 |
65 | _ _ _
66 |
67 | _ _ _
68 |
69 |
70 |
71 | Not horizontal rules:
72 |
73 | --*
74 |
75 | -*-
76 |
77 | *--
78 |
79 | -_-
80 |
81 | __-
82 |
83 | -__
84 |
85 | _-_
86 |
87 |
88 | Long rules:
89 |
90 | -----------
91 |
92 | ___________
93 |
94 | ***********
95 |
--------------------------------------------------------------------------------
/docs/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "standard",
3 | "plugins": [
4 | "standard"
5 | ],
6 | "parserOptions": {
7 | "ecmaVersion": 5,
8 | "sourceType": "script"
9 | },
10 | "rules": {
11 | "semi": ["error", "always"],
12 | "indent": ["error", 2, {
13 | "SwitchCase": 1,
14 | "VariableDeclarator": { "var": 2 },
15 | "outerIIFEBody": 0
16 | }],
17 | "operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
18 | "space-before-function-paren": ["error", "never"],
19 | "no-cond-assign": "off",
20 | "no-useless-escape": "off",
21 | "one-var": "off",
22 | "no-control-regex": "off",
23 | "no-prototype-builtins": "off",
24 |
25 | "prefer-const": "off",
26 | "no-var": "off"
27 | },
28 | "env": {
29 | "node": true,
30 | "browser": true,
31 | "amd": true
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Slugger.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Slugger generates header id
3 | */
4 | module.exports = class Slugger {
5 | constructor() {
6 | this.seen = {};
7 | }
8 |
9 | /**
10 | * Convert string to unique id
11 | */
12 | slug(value) {
13 | let slug = value
14 | .toLowerCase()
15 | .trim()
16 | // remove html tags
17 | .replace(/<[!\/a-z].*?>/ig, '')
18 | // remove unwanted chars
19 | .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
20 | .replace(/\s/g, '-');
21 |
22 | if (this.seen.hasOwnProperty(slug)) {
23 | const originalSlug = slug;
24 | do {
25 | this.seen[originalSlug]++;
26 | slug = originalSlug + '-' + this.seen[originalSlug];
27 | } while (this.seen.hasOwnProperty(slug));
28 | }
29 | this.seen[slug] = 0;
30 |
31 | return slug;
32 | };
33 | };
34 |
--------------------------------------------------------------------------------
/test/helpers/helpers.js:
--------------------------------------------------------------------------------
1 | const marked = require('../../src/marked.js');
2 | const htmlDiffer = require('./html-differ.js');
3 |
4 | beforeEach(() => {
5 | marked.setOptions(marked.getDefaults());
6 |
7 | jasmine.addAsyncMatchers({
8 | toRender: () => {
9 | return {
10 | compare: async(spec, expected) => {
11 | const result = {};
12 | const actual = marked(spec.markdown, spec.options);
13 | result.pass = await htmlDiffer.isEqual(expected, actual);
14 |
15 | if (result.pass) {
16 | result.message = `${spec.markdown}\n------\n\nExpected: Should Fail`;
17 | } else {
18 | const diff = await htmlDiffer.firstDiff(actual, expected);
19 | result.message = `Expected: ${diff.expected}\n Actual: ${diff.actual}`;
20 | }
21 | return result;
22 | }
23 | };
24 | }
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/test/specs/original/inline_html_simple.md:
--------------------------------------------------------------------------------
1 | Here's a simple block:
2 |
3 |
4 | foo
5 |
6 |
7 | This should be a code block, though:
8 |
9 |
10 | foo
11 |
12 |
13 | As should this:
14 |
15 | foo
16 |
17 | Now, nested:
18 |
19 |
26 |
27 | This should just be an HTML comment:
28 |
29 |
30 |
31 | Multiline:
32 |
33 |
37 |
38 | Code block:
39 |
40 |
41 |
42 | Just plain comment, with trailing spaces on the line:
43 |
44 |
45 |
46 | Code:
47 |
48 |
49 |
50 | Hr's:
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Marked says it does this thing but does not
4 |
5 | ---
6 |
7 | **Describe the bug**
8 | A clear and concise description of what the bug is.
9 |
10 | **To Reproduce**
11 | Steps to reproduce the behavior:
12 |
13 |
14 |
18 |
19 |
20 |
25 |
26 | **Expected behavior**
27 | A clear and concise description of what you expected to happen.
28 |
--------------------------------------------------------------------------------
/test/specs/original/horizontal_rules.html:
--------------------------------------------------------------------------------
1 | Dashes:
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | ---
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | - - -
23 |
24 |
25 | Asterisks:
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | ***
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | * * *
47 |
48 |
49 | Underscores:
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | ___
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | _ _ _
71 |
72 |
73 | Not horizontal rules:
74 | --*
75 | -*-
76 | *--
77 | -_-
78 | __-
79 | -__
80 | _-_
81 |
82 | Long rules:
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/test/specs/new/html_comments.html:
--------------------------------------------------------------------------------
1 | Example 1
2 |
3 |
4 |
5 | Example 2
6 |
7 |
8 |
9 | Example 3
10 |
11 |
12 |
13 | Example 4
14 |
15 |
16 |
17 | Example 5
18 |
19 |
20 |
21 | Example 6
22 |
23 |
24 |
25 | Example 7
26 |
27 |
28 |
29 | Example 8
30 |
31 |
32 |
33 | Example 9
34 |
35 |
36 |
37 | Example 10
38 |
39 |
43 |
44 | Example 11
45 |
46 |
47 |
48 | <!-- too much indentation -->
49 |
50 |
51 | Example 12
52 |
53 | <!--> not a comment -->
54 |
55 | <!---> not a comment -->
56 |
57 | -->
58 |
--------------------------------------------------------------------------------
/test/specs/original/inline_html_simple.html:
--------------------------------------------------------------------------------
1 | Here's a simple block:
2 |
3 |
4 | foo
5 |
6 |
7 | This should be a code block, though:
8 |
9 | <div>
10 | foo
11 | </div>
12 |
13 |
14 | As should this:
15 |
16 | <div>foo</div>
17 |
18 |
19 | Now, nested:
20 |
21 |
28 |
29 | This should just be an HTML comment:
30 |
31 |
32 |
33 | Multiline:
34 |
35 |
39 |
40 | Code block:
41 |
42 | <!-- Comment -->
43 |
44 |
45 | Just plain comment, with trailing spaces on the line:
46 |
47 |
48 |
49 | Code:
50 |
51 | <hr />
52 |
53 |
54 | Hr's:
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/test/specs/original/links_reference_style.md:
--------------------------------------------------------------------------------
1 | ---
2 | pedantic: true
3 | ---
4 |
5 | Foo [bar] [1].
6 |
7 | Foo [bar][1].
8 |
9 | Foo [bar]
10 | [1].
11 |
12 | [1]: /url/ "Title"
13 |
14 |
15 | With [embedded [brackets]] [b].
16 |
17 |
18 | Indented [once][].
19 |
20 | Indented [twice][].
21 |
22 | Indented [thrice][].
23 |
24 | Indented [four][] times.
25 |
26 | [once]: /url
27 |
28 | [twice]: /url
29 |
30 | [thrice]: /url
31 |
32 | [four]: /url
33 |
34 |
35 | [b]: /url/
36 |
37 | * * *
38 |
39 | [this] [this] should work
40 |
41 | So should [this][this].
42 |
43 | And [this] [].
44 |
45 | And [this][].
46 |
47 | And [this].
48 |
49 | But not [that] [].
50 |
51 | Nor [that][].
52 |
53 | Nor [that].
54 |
55 | [Something in brackets like [this][] should work]
56 |
57 | [Same with [this].]
58 |
59 | In this case, [this](/somethingelse/) points to something else.
60 |
61 | Backslashing should suppress \[this] and [this\].
62 |
63 | [this]: foo
64 |
65 |
66 | * * *
67 |
68 | Here's one where the [link
69 | breaks] across lines.
70 |
71 | Here's another where the [link
72 | breaks] across lines, but with a line-ending space.
73 |
74 |
75 | [link breaks]: /url/
76 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | **Marked version:**
2 |
3 | **Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a
4 |
5 |
6 |
7 |
18 |
19 | ## Expectation
20 |
21 | **CommonMark Demo:** [demo](https://spec.commonmark.org/dingus/)
22 |
23 |
24 |
25 |
26 | ## Result
27 |
28 | **Marked Demo:** [demo](https://marked.js.org/demo/)
29 |
30 |
31 |
32 |
33 | ## What was attempted
34 |
35 |
36 |
37 |
43 |
--------------------------------------------------------------------------------
/test/specs/redos/link_code.md:
--------------------------------------------------------------------------------
1 | INDEX(string, pattern[, start)` : searches for the first occurrence of pattern in string, starting from start: `INDEX("123123", "23", 3)` == `5`
2 | `INSERT(new, old[, start][, length][, pad])` : inserts the new string into the old string after the specified position (default is 0), new string is truncated or padded (default is " ") to the specified length, if start is beyond the end of old old will be padded
3 | `LASTPOS(pattern, string[, start])` : searches backwards for the last occurrence of pattern in string, starting from start: `LASTPOS("123123", "23", 4)` == `2`
4 | `LINES(file)` : returns the number of lines typed ahead at the interactive stream: `push("a line"); push("second line"); lines(STDIN); /* == 2 */`
5 | `MAX(number, number[, number,...])` : obvious
6 | `MIN(number, number[, number,...])` : obvious
7 | `OPEN(filehandle, filename[, "APPEND"|"READ"|"WRITE"])` : opens file, returns boolean for success: `OPEN("MyCon", "CON:160/50/320/100/MyCon/CDS")` == `1`
8 | `OVERLAY(new, old[, start][, length][, pad])` : overlays new string onto old one at start for length chars padding with pad if necessary: `OVERLAY("4", "123", 5, 5)` == `"123-4----"`
9 | `POS(pattern, string[, start])` : same as index
10 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | jobs:
4 | fast_finish: true
5 | allow_failures:
6 | - stage: security scan 🔐
7 |
8 | include:
9 | - stage: unit tests 👩🏽💻
10 | script: npm run test:unit
11 | node_js: lts/*
12 |
13 | - stage: spec tests 👩🏽💻
14 | script: npm run test:specs
15 | node_js: lts/*
16 | - node_js: node
17 |
18 | - stage: lint ✨
19 | script: npm run test:lint
20 | node_js: lts/*
21 |
22 | - stage: build 🗜️
23 | script: |
24 | npm run build
25 | if ! git diff --quiet; then
26 | git config --global user.email "<>"
27 | git config --global user.name "MarkedJS bot"
28 | git config credential.helper "store --file=.git/credentials"
29 | echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
30 | git commit -am '🗜️ build [skip ci]'
31 | git push origin HEAD:${TRAVIS_BRANCH}
32 | fi
33 | node_js: lts/*
34 | if: branch = master AND type = push
35 |
36 | # - stage: security scan 🔐
37 | # script: npm run test:redos
38 | # node_js: lts/*
39 |
40 | cache:
41 | directories:
42 | - node_modules
43 |
44 | git:
45 | depth: 3
46 |
--------------------------------------------------------------------------------
/docs/demo/demo.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
5 | color: #333;
6 | background-color: #fbfbfb;
7 | height: 100%;
8 | }
9 |
10 | textarea {
11 | font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
12 | font-size: 12px;
13 | resize: none;
14 | }
15 |
16 | header {
17 | padding-top: 10px;
18 | display: flex;
19 | height: 58px;
20 | }
21 |
22 | header h1 {
23 | margin: 0;
24 | }
25 |
26 | .github-ribbon {
27 | position: absolute;
28 | top: 0;
29 | right: 0;
30 | border: 0;
31 | z-index: 1000;
32 | }
33 |
34 | .containers {
35 | display: flex;
36 | height: calc(100vh - 68px);
37 | }
38 |
39 | .container {
40 | flex-basis: 50%;
41 | padding: 5px;
42 | display: flex;
43 | flex-direction: column;
44 | height: 100%;
45 | box-sizing: border-box;
46 | }
47 |
48 | .pane, .inputPane {
49 | margin-top: 5px;
50 | padding: 0.6em;
51 | border: 1px solid #ccc;
52 | overflow: auto;
53 | flex-grow: 1;
54 | flex-shrink: 1;
55 | }
56 |
57 | #preview {
58 | display: flex;
59 | }
60 |
61 | #preview iframe {
62 | flex-grow: 1;
63 | }
64 |
65 | #main {
66 | display: none;
67 | }
68 |
69 | .error {
70 | border-color: red;
71 | background-color: #FEE
72 | }
73 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/release.md:
--------------------------------------------------------------------------------
1 | ## Publisher
2 |
3 | - [ ] `$ npm version` has been run.
4 | - [ ] Release notes in [draft GitHub release](https://github.com/markedjs/marked/releases) are up to date
5 | - [ ] Release notes include which flavors and versions of Markdown are supported by this release
6 | - [ ] Committer checklist is complete.
7 | - [ ] Merge PR.
8 | - [ ] Publish GitHub release using `master` with correct version number.
9 | - [ ] `$ npm publish` has been run.
10 | - [ ] Create draft GitHub release to prepare next release.
11 |
12 | Note: If merges to `master` occur after submitting this PR and before running `$ npm pubish` you should be able to
13 |
14 | 1. pull from `upstream/master` (`git pull upstream master`) into the branch holding this version,
15 | 2. run `$ npm run build` to regenerate the `min` file, and
16 | 3. commit and push the updated changes.
17 |
18 | ## Committer
19 |
20 | In most cases, this should be someone different than the publisher.
21 |
22 | - [ ] Version in `package.json` has been updated (see [PUBLISHING.md](https://github.com/markedjs/marked/blob/master/docs/PUBLISHING.md)).
23 | - [ ] The `marked.min.js` has been updated; or,
24 | - [ ] release does not change library.
25 | - [ ] CI is green (no forced merge required).
26 |
--------------------------------------------------------------------------------
/test/specs/new/main.md:
--------------------------------------------------------------------------------
1 | [test]: http://google.com/ "Google"
2 |
3 | # A heading
4 |
5 | Just a note, I've found that I can't test my markdown parser vs others.
6 | For example, both markdown.js and showdown code blocks in lists wrong. They're
7 | also completely [inconsistent][test] with regards to paragraphs in list items.
8 |
9 | A link. Not anymore.
10 |
11 |
13 |
14 | * List Item 1
15 |
16 | * List Item 2
17 | * New List Item 1
18 | Hi, this is a list item.
19 | * New List Item 2
20 | Another item
21 | Code goes here.
22 | Lots of it...
23 | * New List Item 3
24 | The last item
25 |
26 | * List Item 3
27 | The final item.
28 |
29 | * List Item 4
30 | The real final item.
31 |
32 | Paragraph.
33 |
34 | > * bq Item 1
35 | > * bq Item 2
36 | > * New bq Item 1
37 | > * New bq Item 2
38 | > Text here
39 |
40 | * * *
41 |
42 | > Another blockquote!
43 | > I really need to get
44 | > more creative with
45 | > mockup text..
46 | > markdown.js breaks here again
47 |
48 | Another Heading
49 | -------------
50 |
51 | Hello *world*. Here is a [link](//hello).
52 | And an image .
53 |
54 | Code goes here.
55 | Lots of it...
56 |
--------------------------------------------------------------------------------
/test/specs/new/relative_base_urls.html:
--------------------------------------------------------------------------------
1 | Absolutization of RFC 3986 URIs
2 |
3 | Absolute URI
4 |
5 | 
6 |
7 | Network-path reference
8 |
9 | 
10 |
11 | Absolute path
12 |
13 | 
14 |
15 | Relative path
16 |
17 | 
18 |
19 | Dot-relative path
20 |
21 | 
22 |
23 | 
24 |
25 | Same-document query
26 |
27 | 
28 |
29 | Same-document fragment
30 |
31 | 
32 |
33 | Empty
34 |
35 | section 4.2
36 |
--------------------------------------------------------------------------------
/test/helpers/html-differ.js:
--------------------------------------------------------------------------------
1 | const HtmlDiffer = require('@markedjs/html-differ').HtmlDiffer;
2 | const htmlDiffer = new HtmlDiffer({ ignoreSelfClosingSlash: true });
3 |
4 | module.exports = {
5 | isEqual: htmlDiffer.isEqual.bind(htmlDiffer),
6 | firstDiff: async(actual, expected, padding) => {
7 | padding = padding || 30;
8 | const diffHtml = await htmlDiffer.diffHtml(actual, expected);
9 | const result = diffHtml.reduce((obj, diff) => {
10 | if (diff.added) {
11 | if (obj.firstIndex === null) {
12 | obj.firstIndex = obj.expected.length;
13 | }
14 | obj.expected += diff.value;
15 | } else if (diff.removed) {
16 | if (obj.firstIndex === null) {
17 | obj.firstIndex = obj.actual.length;
18 | }
19 | obj.actual += diff.value;
20 | } else {
21 | obj.actual += diff.value;
22 | obj.expected += diff.value;
23 | }
24 |
25 | return obj;
26 | }, {
27 | firstIndex: null,
28 | actual: '',
29 | expected: ''
30 | });
31 |
32 | return {
33 | actual: result.actual.substring(result.firstIndex - padding, result.firstIndex + padding),
34 | expected: result.expected.substring(result.firstIndex - padding, result.firstIndex + padding)
35 | };
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/test/specs/new/em_list_links.md:
--------------------------------------------------------------------------------
1 | - italic
2 | - [*named link*][some-url]
3 | - *[named link][some-url]*
4 | - [_named link_][some-url]
5 | - _[named link][some-url]_
6 | - bold
7 | - [**named link**][some-url]
8 | - **[named link][some-url]**
9 | - [__named link__][some-url]
10 | - __[named link][some-url]__
11 | - bold italic
12 | - [***named link***][some-url]
13 | - ***[named link][some-url]***
14 | - [___named link___][some-url]
15 | - ___[named link][some-url]___
16 | - [*__named link__*][some-url]
17 | - [__*named link*__][some-url]
18 | - __*[named link][some-url]*__
19 | - code
20 | - [`named link`][some-url]
21 | - code italic
22 | - *[`named link`][some-url]*
23 | - [*`named link`*][some-url]
24 | - _[`named link`][some-url]_
25 | - [_`named link`_][some-url]
26 | - code bold
27 | - **[`named link`][some-url]**
28 | - [**`named link`**][some-url]
29 | - __[`named link`][some-url]__
30 | - [__`named link`__][some-url]
31 | - code bold italic
32 | - [***`named link`***][some-url]
33 | - ***[`named link`][some-url]***
34 | - [___`named link`___][some-url]
35 | - ___[`named link`][some-url]___
36 | - [*__`named link`__*][some-url]
37 | - [__*`named link`*__][some-url]
38 | - __*[`named link`][some-url]*__
39 |
40 | [some-url]: https://www.google.com
--------------------------------------------------------------------------------
/test/specs/new/main.html:
--------------------------------------------------------------------------------
1 | A heading
Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.
A link. Not anymore.
Paragraph.
- bq Item 1
- bq Item 2
- New bq Item 1
- New bq Item 2 Text here
Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again
Another Heading
Hello world. Here is a link. And an image
.
Code goes here.
4 | Lots of it...
5 |
--------------------------------------------------------------------------------
/docs/PUBLISHING.md:
--------------------------------------------------------------------------------
1 | # Releasing Marked
2 |
3 | - [ ] See [contributing](#/CONTRIBUTING.md)
4 | - [ ] Create release branch from `master` (`release-x.y.z`)
5 | - [ ] Submit PR with minimal name: Release x.y.z
6 | - [ ] Complete PR checklists
7 |
8 | ## Overall strategy
9 |
10 | **Master is always shippable:** We try to merge PRs in such a way that `master` is the only branch to really be concerned about *and* `master` can always be released. This allows smoother flow between new features, bug fixes, and so on. (Almost a continuous deployment setup, without automation.)
11 |
12 | ## Versioning
13 |
14 | We follow [semantic versioning](https://semver.org) where the following sequence is true `[major].[minor].[patch]`; therefore, consider the following implications of the release you are preparing:
15 |
16 | 1. **Major:** There is at least one change not deemed backward compatible.
17 | 2. **Minor:** There is at least one new feature added to the release.
18 | 3. **Patch:** No breaking changes, no new features.
19 |
20 | What to expect while Marked is a zero-major (0.x.y):
21 |
22 | 1. The major will remain at zero; thereby, alerting consumers to the potentially volatile nature of the package.
23 | 2. The minor will tend to be more analogous to a `major` release.
24 | 3. The patch will tend to be more analogous to a `minor` release or a collection of bug fixes (patches).
25 |
--------------------------------------------------------------------------------
/test/specs/original/links_reference_style.html:
--------------------------------------------------------------------------------
1 | Foo bar.
2 |
3 | Foo bar.
4 |
5 | Foo bar.
6 |
7 | With embedded [brackets].
8 |
9 | Indented once.
10 |
11 | Indented twice.
12 |
13 | Indented thrice.
14 |
15 | Indented [four][] times.
16 |
17 | [four]: /url
18 |
19 |
20 |
21 |
22 | this should work
23 |
24 | So should this.
25 |
26 | And this.
27 |
28 | And this.
29 |
30 | And this.
31 |
32 | But not [that] [].
33 |
34 | Nor [that][].
35 |
36 | Nor [that].
37 |
38 | [Something in brackets like this should work]
39 |
40 | [Same with this.]
41 |
42 | In this case, this points to something else.
43 |
44 | Backslashing should suppress [this] and [this].
45 |
46 |
47 |
48 | Here's one where the link
49 | breaks across lines.
50 |
51 | Here's another where the link
52 | breaks across lines, but with a line-ending space.
53 |
--------------------------------------------------------------------------------
/test/vuln-regex.js:
--------------------------------------------------------------------------------
1 | const regexp = require('../src/rules.js');
2 | const vulnRegexDetector = require('vuln-regex-detector');
3 |
4 | const promises = [];
5 | function findRegexps(name, obj) {
6 | if (typeof obj === 'string') {
7 | promises.push(testRegexp(name, obj));
8 | } if (obj instanceof RegExp || obj.exec) {
9 | if (obj.source) {
10 | promises.push(testRegexp(name, obj.source));
11 | }
12 | } else if (typeof obj === 'object') {
13 | for (const prop in obj) {
14 | findRegexps(name + (name ? '.' : '') + prop, obj[prop]);
15 | }
16 | }
17 | }
18 |
19 | async function testRegexp(name, source) {
20 | try {
21 | const result = await vulnRegexDetector.test(source);
22 |
23 | if (result === vulnRegexDetector.responses.safe) {
24 | console.log(`${name} is safe`);
25 | return true;
26 | } else if (result === vulnRegexDetector.responses.vulnerable) {
27 | console.error(`${name} is vulnerable`);
28 | } else {
29 | console.error(`${name} might be vulnerable: ` + result.toString());
30 | }
31 | } catch (ex) {
32 | console.error(`${name} failed with error: ` + ex.toString());
33 | }
34 | return false;
35 | }
36 |
37 | findRegexps('', regexp);
38 | // promises.push(testRegexp('a', /(a+)+$/.source));
39 | Promise.allSettled(promises).then(results => {
40 | const code = results.every(r => r.value) ? 0 : 1;
41 | process.exit(code);
42 | });
43 |
--------------------------------------------------------------------------------
/test/specs/redos/redos_html_closing.html:
--------------------------------------------------------------------------------
1 | <tag "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""<" />a'a
2 |
--------------------------------------------------------------------------------
/test/specs/new/relative_urls.html:
--------------------------------------------------------------------------------
1 | Absolutization of RFC 3986 URIs
2 |
3 | Absolute URI
4 |
5 | 
6 |
7 | Network-path reference
8 |
9 | 
10 |
11 | Absolute path
12 |
13 | 
14 |
15 | Relative path
16 |
17 | 
18 |
19 | Dot-relative path
20 |
21 | 
22 |
23 | 
24 |
25 | Same-document query
26 |
27 | 
28 |
29 | Same-document fragment
30 |
31 | 
32 |
33 | Empty
34 |
35 | section 4.2
36 |
--------------------------------------------------------------------------------
/test/specs/redos/link_code.html:
--------------------------------------------------------------------------------
1 | INDEX(string, pattern[, start): searches for the first occurrence of pattern in string, starting from start:INDEX("123123", "23", 3)==5INSERT(new, old[, start][, length][, pad]): inserts the new string into the old string after the specified position (default is 0), new string is truncated or padded (default is " ") to the specified length, if start is beyond the end of old old will be paddedLASTPOS(pattern, string[, start]): searches backwards for the last occurrence of pattern in string, starting from start:LASTPOS("123123", "23", 4)==2LINES(file): returns the number of lines typed ahead at the interactive stream:push("a line"); push("second line"); lines(STDIN); /* == 2 */MAX(number, number[, number,...]): obviousMIN(number, number[, number,...]): obviousOPEN(filehandle, filename[, "APPEND"|"READ"|"WRITE"]): opens file, returns boolean for success:OPEN("MyCon", "CON:160/50/320/100/MyCon/CDS")==1OVERLAY(new, old[, start][, length][, pad]): overlays new string onto old one at start for length chars padding with pad if necessary:OVERLAY("4", "123", 5, 5)=="123-4----"POS(pattern, string[, start])` : same as index
2 |
--------------------------------------------------------------------------------
/test/specs/new/table_cells.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/test/specs/new/link_tick_redos.md:
--------------------------------------------------------------------------------
1 | dash_capstyle: ['butt' | 'round' | 'projecting']
2 | dash_joinstyle: ['miter' | 'round' | 'bevel']
3 | dashes: sequence of on/off ink in points
4 | drawstyle: ['default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post']
5 | figure: a `~.Figure` instance
6 | fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none']
7 | gid: an id string
8 | label: object
9 | linestyle or ls: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) | ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'None'`` | ``' '`` | ``''``]
10 | linewidth or lw: float value in points
11 | marker: :mod:`A valid marker style `
12 | markeredgecolor or mec: any matplotlib color
13 | markeredgewidth or mew: float value in points
14 | markerfacecolor or mfc: any matplotlib color
15 | markerfacecoloralt or mfcalt: any matplotlib color
16 | markersize or ms: float
17 | markevery: [None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]
18 | path_effects: `~.AbstractPathEffect`
19 | picker: float distance in points or callable pick function ``fn(artist, event)``
20 | pickradius: float distance in points
21 | rasterized: bool or None
22 | sketch_params: (scale: float, length: float, randomness: float)
23 | snap: bool or None
24 | solid_capstyle: ['butt' | 'round' | 'projecting']
25 | solid_joinstyle: ['miter' | 'round' | 'bevel']
26 | transform: a :class:`matplotlib.transforms.Transform` instance
27 | url: a url string
28 | visible: bool
29 | xdata: 1D array
30 | ydata: 1D array
31 | zorder: float
32 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 | **Marked version:**
14 |
15 |
16 |
17 | **Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a
18 |
19 | ## Description
20 |
21 | - Fixes #### (if fixing a known issue; otherwise, describe issue using the following format)
22 |
23 |
40 |
41 | ## Contributor
42 |
43 | - [ ] Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
44 | - [ ] no tests required for this PR.
45 | - [ ] If submitting new feature, it has been documented in the appropriate places.
46 |
47 | ## Committer
48 |
49 | In most cases, this should be a different person than the contributor.
50 |
51 | - [ ] Draft GitHub release notes have been updated.
52 | - [ ] CI is green (no forced merge required).
53 | - [ ] Merge PR
54 |
--------------------------------------------------------------------------------
/docs/demo/initial.md:
--------------------------------------------------------------------------------
1 | Marked - Markdown Parser
2 | ========================
3 |
4 | [Marked] lets you convert [Markdown] into HTML. Markdown is a simple text format whose goal is to be very easy to read and write, even when not converted to HTML. This demo page will let you type anything you like and see how it gets converted. Live. No more waiting around.
5 |
6 | How To Use The Demo
7 | -------------------
8 |
9 | 1. Type in stuff on the left.
10 | 2. See the live updates on the right.
11 |
12 | That's it. Pretty simple. There's also a drop-down option in the upper right to switch between various views:
13 |
14 | - **Preview:** A live display of the generated HTML as it would render in a browser.
15 | - **HTML Source:** The generated HTML before your browser makes it pretty.
16 | - **Lexer Data:** What [marked] uses internally, in case you like gory stuff like this.
17 | - **Quick Reference:** A brief run-down of how to format things using markdown.
18 |
19 | Why Markdown?
20 | -------------
21 |
22 | It's easy. It's not overly bloated, unlike HTML. Also, as the creator of [markdown] says,
23 |
24 | > The overriding design goal for Markdown's
25 | > formatting syntax is to make it as readable
26 | > as possible. The idea is that a
27 | > Markdown-formatted document should be
28 | > publishable as-is, as plain text, without
29 | > looking like it's been marked up with tags
30 | > or formatting instructions.
31 |
32 | Ready to start writing? Either start changing stuff on the left or
33 | [clear everything](/demo/?text=) with a simple click.
34 |
35 | [Marked]: https://github.com/markedjs/marked/
36 | [Markdown]: http://daringfireball.net/projects/markdown/
37 |
--------------------------------------------------------------------------------
/test/specs/original/ordered_and_unordered_lists.md:
--------------------------------------------------------------------------------
1 | ---
2 | headerIds: false
3 | ---
4 | ## Unordered
5 |
6 | Asterisks tight:
7 |
8 | * asterisk 1
9 | * asterisk 2
10 | * asterisk 3
11 |
12 |
13 | Asterisks loose:
14 |
15 | * asterisk 1
16 |
17 | * asterisk 2
18 |
19 | * asterisk 3
20 |
21 | * * *
22 |
23 | Pluses tight:
24 |
25 | + Plus 1
26 | + Plus 2
27 | + Plus 3
28 |
29 |
30 | Pluses loose:
31 |
32 | + Plus 1
33 |
34 | + Plus 2
35 |
36 | + Plus 3
37 |
38 | * * *
39 |
40 |
41 | Minuses tight:
42 |
43 | - Minus 1
44 | - Minus 2
45 | - Minus 3
46 |
47 |
48 | Minuses loose:
49 |
50 | - Minus 1
51 |
52 | - Minus 2
53 |
54 | - Minus 3
55 |
56 |
57 | ## Ordered
58 |
59 | Tight:
60 |
61 | 1. First
62 | 2. Second
63 | 3. Third
64 |
65 | and:
66 |
67 | 1. One
68 | 2. Two
69 | 3. Three
70 |
71 |
72 | Loose using tabs:
73 |
74 | 1. First
75 |
76 | 2. Second
77 |
78 | 3. Third
79 |
80 | and using spaces:
81 |
82 | 1. One
83 |
84 | 2. Two
85 |
86 | 3. Three
87 |
88 | Multiple paragraphs:
89 |
90 | 1. Item 1, graf one.
91 |
92 | Item 2. graf two. The quick brown fox jumped over the lazy dog's
93 | back.
94 |
95 | 2. Item 2.
96 |
97 | 3. Item 3.
98 |
99 |
100 |
101 | ## Nested
102 |
103 | * Tab
104 | * Tab
105 | * Tab
106 |
107 | Here's another:
108 |
109 | 1. First
110 | 2. Second:
111 | * Fee
112 | * Fie
113 | * Foe
114 | 3. Third
115 |
116 | Same thing but with paragraphs:
117 |
118 | 1. First
119 |
120 | 2. Second:
121 | * Fee
122 | * Fie
123 | * Foe
124 |
125 | 3. Third
126 |
127 |
128 | This was an error in Markdown 1.0.1:
129 |
130 | * this
131 |
132 | * sub
133 |
134 | that
135 |
136 | Ordered lists start from initial number:
137 |
138 | 3. Three
139 | 1. Four
140 |
141 | Ordered lists start from initial zero:
142 |
143 | 0. Zero
144 | 1. One
145 |
--------------------------------------------------------------------------------
/test/specs/new/link_tick_redos.html:
--------------------------------------------------------------------------------
1 | dash_capstyle: ['butt' | 'round' | 'projecting']
2 | dash_joinstyle: ['miter' | 'round' | 'bevel']
3 | dashes: sequence of on/off ink in points
4 | drawstyle: ['default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post']
5 | figure: a ~.Figure instance
6 | fillstyle: ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none']
7 | gid: an id string
8 | label: object
9 | linestyle or ls: ['solid' | 'dashed', 'dashdot', 'dotted' | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
10 | linewidth or lw: float value in points
11 | marker: :mod:A valid marker style <matplotlib.markers>
12 | markeredgecolor or mec: any matplotlib color
13 | markeredgewidth or mew: float value in points
14 | markerfacecolor or mfc: any matplotlib color
15 | markerfacecoloralt or mfcalt: any matplotlib color
16 | markersize or ms: float
17 | markevery: [None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]
18 | path_effects: ~.AbstractPathEffect
19 | picker: float distance in points or callable pick function fn(artist, event)
20 | pickradius: float distance in points
21 | rasterized: bool or None
22 | sketch_params: (scale: float, length: float, randomness: float)
23 | snap: bool or None
24 | solid_capstyle: ['butt' | 'round' | 'projecting']
25 | solid_joinstyle: ['miter' | 'round' | 'bevel']
26 | transform: a :class:matplotlib.transforms.Transform instance
27 | url: a url string
28 | visible: bool
29 | xdata: 1D array
30 | ydata: 1D array
31 | zorder: float
32 |
--------------------------------------------------------------------------------
/test/specs/original/backslash_escapes.md:
--------------------------------------------------------------------------------
1 | These should all get escaped:
2 |
3 | Backslash: \\
4 |
5 | Backtick: \`
6 |
7 | Asterisk: \*
8 |
9 | Underscore: \_
10 |
11 | Left brace: \{
12 |
13 | Right brace: \}
14 |
15 | Left bracket: \[
16 |
17 | Right bracket: \]
18 |
19 | Left paren: \(
20 |
21 | Right paren: \)
22 |
23 | Greater-than: \>
24 |
25 | Hash: \#
26 |
27 | Period: \.
28 |
29 | Bang: \!
30 |
31 | Plus: \+
32 |
33 | Minus: \-
34 |
35 |
36 |
37 | These should not, because they occur within a code block:
38 |
39 | Backslash: \\
40 |
41 | Backtick: \`
42 |
43 | Asterisk: \*
44 |
45 | Underscore: \_
46 |
47 | Left brace: \{
48 |
49 | Right brace: \}
50 |
51 | Left bracket: \[
52 |
53 | Right bracket: \]
54 |
55 | Left paren: \(
56 |
57 | Right paren: \)
58 |
59 | Greater-than: \>
60 |
61 | Hash: \#
62 |
63 | Period: \.
64 |
65 | Bang: \!
66 |
67 | Plus: \+
68 |
69 | Minus: \-
70 |
71 |
72 | Nor should these, which occur in code spans:
73 |
74 | Backslash: `\\`
75 |
76 | Backtick: `` \` ``
77 |
78 | Asterisk: `\*`
79 |
80 | Underscore: `\_`
81 |
82 | Left brace: `\{`
83 |
84 | Right brace: `\}`
85 |
86 | Left bracket: `\[`
87 |
88 | Right bracket: `\]`
89 |
90 | Left paren: `\(`
91 |
92 | Right paren: `\)`
93 |
94 | Greater-than: `\>`
95 |
96 | Hash: `\#`
97 |
98 | Period: `\.`
99 |
100 | Bang: `\!`
101 |
102 | Plus: `\+`
103 |
104 | Minus: `\-`
105 |
106 |
107 | These should get escaped, even though they're matching pairs for
108 | other Markdown constructs:
109 |
110 | \*asterisks\*
111 |
112 | \_underscores\_
113 |
114 | \`backticks\`
115 |
116 | This is a code span with a literal backslash-backtick sequence: `` \` ``
117 |
118 | This is a tag with unescaped backticks bar.
119 |
120 | This is a tag with backslashes bar.
121 |
--------------------------------------------------------------------------------
/test/specs/run-spec.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const load = require('../helpers/load.js');
3 |
4 | function runSpecs(title, dir, showCompletionTable, options) {
5 | options = options || {};
6 | const specs = load.loadFiles(path.resolve(__dirname, dir));
7 |
8 | if (showCompletionTable) {
9 | load.outputCompletionTable(title, specs);
10 | }
11 |
12 | describe(title, () => {
13 | Object.keys(specs).forEach(section => {
14 | describe(section, () => {
15 | specs[section].specs.forEach((spec) => {
16 | spec.options = Object.assign({}, options, (spec.options || {}));
17 | const example = (spec.example ? ' example ' + spec.example : '');
18 | const passFail = (spec.shouldFail ? 'fail' : 'pass');
19 | if (typeof spec.options.silent === 'undefined') {
20 | spec.options.silent = true;
21 | }
22 | if (spec.options.sanitizer) {
23 | // eslint-disable-next-line no-eval
24 | spec.options.sanitizer = eval(spec.options.sanitizer);
25 | }
26 | (spec.only ? fit : (spec.skip ? xit : it))('should ' + passFail + example, async() => {
27 | const before = process.hrtime();
28 | if (spec.shouldFail) {
29 | await expectAsync(spec).not.toRender(spec.html);
30 | } else {
31 | await expectAsync(spec).toRender(spec.html);
32 | }
33 | const elapsed = process.hrtime(before);
34 | if (elapsed[0] > 0) {
35 | const s = (elapsed[0] + elapsed[1] * 1e-9).toFixed(3);
36 | fail(`took too long: ${s}s`);
37 | }
38 | });
39 | });
40 | });
41 | });
42 | });
43 | }
44 |
45 | runSpecs('GFM', './gfm', true, { gfm: true, pedantic: false, headerIds: false });
46 | runSpecs('CommonMark', './commonmark', true, { gfm: false, pedantic: false, headerIds: false });
47 | runSpecs('Original', './original', false, { gfm: false, pedantic: true });
48 | runSpecs('New', './new');
49 | runSpecs('ReDOS', './redos');
50 | runSpecs('Security', './security', false, { silent: true }); // silent - do not show deprecation warning
51 |
--------------------------------------------------------------------------------
/test/specs/original/backslash_escapes.html:
--------------------------------------------------------------------------------
1 | These should all get escaped:
2 |
3 | Backslash: \
4 |
5 | Backtick: `
6 |
7 | Asterisk: *
8 |
9 | Underscore: _
10 |
11 | Left brace: {
12 |
13 | Right brace: }
14 |
15 | Left bracket: [
16 |
17 | Right bracket: ]
18 |
19 | Left paren: (
20 |
21 | Right paren: )
22 |
23 | Greater-than: >
24 |
25 | Hash: #
26 |
27 | Period: .
28 |
29 | Bang: !
30 |
31 | Plus: +
32 |
33 | Minus: -
34 |
35 | These should not, because they occur within a code block:
36 |
37 | Backslash: \\
38 |
39 | Backtick: \`
40 |
41 | Asterisk: \*
42 |
43 | Underscore: \_
44 |
45 | Left brace: \{
46 |
47 | Right brace: \}
48 |
49 | Left bracket: \[
50 |
51 | Right bracket: \]
52 |
53 | Left paren: \(
54 |
55 | Right paren: \)
56 |
57 | Greater-than: \>
58 |
59 | Hash: \#
60 |
61 | Period: \.
62 |
63 | Bang: \!
64 |
65 | Plus: \+
66 |
67 | Minus: \-
68 |
69 |
70 | Nor should these, which occur in code spans:
71 |
72 | Backslash: \\
73 |
74 | Backtick: \`
75 |
76 | Asterisk: \*
77 |
78 | Underscore: \_
79 |
80 | Left brace: \{
81 |
82 | Right brace: \}
83 |
84 | Left bracket: \[
85 |
86 | Right bracket: \]
87 |
88 | Left paren: \(
89 |
90 | Right paren: \)
91 |
92 | Greater-than: \>
93 |
94 | Hash: \#
95 |
96 | Period: \.
97 |
98 | Bang: \!
99 |
100 | Plus: \+
101 |
102 | Minus: \-
103 |
104 |
105 | These should get escaped, even though they're matching pairs for
106 | other Markdown constructs:
107 |
108 | *asterisks*
109 |
110 | _underscores_
111 |
112 | `backticks`
113 |
114 | This is a code span with a literal backslash-backtick sequence: \`
115 |
116 | This is a tag with unescaped backticks bar.
117 |
118 | This is a tag with backslashes bar.
119 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "marked",
3 | "description": "A markdown parser built for speed",
4 | "author": "Christopher Jeffrey",
5 | "version": "0.8.2",
6 | "main": "./src/marked.js",
7 | "bin": "./bin/marked",
8 | "man": "./man/marked.1",
9 | "files": [
10 | "bin/",
11 | "lib/",
12 | "src/",
13 | "man/",
14 | "marked.min.js"
15 | ],
16 | "repository": "git://github.com/markedjs/marked.git",
17 | "homepage": "https://marked.js.org",
18 | "bugs": {
19 | "url": "http://github.com/markedjs/marked/issues"
20 | },
21 | "license": "MIT",
22 | "keywords": [
23 | "markdown",
24 | "markup",
25 | "html"
26 | ],
27 | "tags": [
28 | "markdown",
29 | "markup",
30 | "html"
31 | ],
32 | "devDependencies": {
33 | "@babel/core": "^7.9.0",
34 | "@babel/preset-env": "^7.9.0",
35 | "@markedjs/html-differ": "^3.0.0",
36 | "cheerio": "^1.0.0-rc.3",
37 | "commonmark": "0.29.x",
38 | "eslint": "^6.8.0",
39 | "eslint-config-standard": "^14.1.1",
40 | "eslint-plugin-import": "^2.20.1",
41 | "eslint-plugin-node": "^11.0.0",
42 | "eslint-plugin-promise": "^4.2.1",
43 | "eslint-plugin-standard": "^4.0.1",
44 | "front-matter": "^3.1.0",
45 | "jasmine": "^3.5.0",
46 | "markdown": "0.5.x",
47 | "markdown-it": "10.x",
48 | "node-fetch": "^2.6.0",
49 | "rollup": "^2.1.0",
50 | "rollup-plugin-babel": "^4.4.0",
51 | "rollup-plugin-commonjs": "^10.1.0",
52 | "rollup-plugin-license": "^0.13.0",
53 | "uglify-js": "^3.8.0",
54 | "vuln-regex-detector": "^1.3.0"
55 | },
56 | "scripts": {
57 | "test": "jasmine --config=jasmine.json",
58 | "test:all": "npm test && npm run test:lint",
59 | "test:unit": "npm test -- test/unit/**/*-spec.js",
60 | "test:specs": "npm test -- test/specs/**/*-spec.js",
61 | "test:lint": "eslint bin/marked .",
62 | "test:redos": "node test/vuln-regex.js",
63 | "test:update": "node test/update-specs.js",
64 | "bench": "npm run rollup && node test/bench.js",
65 | "lint": "eslint --fix bin/marked .",
66 | "build:reset": "git checkout upstream/master lib/marked.js lib/marked.esm.js marked.min.js",
67 | "build": "npm run rollup && npm run minify",
68 | "rollup": "npm run rollup:umd && npm run rollup:esm",
69 | "rollup:umd": "rollup -c rollup.config.js",
70 | "rollup:esm": "rollup -c rollup.config.esm.js",
71 | "minify": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js",
72 | "preversion": "npm run build && (git diff --quiet || git commit -am build)"
73 | },
74 | "engines": {
75 | "node": ">= 8.16.2"
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/test/specs/original/ordered_and_unordered_lists.html:
--------------------------------------------------------------------------------
1 | Unordered
2 |
3 | Asterisks tight:
4 |
5 |
6 | - asterisk 1
7 | - asterisk 2
8 | - asterisk 3
9 |
10 |
11 | Asterisks loose:
12 |
13 |
14 | asterisk 1
15 | asterisk 2
16 | asterisk 3
17 |
18 |
19 |
20 |
21 | Pluses tight:
22 |
23 |
24 | - Plus 1
25 | - Plus 2
26 | - Plus 3
27 |
28 |
29 | Pluses loose:
30 |
31 |
32 | Plus 1
33 | Plus 2
34 | Plus 3
35 |
36 |
37 |
38 |
39 | Minuses tight:
40 |
41 |
42 | - Minus 1
43 | - Minus 2
44 | - Minus 3
45 |
46 |
47 | Minuses loose:
48 |
49 |
50 | Minus 1
51 | Minus 2
52 | Minus 3
53 |
54 |
55 | Ordered
56 |
57 | Tight:
58 |
59 |
60 | - First
61 | - Second
62 | - Third
63 |
64 |
65 | and:
66 |
67 |
68 | - One
69 | - Two
70 | - Three
71 |
72 |
73 | Loose using tabs:
74 |
75 |
76 | First
77 | Second
78 | Third
79 |
80 |
81 | and using spaces:
82 |
83 |
84 | One
85 | Two
86 | Three
87 |
88 |
89 | Multiple paragraphs:
90 |
91 |
92 | Item 1, graf one.
93 |
94 | Item 2. graf two. The quick brown fox jumped over the lazy dog's
95 | back.
96 | Item 2.
97 | Item 3.
98 |
99 |
100 | Nested
101 |
102 |
111 |
112 | Here's another:
113 |
114 |
115 | - First
116 | - Second:
117 |
118 | - Fee
119 | - Fie
120 | - Foe
121 |
122 | - Third
123 |
124 |
125 | Same thing but with paragraphs:
126 |
127 |
128 | First
129 | Second:
130 |
131 |
132 | - Fee
133 | - Fie
134 | - Foe
135 |
136 | Third
137 |
138 |
139 |
140 | This was an error in Markdown 1.0.1:
141 |
142 |
143 | this
144 |
145 |
146 |
147 | that
148 |
149 |
150 |
151 | Ordered lists start from initial number:
152 |
153 |
154 | - Three
155 | - Four
156 |
157 |
158 |
159 | Ordered lists start from initial zero:
160 |
161 |
162 | - Zero
163 | - One
164 |
165 |
--------------------------------------------------------------------------------
/man/marked.1:
--------------------------------------------------------------------------------
1 | .ds q \N'34'
2 | .TH marked 1
3 |
4 | .SH NAME
5 | marked \- a javascript markdown parser
6 |
7 | .SH SYNOPSIS
8 | .B marked
9 | [\-o \fI