Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marked

Package Overview
Dependencies
Maintainers
1
Versions
179
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.6 to 0.1.7

130

lib/marked.js

@@ -14,6 +14,6 @@ /**

newline: /^\n+/,
code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?:\n+| *$)/,
gfm_code: /^ *``` *(\w+)? *\n([^\0]+?)\s*```(?: *\n+| *$)/,
hr: /^( *[\-*_]){3,} *\n+/,
heading: /^ *(#{1,6}) *([^\0]+?) *#* *\n+/,
code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?:\n+|$)/,
gfm_code: /^ *``` *(\w+)? *\n([^\0]+?)\s*``` *(?:\n+|$)/,
hr: /^( *[\-*_]){3,} *(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
lheading: /^([^\n]+)\n *(=|-){3,} *\n*/,

@@ -23,2 +23,3 @@ blockquote: /^( *>[^\n]+(\n[^\n]+)*)+\n*/,

html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
def: /^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
paragraph: /^([^\n]+\n?(?!body))+\n*/,

@@ -40,15 +41,7 @@ text: /^[^\n]+/

// 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);
.replace('closed', /<(?!elements)(\w+)[^\0]+?<\/\1>/.source)
.replace('closing', /<\w+(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^>])*>/.source)
.replace('elements', elements());

@@ -63,3 +56,3 @@ return new RegExp(html);

(function push(rule) {
rule = rule.source || block[rule].source;
rule = block[rule] ? block[rule].source : rule;
body.push(rule.replace(/(^|[^\[])\^/g, '$1'));

@@ -73,8 +66,4 @@ return push;

('blockquote')
(new RegExp('<'
+ '(?:article|aside|audio|blockquote|canvas|caption|col|colgroup|dialog|div'
+ '|d[ltd]|embed|fieldset|figure|figcaption|footer|form|h[1-6r]|header'
+ '|hgroup|input|label|legend|li|nav|noscript|object|[ou]l|optgroup|option'
+ '|p|param|pre|script|section|select|source|table|t(?:body|foot|head)'
+ '|t[dhr]|textarea|video)\\b'));
('<(?!' + elements() + ')\\w+')
('def');

@@ -90,21 +79,10 @@ return new

block.lexer = function(str) {
var tokens = []
, links = {};
var tokens = [];
str = str.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ');
tokens.links = {};
str = str.replace(
/^ {0,3}\[([^\]]+)\]: *([^ ]+)(?: +["(]([^\n]+)[")])? *$/gm,
function(__, id, href, title) {
links[id.toLowerCase()] = {
href: href,
title: title
};
return '';
}
);
str = str
.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ');
tokens.links = links;
return block.token(str, tokens, true);

@@ -193,3 +171,3 @@ };

cap = cap[0].replace(/^ *>/gm, '');
cap = cap[0].replace(/^ *> ?/gm, '');

@@ -270,2 +248,12 @@ // Pass `top` to keep the current

// def
if (top && (cap = block.def.exec(str))) {
str = str.substring(cap[0].length);
tokens.links[cap[1].toLowerCase()] = {
href: cap[2],
title: cap[3]
};
continue;
}
// top-level paragraph

@@ -308,47 +296,9 @@ if (top && (cap = block.paragraph.exec(str))) {

nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
// 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: /^[^\0]+?(?=body|$)/
text: /^[^\0]+?(?=[\\<!\[_*`]|\w+:\/\/| {2,}\n|$)/
};
inline.text = (function() {
var text = inline.text.source
, body = [];
(function push(rule) {
rule = inline[rule].source;
body.push(rule.replace(/(^|[^\[])\^/g, '$1'));
return push;
})
('escape')
('gfm_autolink')
('tag')
('nolink')
('strong')
('em')
('code')
('br');
return new
RegExp(text.replace('body', body.join('|')));
})();
/**

@@ -423,7 +373,6 @@ * Inline Lexer

}
link = {
out += outputLink(cap, {
href: text[1],
title: text[2]
};
out += mlink(cap, link);
});
continue;

@@ -443,3 +392,3 @@ }

}
out += mlink(cap, link);
out += outputLink(cap, link);
continue;

@@ -493,3 +442,3 @@ }

var mlink = function(cap, link) {
var outputLink = function(cap, link) {
if (cap[0][0] !== '!') {

@@ -595,3 +544,3 @@ return '<a href="'

body.push(token.type === 'text'
? text()
? parseText()
: tok());

@@ -625,3 +574,3 @@ }

return '<p>'
+ text()
+ parseText()
+ '</p>';

@@ -632,3 +581,3 @@ }

var text = function() {
var parseText = function() {
var body = [ token.text ]

@@ -691,2 +640,11 @@ , top;

function elements() {
var elements = '(?:'
+ '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';
return elements;
}
/**

@@ -693,0 +651,0 @@ * Expose

@@ -5,3 +5,3 @@ {

"author": "Christopher Jeffrey",
"version": "0.1.6",
"version": "0.1.7",
"main": "./lib/marked.js",

@@ -8,0 +8,0 @@ "bin": { "marked": "./bin/marked" },

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

$ node test --bench
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 completed in 6623ms.
marked (with gfm) completed in 7618ms.
discount completed in 7230ms.
showdown (reuse converter) completed in 16136ms.
showdown (new converter) completed in 18526ms.
markdown-js completed in 24347ms.
```
__Marked is now only ~130ms behind Discount, which is written in C.__
__Marked is now faster than Discount, which is written in C.__

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

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