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

commonmark

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonmark - npm Package Compare versions

Comparing version 0.12.0 to 0.15.0

9

bench.js
var Benchmark = require('benchmark').Benchmark;
var suite = new Benchmark.Suite;
var suite = new Benchmark.Suite();
var fs = require('fs');

@@ -14,5 +14,4 @@ var sm = require('./lib/index.js');

// var converter = new showdown.converter();
suite.add('commonmark.js markdown->html', function() {
"use strict";
var doc = new sm.DocParser().parse(contents);

@@ -24,2 +23,3 @@ var renderer = new sm.HtmlRenderer();

.add('showdown.js markdown->html', function() {
"use strict";
var converter = new showdown.converter();

@@ -30,2 +30,3 @@ converter.makeHtml(contents);

.add('marked.js markdown->html', function() {
"use strict";
marked(contents);

@@ -35,5 +36,5 @@ })

.on('cycle', function(event) {
"use strict";
console.log(String(event.target));
})
.run();

@@ -15,3 +15,3 @@ var C_GREATERTHAN = 62;

var detabLine = function(text) {
if (text.indexOf('\t') == -1) {
if (text.indexOf('\t') === -1) {
return text;

@@ -69,6 +69,6 @@ } else {

var canContain = function(parent_type, child_type) {
return ( parent_type == 'Document' ||
parent_type == 'BlockQuote' ||
parent_type == 'ListItem' ||
(parent_type == 'List' && child_type == 'ListItem') );
return ( parent_type === 'Document' ||
parent_type === 'BlockQuote' ||
parent_type === 'ListItem' ||
(parent_type === 'List' && child_type === 'ListItem') );
};

@@ -78,5 +78,5 @@

var acceptsLines = function(block_type) {
return ( block_type == 'Paragraph' ||
block_type == 'IndentedCode' ||
block_type == 'FencedCode' );
return ( block_type === 'Paragraph' ||
block_type === 'IndentedCode' ||
block_type === 'FencedCode' );
};

@@ -90,3 +90,3 @@

}
if ((block.t == 'List' || block.t == 'ListItem') && block.children.length > 0) {
if ((block.t === 'List' || block.t === 'ListItem') && block.children.length > 0) {
return endsWithBlankLine(block.children[block.children.length - 1]);

@@ -113,3 +113,3 @@ } else {

if (last_list) {
while (block != last_list) {
while (block !== last_list) {
this.finalize(block, line_number);

@@ -128,3 +128,3 @@ block = block.parent;

if (!(this.tip.open)) {
throw({ msg: "Attempted to add line (" + ln + ") to closed container." });
throw { msg: "Attempted to add line (" + ln + ") to closed container." };
}

@@ -270,7 +270,9 @@ this.tip.strings.push(s);

case 'ATXHeader':
case 'SetextHeader':
case 'Header':
case 'HorizontalRule':
// a header can never container > 1 line, so fail to match:
all_matched = false;
if (blank) {
container.last_line_blank = true;
}
break;

@@ -289,2 +291,3 @@

if (blank) {
container.last_line_blank = true;
all_matched = false;

@@ -318,8 +321,9 @@ }

var closeUnmatchedBlocks = function(mythis) {
var already_done = false;
// finalize any blocks not matched
while (!already_done && oldtip != last_matched_container) {
while (!already_done && oldtip !== last_matched_container) {
mythis.finalize(oldtip, line_number);
oldtip = oldtip.parent;
}
var already_done = true;
already_done = true;
};

@@ -334,7 +338,7 @@

// adding children to the last matched container:
while (container.t != 'FencedCode' &&
container.t != 'IndentedCode' &&
container.t != 'HtmlBlock' &&
while (container.t !== 'FencedCode' &&
container.t !== 'IndentedCode' &&
container.t !== 'HtmlBlock' &&
// this is a little performance optimization:
matchAt(/^[ #`~*+_=<>0-9-]/,ln,offset) !== -1) {
matchAt(/^[ #`~*+_=<>0-9-]/, ln, offset) !== -1) {

@@ -353,3 +357,3 @@ match = matchAt(/[^ ]/, ln, offset);

// indented code
if (this.tip.t != 'Paragraph' && !blank) {
if (this.tip.t !== 'Paragraph' && !blank) {
offset += CODE_INDENT;

@@ -376,7 +380,7 @@ closeUnmatchedBlocks(this);

closeUnmatchedBlocks(this);
container = this.addChild('ATXHeader', line_number, first_nonspace);
container = this.addChild('Header', line_number, first_nonspace);
container.level = match[0].trim().length; // number of #s
// remove trailing ###s:
container.strings =
[ln.slice(offset).replace(/^ *#+ *$/, '').replace(/ +#+ *$/,'')];
[ln.slice(offset).replace(/^ *#+ *$/, '').replace(/ +#+ *$/, '')];
break;

@@ -402,3 +406,3 @@

} else if (container.t == 'Paragraph' &&
} else if (container.t === 'Paragraph' &&
container.strings.length === 1 &&

@@ -408,3 +412,3 @@ ((match = ln.slice(first_nonspace).match(/^(?:=+|-+) *$/)))) {

closeUnmatchedBlocks(this);
container.t = 'SetextHeader'; // convert Paragraph to SetextHeader
container.t = 'Header'; // convert Paragraph to SetextHeader
container.level = match[0][0] === '=' ? 1 : 2;

@@ -464,3 +468,3 @@ offset = ln.length;

!blank &&
this.tip.t == 'Paragraph' &&
this.tip.t === 'Paragraph' &&
this.tip.strings.length > 0) {

@@ -482,7 +486,8 @@ // lazy paragraph continuation

container.last_line_blank = blank &&
!(container.t == 'BlockQuote' ||
container.t == 'FencedCode' ||
(container.t == 'ListItem' &&
!(container.t === 'BlockQuote' ||
container.t === 'Header' ||
container.t === 'FencedCode' ||
(container.t === 'ListItem' &&
container.children.length === 0 &&
container.start_line == line_number));
container.start_line === line_number));

@@ -504,3 +509,3 @@ var cont = container;

match = (indent <= 3 &&
ln.charAt(first_nonspace) == container.fence_char &&
ln.charAt(first_nonspace) === container.fence_char &&
ln.slice(first_nonspace).match(/^(?:`{3,}|~{3,})(?= *$)/));

@@ -515,4 +520,3 @@ if (match && match[0].length >= container.fence_length) {

case 'ATXHeader':
case 'SetextHeader':
case 'Header':
case 'HorizontalRule':

@@ -526,5 +530,5 @@ // nothing to do; we already added the contents.

} else if (blank) {
// do nothing
} else if (container.t != 'HorizontalRule' &&
container.t != 'SetextHeader') {
break;
} else if (container.t !== 'HorizontalRule' &&
container.t !== 'Header') {
// create paragraph container for line

@@ -563,3 +567,3 @@ container = this.addChild('Paragraph', line_number, first_nonspace);

case 'Paragraph':
block.string_content = block.strings.join('\n').replace(/^ */m,'');
block.string_content = block.strings.join('\n').replace(/^ {2,}/m, '');
// delete block.strings;

@@ -579,4 +583,3 @@

case 'ATXHeader':
case 'SetextHeader':
case 'Header':
case 'HtmlBlock':

@@ -587,3 +590,4 @@ block.string_content = block.strings.join('\n');

case 'IndentedCode':
block.string_content = block.strings.join('\n').replace(/(\n *)*$/,'\n');
block.string_content = block.strings.join('\n').replace(/(\n *)*$/, '\n');
block.t = 'CodeBlock';
break;

@@ -594,3 +598,3 @@

block.info = unescapeString(block.strings[0].trim());
if (block.strings.length == 1) {
if (block.strings.length === 1) {
block.string_content = '';

@@ -600,2 +604,3 @@ } else {

}
block.t = 'CodeBlock';
break;

@@ -611,3 +616,3 @@

// check for non-final list item ending with blank line:
var last_item = i == numitems - 1;
var last_item = i === numitems - 1;
if (endsWithBlankLine(item) && !last_item) {

@@ -623,3 +628,3 @@ block.tight = false;

var subitem = item.children[j];
var last_subitem = j == numsubitems - 1;
var last_subitem = j === numsubitems - 1;
if (endsWithBlankLine(subitem) && !(last_item && last_subitem)) {

@@ -656,4 +661,3 @@ block.tight = false;

break;
case 'SetextHeader':
case 'ATXHeader':
case 'Header':
newblock.inline_content =

@@ -667,7 +671,6 @@ this.inlineParser.parse(block.string_content.trim(), this.refmap);

break;
case 'FencedCode':
case 'CodeBlock':
newblock.string_content = block.string_content;
newblock.info = block.info;
break;
case 'IndentedCode':
case 'HtmlBlock':

@@ -695,6 +698,6 @@ newblock.string_content = block.string_content;

this.refmap = {};
var lines = input.replace(/\n$/,'').split(/\r\n|\n|\r/);
var lines = input.replace(/\n$/, '').split(/\r\n|\n|\r/);
var len = lines.length;
for (var i = 0; i < len; i++) {
this.incorporateLine(lines[i], i+1);
this.incorporateLine(lines[i], i + 1);
}

@@ -701,0 +704,0 @@ while (this.tip) {

// derived from https://github.com/mathiasbynens/String.fromCodePoint
/*! http://mths.be/fromcodepoint v0.2.1 by @mathias */
if (String.fromCodePoint) {
module.exports = function (_) {
"use strict";
try {
return String.fromCodePoint(_);
} catch (e) {
if (e instanceof RangeError) {
return String.fromCharCode(0xFFFD);
}
throw e;
}
};
module.exports = String.fromCodePoint;
} else {

@@ -11,3 +20,4 @@

var floor = Math.floor;
var fromCodePoint = function(_) {
var fromCodePoint = function() {
"use strict";
var MAX_SIZE = 0x4000;

@@ -29,3 +39,3 @@ var codeUnits = [];

codePoint > 0x10FFFF || // not a valid Unicode code point
floor(codePoint) != codePoint // not an integer
floor(codePoint) !== codePoint // not an integer
) {

@@ -43,3 +53,3 @@ return String.fromCharCode(0xFFFD);

}
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
result += stringFromCharCode.apply(null, codeUnits);

@@ -46,0 +56,0 @@ codeUnits.length = 0;

@@ -26,3 +26,3 @@ // Helper function to produce content in a pair of HTML tags.

switch (inline.t) {
case 'Str':
case 'Text':
return this.escape(inline.c);

@@ -32,3 +32,3 @@ case 'Softbreak':

case 'Hardbreak':
return inTags('br',[],"",true) + '\n';
return inTags('br', [], "", true) + '\n';
case 'Emph':

@@ -50,3 +50,3 @@ return inTags('em', [], this.renderInlines(inline.c));

replace(/\<[^>]*alt="([^"]*)"[^>]*\>/g, '$1').
replace(/\<[^>]*\>/g,'')]];
replace(/\<[^>]*\>/g, '')]];
if (inline.title) {

@@ -67,3 +67,3 @@ attrs.push(['title', this.escape(inline.title, true)]);

var result = '';
for (var i=0; i < inlines.length; i++) {
for (var i = 0; i < inlines.length; i++) {
result = result + this.renderInline(inlines[i]);

@@ -95,6 +95,13 @@ }

case 'ListItem':
return inTags('li', [], this.renderBlocks(block.children, in_tight_list).trim());
var contents = this.renderBlocks(block.children, in_tight_list);
if (/^[<]/.test(contents)) {
contents = '\n' + contents;
}
if (/[>]$/.test(contents)) {
contents = contents + '\n';
}
return inTags('li', [], contents, false).trim();
case 'List':
tag = block.list_data.type == 'Bullet' ? 'ul' : 'ol';
attr = (!block.list_data.start || block.list_data.start == 1) ?
tag = block.list_data.type === 'Bullet' ? 'ul' : 'ol';
attr = (!block.list_data.start || block.list_data.start === 1) ?
[] : [['start', block.list_data.start.toString()]];

@@ -104,15 +111,10 @@ return inTags(tag, attr, this.innersep +

this.innersep);
case 'ATXHeader':
case 'SetextHeader':
case 'Header':
tag = 'h' + block.level;
return inTags(tag, [], this.renderInlines(block.inline_content));
case 'IndentedCode':
case 'CodeBlock':
info_words = block.info ? block.info.split(/ +/) : [];
attr = (info_words.length === 0 || info_words[0].length === 0) ?
[] : [['class', 'language-' + this.escape(info_words[0], true)]];
return inTags('pre', [],
inTags('code', [], this.escape(block.string_content)));
case 'FencedCode':
info_words = block.info.split(/ +/);
attr = info_words.length === 0 || info_words[0].length === 0 ?
[] : [['class','language-' +
this.escape(info_words[0],true)]];
return inTags('pre', [],
inTags('code', attr, this.escape(block.string_content)));

@@ -124,3 +126,3 @@ case 'HtmlBlock':

case 'HorizontalRule':
return inTags('hr',[],"",true);
return inTags('hr', [], "", true);
default:

@@ -135,3 +137,3 @@ console.log("Unknown block type " + block.t);

var result = [];
for (var i=0; i < blocks.length; i++) {
for (var i = 0; i < blocks.length; i++) {
if (blocks[i].t !== 'ReferenceDef') {

@@ -155,11 +157,11 @@ result.push(this.renderBlock(blocks[i], in_tight_list));

if (preserve_entities) {
return s.replace(/[&](?![#](x[a-f0-9]{1,8}|[0-9]{1,8});|[a-z][a-z0-9]{1,31};)/gi,'&amp;')
.replace(/[<]/g,'&lt;')
.replace(/[>]/g,'&gt;')
.replace(/["]/g,'&quot;');
return s.replace(/[&](?![#](x[a-f0-9]{1,8}|[0-9]{1,8});|[a-z][a-z0-9]{1,31};)/gi, '&amp;')
.replace(/[<]/g, '&lt;')
.replace(/[>]/g, '&gt;')
.replace(/["]/g, '&quot;');
} else {
return s.replace(/[&]/g,'&amp;')
.replace(/[<]/g,'&lt;')
.replace(/[>]/g,'&gt;')
.replace(/["]/g,'&quot;');
.replace(/[<]/g, '&lt;')
.replace(/[>]/g, '&gt;')
.replace(/["]/g, '&quot;');
}

@@ -166,0 +168,0 @@ },

@@ -12,2 +12,4 @@ // commonmark.js - CommomMark in JavaScript

"use strict";
var util = require('util');

@@ -14,0 +16,0 @@

@@ -14,3 +14,2 @@ var fromCodePoint = require('./from-code-point.js');

var C_LESSTHAN = 60;
var C_GREATERTHAN = 62;
var C_BANG = 33;

@@ -26,5 +25,2 @@ var C_BACKSLASH = 92;

var ESCAPED_CHAR = '\\\\' + ESCAPABLE;
var IN_DOUBLE_QUOTES = '"(' + ESCAPED_CHAR + '|[^"\\x00])*"';
var IN_SINGLE_QUOTES = '\'(' + ESCAPED_CHAR + '|[^\'\\x00])*\'';
var IN_PARENS = '\\((' + ESCAPED_CHAR + '|[^)\\x00])*\\)';
var REG_CHAR = '[^\\\\()\\x00-\\x20]';

@@ -50,2 +46,4 @@ var IN_PARENS_NOSP = '\\((' + REG_CHAR + '|' + ESCAPED_CHAR + ')*\\)';

var rePunctuation = new RegExp(/^[\u2000-\u206F\u2E00-\u2E7F\\'!"#\$%&\(\)\*\+,\-\.\/:;<=>\?@\[\]\^_`\{\|\}~]/);
var reHtmlTag = new RegExp('^' + HTMLTAG, 'i');

@@ -70,4 +68,2 @@

var reEscapedChar = new RegExp('^\\\\(' + ESCAPABLE + ')');
var reEntityHere = new RegExp('^' + ENTITY, 'i');

@@ -92,3 +88,3 @@

return s.trim()
.replace(/\s+/,' ')
.replace(/\s+/, ' ')
.toUpperCase();

@@ -106,6 +102,6 @@ };

var match = function(re) {
var match = re.exec(this.subject.slice(this.pos));
if (match) {
this.pos += match.index + match[0].length;
return match[0];
var m = re.exec(this.subject.slice(this.pos));
if (m) {
this.pos += m.index + m[0].length;
return m[0];
} else {

@@ -139,3 +135,2 @@ return null;

var parseBackticks = function(inlines) {
var startpos = this.pos;
var ticks = this.match(/^`+/);

@@ -147,8 +142,8 @@ if (!ticks) {

var foundCode = false;
var match;
while (!foundCode && (match = this.match(/`+/m))) {
if (match === ticks) {
var matched;
while (!foundCode && (matched = this.match(/`+/m))) {
if (matched === ticks) {
inlines.push({ t: 'Code', c: this.subject.slice(afterOpenTicks,
this.pos - ticks.length)
.replace(/[ \n]+/g,' ')
.replace(/[ \n]+/g, ' ')
.trim() });

@@ -160,3 +155,3 @@ return true;

this.pos = afterOpenTicks;
inlines.push({ t: 'Str', c: ticks });
inlines.push({ t: 'Text', c: ticks });
return true;

@@ -170,3 +165,3 @@ };

var subj = this.subject,
pos = this.pos;
pos = this.pos;
if (subj.charCodeAt(pos) === C_BACKSLASH) {

@@ -178,6 +173,6 @@ if (subj.charAt(pos + 1) === '\n') {

this.pos = this.pos + 2;
inlines.push({ t: 'Str', c: subj.charAt(pos + 1) });
inlines.push({ t: 'Text', c: subj.charAt(pos + 1) });
} else {
this.pos++;
inlines.push({t: 'Str', c: '\\'});
inlines.push({t: 'Text', c: '\\'});
}

@@ -195,13 +190,13 @@ return true;

if ((m = this.match(/^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/))) { // email autolink
dest = m.slice(1,-1);
dest = m.slice(1, -1);
inlines.push(
{t: 'Link',
label: [{ t: 'Str', c: dest }],
label: [{ t: 'Text', c: dest }],
destination: 'mailto:' + encodeURI(unescape(dest)) });
return true;
} else if ((m = this.match(/^<(?:coap|doi|javascript|aaa|aaas|about|acap|cap|cid|crid|data|dav|dict|dns|file|ftp|geo|go|gopher|h323|http|https|iax|icap|im|imap|info|ipp|iris|iris.beep|iris.xpc|iris.xpcs|iris.lwz|ldap|mailto|mid|msrp|msrps|mtqp|mupdate|news|nfs|ni|nih|nntp|opaquelocktoken|pop|pres|rtsp|service|session|shttp|sieve|sip|sips|sms|snmp|soap.beep|soap.beeps|tag|tel|telnet|tftp|thismessage|tn3270|tip|tv|urn|vemmi|ws|wss|xcon|xcon-userid|xmlrpc.beep|xmlrpc.beeps|xmpp|z39.50r|z39.50s|adiumxtra|afp|afs|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|chrome|chrome-extension|com-eventbrite-attendee|content|cvs|dlna-playsingle|dlna-playcontainer|dtn|dvb|ed2k|facetime|feed|finger|fish|gg|git|gizmoproject|gtalk|hcp|icon|ipn|irc|irc6|ircs|itms|jar|jms|keyparc|lastfm|ldaps|magnet|maps|market|message|mms|ms-help|msnim|mumble|mvn|notes|oid|palm|paparazzi|platform|proxy|psyc|query|res|resource|rmi|rsync|rtmp|secondlife|sftp|sgn|skype|smb|soldat|spotify|ssh|steam|svn|teamspeak|things|udp|unreal|ut2004|ventrilo|view-source|webcal|wtai|wyciwyg|xfire|xri|ymsgr):[^<>\x00-\x20]*>/i))) {
dest = m.slice(1,-1);
dest = m.slice(1, -1);
inlines.push({
t: 'Link',
label: [{ t: 'Str', c: dest }],
label: [{ t: 'Text', c: dest }],
destination: encodeURI(unescape(dest)) });

@@ -231,3 +226,2 @@ return true;

var numdelims = 0;
var first_close_delims = 0;
var char_before, char_after, cc_after;

@@ -251,4 +245,10 @@ var startpos = this.pos;

var can_open = numdelims > 0 && !(/\s/.test(char_after));
var can_close = numdelims > 0 && !(/\s/.test(char_before));
var can_open = numdelims > 0 && !(/\s/.test(char_after)) &&
!(rePunctuation.test(char_after) &&
!(/\s/.test(char_before)) &&
!(rePunctuation.test(char_before)));
var can_close = numdelims > 0 && !(/\s/.test(char_before)) &&
!(rePunctuation.test(char_before) &&
!(/\s/.test(char_after)) &&
!(rePunctuation.test(char_after)));
if (cc === C_UNDERSCORE) {

@@ -273,7 +273,7 @@ can_open = can_open && !((/[a-z0-9]/i).test(char_before));

var Str = function(s) {
return {t: 'Str', c: s};
return {t: 'Text', c: s};
};
// Attempt to parse emphasis or strong emphasis.
var parseEmphasis = function(cc,inlines) {
var parseEmphasis = function(cc, inlines) {

@@ -298,3 +298,4 @@ var res = this.scanDelims(cc);

can_open: res.can_open,
can_close: res.can_close};
can_close: res.can_close,
active: true };
if (this.delimiters.previous !== null) {

@@ -334,2 +335,3 @@ this.delimiters.previous.next = this.delimiters;

var processEmphasis = function(inlines, stack_bottom) {
"use strict";
var opener, closer;

@@ -340,5 +342,4 @@ var opener_inl, closer_inl;

var contents;
var tmp;
var emph;
var i,j;
var i;

@@ -426,3 +427,3 @@ // find first closer above stack_bottom:

// remove all delimiters
while (this.delimiters != stack_bottom) {
while (this.delimiters !== stack_bottom) {
this.removeDelimiter(this.delimiters);

@@ -462,14 +463,6 @@ }

var parseLinkLabel = function() {
var match = this.match(/^\[(?:[^\\\[\]]|\\[\[\]]){0,1000}\]/);
return match === null ? 0 : match.length;
var m = this.match(/^\[(?:[^\\\[\]]|\\[\[\]]){0,1000}\]/);
return m === null ? 0 : m.length;
};
// Parse raw link label, including surrounding [], and return
// inline contents. (Note: this is not a method of InlineParser.)
var parseRawLabel = function(s) {
// note: parse without a refmap; we don't want links to resolve
// in nested brackets!
return new InlineParser().parse(s.substr(1, s.length - 2), {});
};
// Add open bracket to delimiter stack and add a Str to inlines.

@@ -480,2 +473,3 @@ var parseOpenBracket = function(inlines) {

this.pos += 1;
inlines.push(Str("["));

@@ -491,6 +485,8 @@

can_close: false,
index: startpos };
index: startpos,
active: true };
if (this.delimiters.previous !== null) {
this.delimiters.previous.next = this.delimiters;
}
return true;

@@ -518,3 +514,4 @@

can_close: false,
index: startpos + 1 };
index: startpos + 1,
active: true };
if (this.delimiters.previous !== null) {

@@ -541,3 +538,4 @@ this.delimiters.previous.next = this.delimiters;

var i;
var opener, closer_above, tempstack;
var reflabel;
var opener;

@@ -547,4 +545,5 @@ this.pos += 1;

// look through stack of delimiters for a [ or !
// look through stack of delimiters for a [ or ![
opener = this.delimiters;
while (opener !== null) {

@@ -563,2 +562,10 @@ if (opener.cc === C_OPEN_BRACKET || opener.cc === C_BANG) {

if (!opener.active) {
// no matched opener, just return a literal
inlines.push(Str("]"));
// take opener off emphasis stack
this.removeDelimiter(opener);
return true;
}
// If we got here, open is a potential opener

@@ -597,3 +604,3 @@ is_image = opener.cc === C_BANG;

var beforelabel = this.pos;
n = this.parseLinkLabel();
var n = this.parseLinkLabel();
if (n === 0 || n === 2) {

@@ -605,2 +612,6 @@ // empty or missing second label

}
if (n === 0) {
// If shortcut reference link, rewind before spaces we skipped.
this.pos = savepos;
}

@@ -626,16 +637,9 @@ // lookup rawlabel in refmap

// processEmphasis will remove this and later delimiters.
// Now, for a link, we also remove earlier link openers.
// Now, for a link, we also deactivate earlier link openers.
// (no links in links)
if (!is_image) {
opener = this.delimiters;
closer_above = null;
while (opener !== null) {
if (opener.cc === C_OPEN_BRACKET) {
if (closer_above) {
closer_above.previous = opener.previous;
} else {
this.delimiters = opener.previous;
}
} else {
closer_above = opener;
opener.active = false; // deactivate this opener
}

@@ -666,3 +670,3 @@ opener = opener.previous;

if ((m = this.match(reEntityHere))) {
inlines.push({ t: 'Str', c: entityToChar(m) });
inlines.push({ t: 'Text', c: entityToChar(m) });
return true;

@@ -679,3 +683,3 @@ } else {

if ((m = this.match(reMain))) {
inlines.push({ t: 'Str', c: m });
inlines.push({ t: 'Text', c: m });
return true;

@@ -702,19 +706,2 @@ } else {

// Attempt to parse an image. If the opening '!' is not followed
// by a link, return a literal '!'.
var parseImage = function(inlines) {
if (this.match(/^!/)) {
var link = this.parseLink(inlines);
if (link) {
inlines[inlines.length - 1].t = 'Image';
return true;
} else {
inlines.push({ t: 'Str', c: '!' });
return true;
}
} else {
return false;
}
};
// Attempt to parse a link reference, modifying refmap.

@@ -730,3 +717,2 @@ var parseReference = function(s, refmap) {

var startpos = this.pos;
var match;

@@ -785,5 +771,3 @@ // label:

var parseInline = function(inlines) {
var startpos = this.pos;
var origlen = inlines.length;
"use strict";
var c = this.peek();

@@ -830,3 +814,3 @@ if (c === -1) {

this.pos += 1;
inlines.push({t: 'Str', c: fromCodePoint(c)});
inlines.push({t: 'Text', c: fromCodePoint(c)});
}

@@ -852,2 +836,3 @@

function InlineParser(){
"use strict";
return {

@@ -887,1 +872,2 @@ subject: '',

module.exports = InlineParser;
{ "name": "commonmark",
"description": "a strongly specified, highly compatible variant of Markdown",
"version": "0.12.0",
"version": "0.15.0",
"homepage": "http://commonmark.org",

@@ -5,0 +5,0 @@ "keywords":

#!/usr/bin/env node
"use strict";

@@ -16,4 +17,4 @@ var fs = require('fs');

var t = s;
return t.replace(/\t/g,'→')
.replace(/ /g,'␣');
return t.replace(/\t/g, '→')
.replace(/ /g, '␣');
};

@@ -34,3 +35,3 @@

tests.replace(/^\.\n([\s\S]*?)^\.\n([\s\S]*?)^\.$|^#{1,6} *(.*)$/gm,
function(_,markdownSubmatch,htmlSubmatch,sectionSubmatch){
function(_, markdownSubmatch, htmlSubmatch, sectionSubmatch){
if (sectionSubmatch) {

@@ -84,2 +85,1 @@ current_section = sectionSubmatch;

});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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