Merge branch 'master' into defib-challenge

This commit is contained in:
Josh Bruce 2018-04-20 10:12:51 -04:00
commit 3049bded57
12 changed files with 311 additions and 12 deletions

View File

@ -13,6 +13,10 @@ jobs:
- node_js: lts/*
- node_js: node
- stage: security scan 🔐
script: npm run test:redos
node_js: lts/*
- stage: lint ✨
script: npm run test:lint
node_js: lts/*

View File

@ -4,6 +4,12 @@
# Marked
[![npm](https://img.shields.io/npm/v/marked.svg)](https://www.npmjs.com/package/marked)
[![gzip size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/marked@0.3.19/marked.min.js?compression=gzip)](https://cdn.jsdelivr.net/npm/marked@0.3.19/marked.min.js)
[![install size](https://packagephobia.now.sh/badge?p=marked@0.3.19)](https://packagephobia.now.sh/result?p=marked@0.3.19)
[![downloads](https://img.shields.io/npm/dt/marked.svg)](https://www.npmjs.com/package/marked)
[![travis](https://travis-ci.org/markedjs/marked.svg?branch=master)](https://travis-ci.org/markedjs/marked)
- ⚡ built for speed
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications

View File

@ -6,6 +6,10 @@ Marked takes an encompassing approach to its community. As such, you can think o
Users are anyone using Marked in some fashion, without them, there's no reason for us to exist.
|Individual or Organization |Website |Project |Submitted by |
|:-------------------------------------------|:--------------------------|:------------------------------------------------|:-----------------------------------------------------------|
|[OpenUserJS](https://github.com/OpenUserJS) |https://openuserjs.org |[OpenUserJS.org](https://github.com/OpenUserJS/OpenUserJS.org) | Marti Martz (@Martii) Co-Owner / Active Maintainer |
To be listed: please let us know or submit a PR.
To be removed: please let us know or submit a PR.
@ -91,7 +95,7 @@ Christopher Jeffrey @chjj
<h2 id="badges">Badges</h2>
Badges? You don't *need* no stinkin' badges.
Badges? You don't *need* no stinkin' badges.
Movie references aside. (It was either that or, "Let's play a game", but that would have been creepy&hellip;that's why it will most likely come later.)
@ -108,9 +112,9 @@ Badges? If you *want* 'em, we got 'em, and here's how you get 'em (and&hellip;dr
<dd>A contributor with less than one year on this page who is actively engaged in submitting PRs, Issues, making recommendations, sharing thoughts&hellip;without being too annoying about it (let's be clear, submitting 100 Issues recommending the Marked Committers send everyone candy is trying for the badge, not honestly earning it).</dd>
<dt>Dr. DevOps</dt>
<dd>
<p>Someone who understands and contributes to improving the developer experience and flow of Marked into the world.</p>
<p>Someone who understands and contributes to improving the developer experience and flow of Marked into the world.</p>
<blockquote>
"The main characteristic of the DevOps movement is to strongly advocate automation and monitoring at all steps of software construction, from integration, testing, releasing to deployment and infrastructure management. DevOps aims at shorter development cycles, increased deployment frequency, more dependable releases, in close alignment with business objectives." ~ <a href="https://en.wikipedia.org/wiki/DevOps">Wikipedia</a>
"The main characteristic of the DevOps movement is to strongly advocate automation and monitoring at all steps of software construction, from integration, testing, releasing to deployment and infrastructure management. DevOps aims at shorter development cycles, increased deployment frequency, more dependable releases, in close alignment with business objectives." ~ <a href="https://www.wikipedia.org/wiki/DevOps">Wikipedia</a>
</blockquote>
</dd>
<dt>Eye for the CLI</dt>

View File

@ -16,7 +16,7 @@ var block = {
code: /^( {4}[^\n]+\n*)+/,
fences: noop,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
nptable: noop,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
@ -554,7 +554,7 @@ inline.normal = merge({}, inline);
inline.pedantic = merge({}, inline.normal, {
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
link: edit(/^!?\[(label)\]\(\s*<?([\s\S]*?)>?(?:\s+(['"][\s\S]*?['"]))?\s*\)/)
link: edit(/^!?\[(label)\]\((.*?)\)/)
.replace('label', inline._label)
.getRegex(),
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
@ -703,8 +703,19 @@ InlineLexer.prototype.output = function(src) {
src = src.substring(cap[0].length);
this.inLink = true;
href = cap[2];
href = href[0] === '<' ? href.substring(1, href.length - 1) : href;
title = cap[3] ? cap[3].substring(1, cap[3].length - 1) : cap[3];
if (this.options.pedantic) {
link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
if (link) {
href = link[1];
title = link[3];
} else {
title = '';
}
} else {
title = cap[3] ? cap[3].slice(1, -1) : '';
}
href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
out += this.outputLink(cap, {
href: InlineLexer.escapes(href),
title: InlineLexer.escapes(title)

2
marked.min.js vendored

File diff suppressed because one or more lines are too long

211
package-lock.json generated
View File

@ -4,6 +4,36 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/concat-stream": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.0.tgz",
"integrity": "sha1-OU2+C7X+5Gs42JZzXoto7yOQ0A0=",
"dev": true,
"requires": {
"@types/node": "9.6.5"
}
},
"@types/form-data": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz",
"integrity": "sha1-yayFsqX9GENbjIXZ7LUObWyJP/g=",
"dev": true,
"requires": {
"@types/node": "9.6.5"
}
},
"@types/node": {
"version": "9.6.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.5.tgz",
"integrity": "sha512-NOLEgsT6UiDTjnWG5Hd2Mg25LRyz/oe8ql3wbjzgSFeRzRROhPmtlsvIrei4B46UjERF0td9SZ1ZXPLOdcrBHg==",
"dev": true
},
"@types/qs": {
"version": "6.5.1",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.5.1.tgz",
"integrity": "sha512-mNhVdZHdtKHMMxbqzNK3RzkBcN1cux3AvuCYGTvjEIQT2uheH3eCAyYsbMbh2Bq8nXkeOWs1kyDiF7geWRFQ4Q==",
"dev": true
},
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -99,6 +129,18 @@
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
"dev": true
},
"asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=",
"dev": true
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
},
"babel-code-frame": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@ -147,6 +189,12 @@
"integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=",
"dev": true
},
"caseless": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
"dev": true
},
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
@ -223,6 +271,15 @@
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"dev": true,
"requires": {
"delayed-stream": "1.0.0"
}
},
"commander": {
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz",
@ -357,6 +414,12 @@
}
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
},
"diff": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/diff/-/diff-1.0.8.tgz",
@ -662,6 +725,16 @@
"integrity": "sha1-NNDJFbRe3G8BA5PH7vOCOwhWXPI=",
"dev": true
},
"eslint-plugin-vuln-regex-detector": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/eslint-plugin-vuln-regex-detector/-/eslint-plugin-vuln-regex-detector-1.0.4.tgz",
"integrity": "sha512-MlGNEvfk/lmHrbp6gIXKP2NPedA+wX2+KwezolXLE6t9q0pcmohkYm2EKmgL9z5n57CAIYFJ/I4SSI3ANWyl/A==",
"dev": true,
"requires": {
"requireindex": "1.1.0",
"vuln-regex-detector": "1.3.0"
}
},
"eslint-scope": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz",
@ -833,6 +906,17 @@
}
}
},
"form-data": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
"dev": true,
"requires": {
"asynckit": "0.4.0",
"combined-stream": "1.0.6",
"mime-types": "2.1.18"
}
},
"front-matter": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/front-matter/-/front-matter-2.3.0.tgz",
@ -866,6 +950,12 @@
"integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=",
"dev": true
},
"get-port": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz",
"integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=",
"dev": true
},
"get-stdin": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
@ -1040,6 +1130,29 @@
}
}
},
"http-basic": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/http-basic/-/http-basic-7.0.0.tgz",
"integrity": "sha1-gvClBr6UJzLsje6+6A50bvVzbbo=",
"dev": true,
"requires": {
"@types/concat-stream": "1.6.0",
"@types/node": "9.6.5",
"caseless": "0.12.0",
"concat-stream": "1.6.0",
"http-response-object": "3.0.1",
"parse-cache-control": "1.0.1"
}
},
"http-response-object": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.1.tgz",
"integrity": "sha512-6L0Fkd6TozA8kFSfh9Widst0wfza3U1Ex2RjJ6zNDK0vR1U1auUR6jY4Nn2Xl7CCy0ikFmxW1XcspVpb9RvwTg==",
"dev": true,
"requires": {
"@types/node": "9.6.5"
}
},
"iconv-lite": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
@ -1395,6 +1508,21 @@
"mimic-fn": "1.1.0"
}
},
"mime-db": {
"version": "1.33.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
"integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==",
"dev": true
},
"mime-types": {
"version": "2.1.18",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
"integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
"dev": true,
"requires": {
"mime-db": "1.33.0"
}
},
"mimic-fn": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz",
@ -1557,6 +1685,12 @@
"p-limit": "1.1.0"
}
},
"parse-cache-control": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz",
"integrity": "sha1-juqz5U+laSD+Fro493+iGqzC104=",
"dev": true
},
"parse-json": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
@ -1686,6 +1820,15 @@
"integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=",
"dev": true
},
"promise": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/promise/-/promise-8.0.1.tgz",
"integrity": "sha1-5F1osAoXZHttpxG/he1u1HII9FA=",
"dev": true,
"requires": {
"asap": "2.0.6"
}
},
"pseudomap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
@ -1698,6 +1841,12 @@
"integrity": "sha1-TeLmyzspCIyeTLwDv51C+5bOL3U=",
"dev": true
},
"qs": {
"version": "6.5.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz",
"integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==",
"dev": true
},
"read-pkg": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
@ -1741,6 +1890,12 @@
"resolve-from": "1.0.1"
}
},
"requireindex": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.1.0.tgz",
"integrity": "sha1-5UBLgVV+91225JxacgBIk/4D4WI=",
"dev": true
},
"resolve": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz",
@ -2034,6 +2189,26 @@
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"dev": true
},
"sync-request": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.0.0.tgz",
"integrity": "sha512-jGNIAlCi9iU4X3Dm4oQnNQshDD3h0/1A7r79LyqjbjUnj69sX6mShAXlhRXgImsfVKtTcnra1jfzabdZvp+Lmw==",
"dev": true,
"requires": {
"http-response-object": "3.0.1",
"sync-rpc": "1.3.3",
"then-request": "6.0.0"
}
},
"sync-rpc": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.3.tgz",
"integrity": "sha512-xtTZUAeFaescZALim6yqjMDsVQD7mKAkdZ0/FOvVjlrr4uQqrARlWxs4P7bKV2ZPnvOyTVyHyyxqztxtBF4iIw==",
"dev": true,
"requires": {
"get-port": "3.2.0"
}
},
"table": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz",
@ -2091,6 +2266,33 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"then-request": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.0.tgz",
"integrity": "sha512-xA+7uEMc+jsQIoyySJ93Ad08Kuqnik7u6jLS5hR91Z3smAoCfL3M8/MqMlobAa9gzBfO9pA88A/AntfepkkMJQ==",
"dev": true,
"requires": {
"@types/concat-stream": "1.6.0",
"@types/form-data": "0.0.33",
"@types/node": "8.10.8",
"@types/qs": "6.5.1",
"caseless": "0.12.0",
"concat-stream": "1.6.0",
"form-data": "2.3.2",
"http-basic": "7.0.0",
"http-response-object": "3.0.1",
"promise": "8.0.1",
"qs": "6.5.1"
},
"dependencies": {
"@types/node": {
"version": "8.10.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.8.tgz",
"integrity": "sha512-BvcUxNZe9JgiiUVivtiQt3NrPVu9OAQzkxR1Ko9ESftCYU7V6Np5kpDzQwxd+34lsop7SNRdL292Flv52OvCaw==",
"dev": true
}
}
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
@ -2198,6 +2400,15 @@
"integrity": "sha1-qbVhR3x+pdVjsMqqUuQOZo3gwjg=",
"dev": true
},
"vuln-regex-detector": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/vuln-regex-detector/-/vuln-regex-detector-1.3.0.tgz",
"integrity": "sha512-QWm8buVznZjdcfMuFHYsiNfHd0YQ7dO41G0iEGVPlUng5eZUo8uy+QsVCmbgVZ2b96xprY1Tz9dQD7QtvbFHXw==",
"dev": true,
"requires": {
"sync-request": "6.0.0"
}
},
"which": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",

View File

@ -29,6 +29,7 @@
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vuln-regex-detector": "^1.0.4",
"front-matter": "^2.3.0",
"glob-to-regexp": "0.3.0",
"html-differ": "^1.3.4",
@ -45,8 +46,10 @@
"test:specs": "npm test -- test/specs/**/*-spec.js",
"test:cm": "npm test -- test/specs/commonmark/**/*-spec.js",
"test:gfm": "npm test -- test/specs/gfm/**/*-spec.js",
"test:marked": "npm test -- test/specs/marked/**/*-spec.js",
"test:old": "node test",
"test:lint": "eslint bin/marked .",
"test:redos": "eslint --plugin vuln-regex-detector --rule '\"vuln-regex-detector/no-vuln-regex\": 2' lib/marked.js",
"bench": "node test --bench",
"lint": "eslint --fix bin/marked .",
"build": "uglifyjs lib/marked.js -cm --comments /Copyright/ -o marked.min.js",

10
test/index.js vendored
View File

@ -111,12 +111,9 @@ function runTests(engine, options) {
filename = filenames[i];
file = files[filename];
var before = process.hrtime();
success = testFile(engine, file, filename, i + 1);
var elapsed = process.hrtime(before);
var tookLessThanOneSec = (elapsed[0] === 0);
if (success && tookLessThanOneSec) {
if (success) {
succeeded++;
} else {
failed++;
@ -198,6 +195,11 @@ function testFile(engine, file, filename, index) {
}
}
if (elapsed[0] > 0) {
console.log(' failed because it took too long.\n\n passed in %dms', prettyElapsedTime(elapsed));
return false;
}
console.log(' passed in %dms', prettyElapsedTime(elapsed));
return true;
}

1
test/new/link_lt.html Normal file
View File

@ -0,0 +1 @@
<p><a href="%3Ctest">URL</a></p>

1
test/new/link_lt.md Normal file
View File

@ -0,0 +1 @@
[URL](<test)

View File

@ -0,0 +1,48 @@
/**
* Marked does not have a custom markdown specification. However, there are times
* when we come across use cases that are not defined in a given specification.
* Therefore, we will put use cases together to illustrate those instances to
* consumers of marked.
*
*/
var marked = require('../../../lib/marked.js');
var markedSpec = require('./marked.json');
var HtmlDiffer = require('html-differ').HtmlDiffer,
htmlDiffer = new HtmlDiffer();
var since = require('jasmine2-custom-message');
var Messenger = function() {}
Messenger.prototype.message = function(spec, expected, actual) {
return 'CommonMark (' + spec.section + '):\n' + spec.markdown + '\n------\n\nExpected:\n' + expected + '\n------\n\nMarked:\n' + actual;
}
Messenger.prototype.test = function(spec, section, ignore) {
if (spec.section === section) {
var shouldFail = ~ignore.indexOf(spec.example);
it('should ' + (shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, function() {
var expected = spec.html;
var actual = marked(spec.markdown, { headerIds: false, xhtml: true });
since(messenger.message(spec, expected, actual)).expect(
htmlDiffer.isEqual(expected, actual)
).toEqual(!shouldFail);
});
}
}
var messenger = new Messenger();
describe('Marked Code spans', function() {
var section = 'Code spans';
// var shouldPassButFails = [];
var shouldPassButFails = [1];
var willNotBeAttemptedByCoreTeam = [];
var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);
markedSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});

View File

@ -0,0 +1,8 @@
[
{
"section": "Code spans",
"markdown": "`someone@example.com`",
"html": "<p><code>someone@exmaple.com</code></p>\n",
"example": 1
}
]