Socket
Socket
Sign inDemoInstall

marked

Package Overview
Dependencies
Maintainers
1
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

179

lib/marked.js

@@ -14,20 +14,47 @@ /**

newline: /^\n+/,
code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?=\n| *$)/,
gfm_code: /^ *``` *(\w+)? *\n([^\0]+?)\s*```(?= *\n| *$)/,
hr: /^( *[\-*_]){3,} *\n/,
code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?:\n+| *$)/,
gfm_code: /^ *``` *(\w+)? *\n([^\0]+?)\s*```(?: *\n+| *$)/,
hr: /^( *[\-*_]){3,} *\n+/,
heading: /^ *(#{1,6}) *([^\0]+?) *#* *\n+/,
lheading: /^([^\n]+)\n *(=|-){3,}/,
blockquote: /^ *>[^\n]*(?:\n *>[^\n]*)*/,
list: /^( *)([*+-]|\d+\.) [^\0]+?(?:\n{2,}(?! )|\s*$)(?!\1\2|\1\d+\.)/,
html: /^ *(?:<!--[^\0]*?-->|<(\w+)[^\0]+?<\/\1>|<\w+[^>]*>) *(?:\n{2,}|\s*$)/,
text: /^[^\n]+/,
paragraph: /^/
lheading: /^([^\n]+)\n *(=|-){3,} *\n*/,
blockquote: /^( *>[^\n]+(\n[^\n]+)*)+\n*/,
list: /^( *)([*+-]|\d+\.) [^\0]+?(?:\n{2,}(?! )|\s*$)(?!\1bullet)\n*/,
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
paragraph: /^([^\n]+\n?(?!body))+\n*/,
text: /^[^\n]+/
};
block.list = (function() {
var list = block.list.source;
list = list
.replace('bullet', /(?:[*+-](?!(?: *[-*]){2,})|\d+\.)/.source);
return new RegExp(list);
})();
block.html = (function() {
var html = block.html.source;
// The real markdown checks for block elements.
// It's better to check for non-inline elements.
// Unknown elements will then be treated as block elements.
var closed = '<(?!(?:'
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
+ '|span|br|wbr|ins|del|img)\\b)'
+ '(\\w+)[^\\0]+?</\\1>';
html = html
.replace('comment', /<!--[^\0]*?-->/.source)
.replace('closed', closed)
.replace('closing', /<\w+(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^>])*>/.source);
return new RegExp(html);
})();
block.paragraph = (function() {
var body = [];
var paragraph = block.paragraph.source
, body = [];
// this rule determines which tokens are able to
// immediately follow a line of text on the top level.
// everything below conforms to markdown.pl.
(function push(rule) {

@@ -38,3 +65,2 @@ rule = rule.source || block[rule].source;

})
// no code
('gfm_code')

@@ -45,7 +71,2 @@ ('hr')

('blockquote')
// no list
// html - stop before block-level elements only
// from: github.com/Kroc/ReMarkable
// (possibly stray from conformance and remove this altogether)
(new RegExp('<'

@@ -56,8 +77,6 @@ + '(?:article|aside|audio|blockquote|canvas|caption|col|colgroup|dialog|div'

+ '|p|param|pre|script|section|select|source|table|t(?:body|foot|head)'
+ '|t[dhr]|textarea|video)'));
+ '|t[dhr]|textarea|video)\\b'));
body = body.join('|');
return new
RegExp('^([^\\n]+\\n?(?!' + body + '))+\\n*');
RegExp(paragraph.replace('body', body.join('|')));
})();

@@ -77,5 +96,5 @@

