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.8 to 0.1.9

man/marked.1

221

lib/marked.js

@@ -19,3 +19,3 @@ /**

lheading: /^([^\n]+)\n *(=|-){3,} *\n*/,
blockquote: /^( *>[^\n]+(\n[^\n]+)*)+\n*/,
blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/,
list: /^( *)([*+-]|\d+\.) [^\0]+?(?:\n{2,}(?! )|\s*$)(?!\1bullet)\n*/,

@@ -74,3 +74,3 @@ html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,

block.lexer = function(str) {
block.lexer = function(src) {
var tokens = [];

@@ -80,11 +80,12 @@

str = str
src = src
.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ');
return block.token(str, tokens, true);
return block.token(src, tokens, true);
};
block.token = function(str, tokens, top) {
var str = str.replace(/^ +$/gm, '')
block.token = function(src, tokens, top) {
var src = src.replace(/^ +$/gm, '')
, next
, loose

@@ -97,6 +98,6 @@ , cap

while (str) {
while (src) {
// newline
if (cap = block.newline.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.newline.exec(src)) {
src = src.substring(cap[0].length);
if (cap[0].length > 1) {

@@ -110,4 +111,4 @@ tokens.push({

// code
if (cap = block.code.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.code.exec(src)) {
src = src.substring(cap[0].length);
cap = cap[0].replace(/^ {4}/gm, '');

@@ -122,4 +123,4 @@ tokens.push({

// gfm_code
if (cap = block.gfm_code.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.gfm_code.exec(src)) {
src = src.substring(cap[0].length);
tokens.push({

@@ -134,4 +135,4 @@ type: 'code',

// heading
if (cap = block.heading.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.heading.exec(src)) {
src = src.substring(cap[0].length);
tokens.push({

@@ -146,4 +147,4 @@ type: 'heading',

// lheading
if (cap = block.lheading.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.lheading.exec(src)) {
src = src.substring(cap[0].length);
tokens.push({

@@ -158,4 +159,4 @@ type: 'heading',

// hr
if (cap = block.hr.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.hr.exec(src)) {
src = src.substring(cap[0].length);
tokens.push({

@@ -168,4 +169,4 @@ type: 'hr'

// blockquote
if (cap = block.blockquote.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.blockquote.exec(src)) {
src = src.substring(cap[0].length);
tokens.push({

@@ -189,4 +190,4 @@ type: 'blockquote_start'

// list
if (cap = block.list.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.list.exec(src)) {
src = src.substring(cap[0].length);

@@ -198,4 +199,2 @@ tokens.push({

loose = /\n *\n *(?:[*+-]|\d+\.)/.test(cap[0]);
// Get each top-level item.

@@ -206,18 +205,30 @@ cap = cap[0].match(

next = false;
l = cap.length;
i = 0;
l = cap.length;
for (; i < l; i++) {
item = cap[i];
// Remove the list item's bullet
// so it is seen as the next token.
item = cap[i].replace(/^ *([*+-]|\d+\.) */, '');
space = item.length;
item = item.replace(/^ *([*+-]|\d+\.) */, '');
// Outdent whatever the
// list item contains. Hacky.
space = /\n( +)/.exec(item);
if (space) {
space = new RegExp('^' + space[1], 'gm');
item = item.replace(space, '');
if (~item.indexOf('\n ')) {
space -= item.length;
item = item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '');
}
// Determine whether item is loose or not.
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
// for discount behavior.
loose = next || /\n\n(?!\s*$)/.test(item);
if (i !== l - 1) {
next = item[item.length-1] === '\n';
if (!loose) loose = next;
}
tokens.push({

@@ -245,4 +256,4 @@ type: loose

// html
if (cap = block.html.exec(str)) {
str = str.substring(cap[0].length);
if (cap = block.html.exec(src)) {
src = src.substring(cap[0].length);
tokens.push({

@@ -256,4 +267,4 @@ type: 'html',

// def
if (top && (cap = block.def.exec(str))) {
str = str.substring(cap[0].length);
if (top && (cap = block.def.exec(src))) {
src = src.substring(cap[0].length);
tokens.links[cap[1].toLowerCase()] = {

@@ -267,4 +278,4 @@ href: cap[2],

// top-level paragraph
if (top && (cap = block.paragraph.exec(str))) {
str = str.substring(cap[0].length);
if (top && (cap = block.paragraph.exec(src))) {
src = src.substring(cap[0].length);
tokens.push({

@@ -278,5 +289,5 @@ type: 'paragraph',

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

@@ -316,3 +327,3 @@ type: 'text',

inline.lexer = function(str) {
inline.lexer = function(src) {
var out = ''

@@ -325,6 +336,6 @@ , links = tokens.links

while (str) {
while (src) {
// escape
if (cap = inline.escape.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.escape.exec(src)) {
src = src.substring(cap[0].length);
out += cap[1];

@@ -335,4 +346,4 @@ continue;

// autolink
if (cap = inline.autolink.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.autolink.exec(src)) {
src = src.substring(cap[0].length);
if (cap[2] === '@') {

@@ -356,4 +367,4 @@ text = cap[1][6] === ':'

// gfm_autolink
if (cap = inline.gfm_autolink.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.gfm_autolink.exec(src)) {
src = src.substring(cap[0].length);
text = escape(cap[1]);

@@ -370,4 +381,4 @@ href = text;

// tag
if (cap = inline.tag.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.tag.exec(src)) {
src = src.substring(cap[0].length);
out += cap[0];

@@ -378,8 +389,8 @@ continue;

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

@@ -395,5 +406,5 @@ }

// reflink, nolink
if ((cap = inline.reflink.exec(str))
|| (cap = inline.nolink.exec(str))) {
str = str.substring(cap[0].length);
if ((cap = inline.reflink.exec(src))
|| (cap = inline.nolink.exec(src))) {
src = src.substring(cap[0].length);
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');

@@ -403,3 +414,3 @@ link = links[link.toLowerCase()];

out += cap[0][0];
str = cap[0].substring(1) + str;
src = cap[0].substring(1) + src;
continue;

@@ -412,4 +423,4 @@ }

// strong
if (cap = inline.strong.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.strong.exec(src)) {
src = src.substring(cap[0].length);
out += '<strong>'

@@ -422,4 +433,4 @@ + inline.lexer(cap[2] || cap[1])

// em
if (cap = inline.em.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.em.exec(src)) {
src = src.substring(cap[0].length);
out += '<em>'

@@ -432,4 +443,4 @@ + inline.lexer(cap[2] || cap[1])

// code
if (cap = inline.code.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.code.exec(src)) {
src = src.substring(cap[0].length);
out += '<code>'

@@ -442,4 +453,4 @@ + escape(cap[2], true)

// br
if (cap = inline.br.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.br.exec(src)) {
src = src.substring(cap[0].length);
out += '<br>';

@@ -450,4 +461,4 @@ continue;

// text
if (cap = inline.text.exec(str)) {
str = str.substring(cap[0].length);
if (cap = inline.text.exec(src)) {
src = src.substring(cap[0].length);
out += escape(cap[0]);

@@ -506,3 +517,3 @@ continue;

case 'hr': {
return '<hr>';
return '<hr>\n';
}

@@ -516,3 +527,3 @@ case 'heading': {

+ token.depth
+ '>';
+ '>\n';
}

@@ -530,21 +541,21 @@ case 'code': {

: escape(token.text, true))
+ '</code></pre>';
+ '</code></pre>\n';
}
case 'blockquote_start': {
var body = [];
var body = '';
while (next().type !== 'blockquote_end') {
body.push(tok());
body += tok();
}
return '<blockquote>'
+ body.join('')
+ '</blockquote>';
return '<blockquote>\n'
+ body
+ '</blockquote>\n';
}
case 'list_start': {
var type = token.ordered ? 'ol' : 'ul'
, body = [];
, body = '';
while (next().type !== 'list_end') {
body.push(tok());
body += tok();
}

@@ -554,31 +565,31 @@

+ type
+ '>'
+ body.join('')
+ '>\n'
+ body
+ '</'
+ type
+ '>';
+ '>\n';
}
case 'list_item_start': {
var body = [];
var body = '';
while (next().type !== 'list_item_end') {
body.push(token.type === 'text'
body += token.type === 'text'
? parseText()
: tok());
: tok();
}
return '<li>'
+ body.join(' ')
+ '</li>';
+ body
+ '</li>\n';
}
case 'loose_item_start': {
var body = [];
var body = '';
while (next().type !== 'list_item_end') {
body.push(tok());
body += tok();
}
return '<li>'
+ body.join(' ')
+ '</li>';
+ body
+ '</li>\n';
}

@@ -591,3 +602,3 @@ case 'html': {

+ inline.lexer(token.text)
+ '</p>';
+ '</p>\n';
}

@@ -597,3 +608,3 @@ case 'text': {

+ parseText()
+ '</p>';
+ '</p>\n';
}

@@ -604,3 +615,3 @@ }

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

@@ -610,6 +621,6 @@

&& top.type === 'text') {
body.push(next().text);
body += '\n' + next().text;
}
return inline.lexer(body.join('\n'));
return inline.lexer(body);
};

@@ -620,5 +631,5 @@

var out = [];
var out = '';
while (next()) {
out.push(tok());
out += tok();
}

@@ -629,3 +640,3 @@

return out.join('\n');
return out;
};

@@ -637,7 +648,5 @@

var escape = function(html, dbl) {
var escape = function(html, encode) {
return html
.replace(!dbl
? /&(?!#?\w+;)/g
: /&/g, '&amp;')
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/</g, '&lt;')

@@ -649,10 +658,10 @@ .replace(/>/g, '&gt;')

var mangle = function(str) {
var mangle = function(text) {
var out = ''
, ch
, l = text.length
, i = 0
, l = str.length;
, ch;
for (; i < l; i++) {
ch = str.charCodeAt(i);
ch = text.charCodeAt(i);
if (Math.random() > 0.5) {

@@ -680,4 +689,4 @@ ch = 'x' + ch.toString(16);

var marked = function(str) {
return parse(block.lexer(str));
var marked = function(src) {
return parse(block.lexer(src));
};

@@ -684,0 +693,0 @@

@@ -5,11 +5,12 @@ {

"author": "Christopher Jeffrey",
"version": "0.1.8",
"version": "0.1.9",
"main": "./lib/marked.js",
"bin": { "marked": "./bin/marked" },
"bin": "./bin/marked",
"man": "./man/marked.1",
"preferGlobal": false,
"repository": "git://github.com/chjj/marked.git",
"bugs" : {
"url": "http://github.com/chjj/marked/issues"
},
"homepage": "https://github.com/chjj/marked",
"bugs": "http://github.com/chjj/marked/issues",
"keywords": [ "markdown", "markup", "html" ],
"tags": [ "markdown", "markup", "html" ]
}

@@ -22,8 +22,8 @@ # marked

$ node test --bench
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 completed in 6485ms.
marked (with gfm) completed in 7466ms.
discount completed in 7169ms.
showdown (reuse converter) completed in 15937ms.
showdown (new converter) completed in 18279ms.
markdown-js completed in 23572ms.
```

@@ -30,0 +30,0 @@

Sorry, the diff of this file is not supported yet

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