str = str.replace(
/^ {0,3}\[([^\]]+)\]: *([^ ]+)(?: +"([^\n]+)")? *$/gm,
/^ {0,3}\[([^\]]+)\]: *([^ ]+)(?: +["(]([^\n]+)[")])? *$/gm,
function(__, id, href, title) {
links[id] = {
links[id.toLowerCase()] = {
href: href,

@@ -119,5 +138,3 @@ title: title

type: 'code',
text: cap[cap.length-1] === '\n'
? cap.slice(0, -1)
: cap
text: cap.replace(/\n+$/, '')
});

@@ -175,7 +192,10 @@ continue;

});
cap = cap[0].replace(/^ *>/gm, '');
// pass `top` to keep the current
// "toplevel" state. this is exactly
// Pass `top` to keep the current
// "toplevel" state. This is exactly
// how markdown.pl works.
block.token(cap, tokens, top);
tokens.push({

@@ -198,5 +218,5 @@ type: 'blockquote_end'

// get each top-level item
// Get each top-level item.
cap = cap[0].match(
/^( *)([*+-]|\d+\.)[^\n]*(?:\n(?!\1\2|\1\d+\.)[^\n]*)*/gm
/^( *)([*+-]|\d+\.)[^\n]*(?:\n(?!\1(?:[*+-]|\d+\.))[^\n]*)*/gm
);

@@ -208,7 +228,8 @@

for (; i < l; i++) {
// remove the list item's bullet
// so it is seen as the next token
// Remove the list item's bullet
// so it is seen as the next token.
item = cap[i].replace(/^ *([*+-]|\d+\.) */, '');
// outdent whatever the
// list item contains, hacky
// Outdent whatever the
// list item contains. Hacky.
space = /\n( +)/.exec(item);

@@ -219,2 +240,3 @@ if (space) {

}
tokens.push({

@@ -225,3 +247,6 @@ type: loose

});
// Recurse.
block.token(item, tokens);
tokens.push({

@@ -249,4 +274,3 @@ type: 'list_item_end'

// optimization for top-level paragraphs.
// ignores list-item-looking lines.
// top-level paragraph
if (top && (cap = block.paragraph.exec(str))) {

@@ -261,4 +285,5 @@ str = str.substring(cap[0].length);

// text (top-level should never reach here)
// text
if (cap = block.text.exec(str)) {
// Top-level should never reach here.
str = str.substring(cap[0].length);

@@ -281,18 +306,35 @@ tokens.push({

var inline = {
escape: /^\\([\\`*{}\[\]()#+\-.!_])/,
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
gfm_autolink: /^(\w+:\/\/[^\s]+[^.,:;"')\]\s])/,
tag: /^<!--[^\0]*?-->|^<\/?\w+[^>]*>/,
link: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]\(([^\)]*)\)/,
reflink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]\s*\[([^\]]*)\]/,
tag: /^<!--[^\0]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^>])*>/,
link: /^!?\[((?:\[[^\]]*\]|[^\[\]]|\[|\](?=[^[\]]*\]))*)\]\(([^\)]*)\)/,
reflink: /^!?\[((?:\[[^\]]*\]|[^\[\]]|\[|\](?=[^[\]]*\]))*)\]\s*\[([^\]]*)\]/,
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
strong: /^__(?=\S)([^\0]*?\S)__(?!_)|^\*\*(?=\S)([^\0]*?\S)\*\*(?!\*)/,
em: /^\b_(?=\S)([^\0]*?\S)_\b|^\*(?=\S)([^\0]*?\S)\*/,
code: /^`([^`]+)`|^``([^\0]+?)``/,
// discount em/strong behavior
// strong: /^__([^\0]+?)__(?!_)|^\*\*([^\0]+?)\*\*(?!\*)/,
// em: /^\b_(?=\S)([^\0]*?\S)_\b|^\*(?=\S)([^\0]*?(?:\*\*|[^\s*]))\*(?!\*)/,
// markdown.js em/strong behavior
strong: /^__([^\0]+?)__(?!_)|^\*\*([^\0]+?)\*\*(?!\*)/,
em: /^\b_([^\0]+?)_\b|^\*((?:\*\*|[^\0])+?)\*(?!\*)/,
// upskirt/markdown.pl em/strong behavior
// strong: /^__(?=\S)([^\0]*?\S)__(?!_)|^\*\*(?=\S)([^\0]*?\S)\*\*(?!\*)/,
// em: /^\b_(?=\S)([^\0]*?\S)_\b|^\*(?=\S)([^\0]*?\S)\*(?!\*)/,
// strict em/strong behavior
// closest to being conformant without markdown.pl's bugs
// strong: /^__(?=\S)([^\0]*?\S)__(?!_)|^\*\*(?=\S)([^\0]*?\S)\*\*(?!\*)/,
// em: /^\b_(?=\S)([^\0]*?\S)_\b|^\*(?=\S)([^\0]*?(?:\*\*|[^\s*]))\*(?!\*)/,
code: /^(`+)([^\0]*?[^`])\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
text: /^/
text: /^[^\0]+?(?=body|$)/
};
inline.text = (function() {
var body = [];
var text = inline.text.source
, body = [];

@@ -314,3 +356,3 @@ (function push(rule) {

return new
RegExp('^[^\\0]+?(?=' + body.join('|') + '|$)');
RegExp(text.replace('body', body.join('|')));
})();

@@ -382,2 +424,7 @@

text = /^\s*<?([^\s]*?)>?(?:\s+"([^\n]+)")?\s*$/.exec(cap[2]);
if (!text) {
out += cap[0][0];
str = cap[0].substring(1) + str;
continue;
}
link = {

@@ -396,4 +443,4 @@ href: text[1],

link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
link = links[link];
if (!link) {
link = links[link.toLowerCase()];
if (!link || !link.href) {
out += cap[0][0];

@@ -429,3 +476,3 @@ str = cap[0].substring(1) + str;

out += '<code>'
+ escape(cap[2] || cap[1], true)
+ escape(cap[2], true)
+ '</code>';

@@ -459,6 +506,6 @@ continue;

+ (link.title
? ' title="'
+ escape(link.title)
+ '"'
: '')
? ' title="'
+ escape(link.title)
+ '"'
: '')
+ '>'

@@ -474,6 +521,6 @@ + inline.lexer(cap[1])

+ (link.title
? ' title="'
+ escape(link.title)
+ '"'
: '')
? ' title="'
+ escape(link.title)
+ '"'
: '')
+ '>';

@@ -514,10 +561,10 @@ }

+ (token.lang
? ' class="'
+ token.lang
+ '"'
: '')
? ' class="'
+ token.lang
+ '"'
: '')
+ '>'
+ (token.escaped
? token.text
: escape(token.text, true))
? token.text
: escape(token.text, true))
+ '</code></pre>';

@@ -524,0 +571,0 @@ }

@@ -5,7 +5,11 @@ {

"author": "Christopher Jeffrey",
"version": "0.1.5",
"version": "0.1.6",
"main": "./lib/marked.js",
"bin": { "marked": "./bin/marked" },
"repository": "git://github.com/chjj/marked.git",
"keywords": [ "markdown", "markup" ]
"bugs" : {
"url": "http://github.com/chjj/marked/issues"
},
"keywords": [ "markdown", "markup", "html" ],
"tags": [ "markdown", "markup", "html" ]
}

@@ -22,11 +22,11 @@ # marked

$ node test --bench
marked completed in 7904ms.
marked (with gfm) completed in 8947ms.
discount completed in 7171ms.
showdown (reuse converter) completed in 15729ms.
showdown (new converter) completed in 18149ms.
markdown-js completed in 24521ms.
marked completed in 7303ms.
marked (with gfm) completed in 8206ms.
discount completed in 7170ms.
showdown (reuse converter) completed in 15865ms.
showdown (new converter) completed in 18140ms.
markdown-js completed in 24357ms.
```
__Marked is now only ~700ms behind Discount (which is written in C).__
__Marked is now only ~130ms behind Discount, which is written in C.__

@@ -33,0 +33,0 @@ For those feeling skeptical: These benchmarks run the entire markdown test suite

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc