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.30.0 to 0.31.0

149

lib/blocks.js

@@ -21,3 +21,3 @@ "use strict";

/^<[?]/,
/^<![A-Z]/,
/^<![A-Za-z]/,
/^<!\[CDATA\[/,

@@ -51,3 +51,3 @@ /^<[/]?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|[/]?[>]|$)/i,

var reClosingCodeFence = /^(?:`{3,}|~{3,})(?= *$)/;
var reClosingCodeFence = /^(?:`{3,}|~{3,})(?=[ \t]*$)/;

@@ -79,19 +79,6 @@ var reSetextHeadingLine = /^(?:=+|-+)[ \t]*$/;

// Returns true if block ends with a blank line, descending if needed
// into lists and sublists.
// Returns true if block ends with a blank line.
var endsWithBlankLine = function(block) {
while (block) {
if (block._lastLineBlank) {
return true;
}
var t = block.type;
if (!block._lastLineChecked && (t === "list" || t === "item")) {
block._lastLineChecked = true;
block = block._lastChild;
} else {
block._lastLineChecked = true;
break;
}
}
return false;
return block.next &&
block.sourcepos[1][0] !== block.next.sourcepos[0][0] - 1;
};

@@ -227,2 +214,46 @@

// Remove link reference definitions from given tree.
var removeLinkReferenceDefinitions = function(parser, tree) {
var event, node;
var walker = tree.walker();
var emptyNodes = [];
while ((event = walker.next())) {
node = event.node;
if (event.entering && node.type === "paragraph") {
var pos;
var hasReferenceDefs = false;
// Try parsing the beginning as link reference definitions;
// Note that link reference definitions must be the beginning of a
// paragraph node since link reference definitions cannot interrupt
// paragraphs.
while (
peek(node._string_content, 0) === C_OPEN_BRACKET &&
(pos = parser.inlineParser.parseReference(
node._string_content,
parser.refmap
))
) {
const removedText = node._string_content.slice(0, pos);
node._string_content = node._string_content.slice(pos);
hasReferenceDefs = true;
const lines = removedText.split("\n");
// -1 for final newline.
node.sourcepos[0][0] += lines.length - 1;
}
if (hasReferenceDefs && isBlank(node._string_content)) {
emptyNodes.push(node);
}
}
}
for (node of emptyNodes) {
node.unlink();
}
};
// 'finalize' is run when the block is closed.

@@ -238,3 +269,4 @@ // 'continue' is run to check whether the block is continuing

},
finalize: function() {
finalize: function(parser, block) {
removeLinkReferenceDefinitions(parser, block);
return;

@@ -255,3 +287,3 @@ },

// check for non-final list item ending with blank line:
if (endsWithBlankLine(item) && item._next) {
if (item._next && endsWithBlankLine(item)) {
block._listData.tight = false;

@@ -265,4 +297,4 @@ break;

if (
endsWithBlankLine(subitem) &&
(item._next || subitem._next)
subitem._next &&
endsWithBlankLine(subitem)
) {

@@ -276,2 +308,3 @@ block._listData.tight = false;

}
block.sourcepos[1] = block._lastChild.sourcepos[1];
},

@@ -331,3 +364,12 @@ canContain: function(t) {

},
finalize: function() {
finalize: function(parser, block) {
if (block._lastChild) {
block.sourcepos[1] = block._lastChild.sourcepos[1];
} else {
// Empty list item
block.sourcepos[1][0] = block.sourcepos[0][0];
block.sourcepos[1][1] =
block._listData.markerOffset + block._listData.padding;
}
return;

@@ -414,6 +456,13 @@ },

// indented
block._literal = block._string_content.replace(
/(\n *)+$/,
"\n"
);
var lines = block._string_content.split("\n");
// Note that indented code block cannot be empty, so
// lines.length cannot be zero.
while (/^[ \t]*$/.test(lines[lines.length - 1])) {
lines.pop();
}
block._literal = lines.join("\n") + "\n";
block.sourcepos[1][0] =
block.sourcepos[0][0] + lines.length - 1;
block.sourcepos[1][1] =
block.sourcepos[0][1] + lines[lines.length - 1].length - 1;
}

@@ -436,3 +485,3 @@ block._string_content = null; // allow GC

finalize: function(parser, block) {
block._literal = block._string_content.replace(/(\n *)+$/, "");
block._literal = block._string_content.replace(/\n$/, '');
block._string_content = null; // allow GC

@@ -449,20 +498,4 @@ },

},
finalize: function(parser, block) {
var pos;
var hasReferenceDefs = false;
// try parsing the beginning as link reference definitions:
while (
peek(block._string_content, 0) === C_OPEN_BRACKET &&
(pos = parser.inlineParser.parseReference(
block._string_content,
parser.refmap
))
) {
block._string_content = block._string_content.slice(pos);
hasReferenceDefs = true;
}
if (hasReferenceDefs && isBlank(block._string_content)) {
block.unlink();
}
finalize: function() {
return;
},

@@ -850,29 +883,5 @@ canContain: function() {

this.closeUnmatchedBlocks();
if (this.blank && container.lastChild) {
container.lastChild._lastLineBlank = true;
}
t = container.type;
// Block quote lines are never blank as they start with >
// and we don't count blanks in fenced code for purposes of tight/loose
// lists or breaking out of lists. We also don't set _lastLineBlank
// on an empty list item, or if we just closed a fenced block.
var lastLineBlank =
this.blank &&
!(
t === "block_quote" ||
(t === "code_block" && container._isFenced) ||
(t === "item" &&
!container._firstChild &&
container.sourcepos[0][0] === this.lineNumber)
);
// propagate lastLineBlank up through parents:
var cont = container;
while (cont) {
cont._lastLineBlank = lastLineBlank;
cont = cont._parent;
}
if (this.blocks[t].acceptsLines) {

@@ -879,0 +888,0 @@ this.addLine();

"use strict";
import encode from "mdurl/encode.js";
import { decodeHTML } from "entities";
import { decodeHTMLStrict } from "entities";

@@ -27,5 +27,5 @@ var C_BACKSLASH = 92;

var CLOSETAG = "</" + TAGNAME + "\\s*[>]";
var HTMLCOMMENT = "<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->";
var HTMLCOMMENT = "<!-->|<!--->|<!--(?:[^-]|-[^-]|--[^>])*-->"
var PROCESSINGINSTRUCTION = "[<][?][\\s\\S]*?[?][>]";
var DECLARATION = "<![A-Z]+" + "\\s+[^>]*>";
var DECLARATION = "<![A-Z]+" + "[^>]*>";
var CDATA = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";

@@ -62,3 +62,3 @@ var HTMLTAG =

} else {
return decodeHTML(s);
return decodeHTMLStrict(s);
}

@@ -65,0 +65,0 @@ };

"use strict";
// commonmark.js - CommomMark in JavaScript
// commonmark.js - CommonMark in JavaScript
// Copyright (C) 2014 John MacFarlane

@@ -5,0 +5,0 @@ // License: BSD3.

@@ -6,3 +6,3 @@ "use strict";

import fromCodePoint from "./from-code-point.js";
import { decodeHTML } from "entities";
import { decodeHTMLStrict } from "entities";
import "string.prototype.repeat"; // Polyfill for String.prototype.repeat

@@ -40,4 +40,3 @@

var rePunctuation = new RegExp(
/^[!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/
);
/^[!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~\p{P}\p{S}]/u);

@@ -47,11 +46,14 @@ var reLinkTitle = new RegExp(

ESCAPED_CHAR +
'|[^"\\x00])*"' +
'|\\\\[^\\\\]' +
'|[^\\\\"\\x00])*"' +
"|" +
"'(" +
ESCAPED_CHAR +
"|[^'\\x00])*'" +
'|\\\\[^\\\\]' +
"|[^\\\\'\\x00])*'" +
"|" +
"\\((" +
ESCAPED_CHAR +
"|[^()\\x00])*\\))"
'|\\\\[^\\\\]' +
"|[^\\\\()\\x00])*\\))"
);

@@ -107,3 +109,3 @@

.trim()
.replace(/[ \t\r\n]+/, " ")
.replace(/[ \t\r\n]+/g, " ")
.toLowerCase()

@@ -386,3 +388,3 @@ .toUpperCase();

for (var i = 0; i < 8; i++) {
for (var i = 0; i < 14; i++) {
openers_bottom[i] = stack_bottom;

@@ -412,6 +414,7 @@ }

case C_UNDERSCORE:
openers_bottom_index = 2;
openers_bottom_index = 2 + (closer.can_open ? 3 : 0)
+ (closer.origdelims % 3);
break;
case C_ASTERISK:
openers_bottom_index = 3 + (closer.can_open ? 3 : 0)
openers_bottom_index = 8 + (closer.can_open ? 3 : 0)
+ (closer.origdelims % 3);

@@ -529,3 +532,3 @@ break;

// chop off quotes from title and unescape:
return unescapeString(title.substr(1, title.length - 2));
return unescapeString(title.slice(1, -1));
}

@@ -577,7 +580,7 @@ };

}
res = this.subject.substr(savepos, this.pos - savepos);
res = this.subject.slice(savepos, this.pos);
return normalizeURI(unescapeString(res));
} else {
// chop off surrounding <..>:
return normalizeURI(unescapeString(res.substr(1, res.length - 2)));
return normalizeURI(unescapeString(res.slice(1, -1)));
}

@@ -780,3 +783,3 @@ };

if ((m = this.match(reEntityHere))) {
block.appendChild(text(decodeHTML(m)));
block.appendChild(text(decodeHTMLStrict(m)));
return true;

@@ -868,3 +871,3 @@ } else {

} else {
rawlabel = this.subject.substr(0, matchChars);
rawlabel = this.subject.slice(0, matchChars);
}

@@ -871,0 +874,0 @@

@@ -77,4 +77,2 @@ "use strict";

this._sourcepos = sourcepos;
this._lastLineBlank = false;
this._lastLineChecked = false;
this._open = true;

@@ -81,0 +79,0 @@ this._string_content = null;

@@ -147,3 +147,7 @@ "use strict";

if (info_words.length > 0 && info_words[0].length > 0) {
attrs.push(["class", "language-" + this.esc(info_words[0])]);
var cls = this.esc(info_words[0]);
if (!/^language-/.exec(cls)) {
cls = "language-" + cls;
}
attrs.push(["class", cls]);
}

@@ -150,0 +154,0 @@ this.cr();

{
"name": "commonmark",
"description": "a strongly specified, highly compatible variant of Markdown",
"version": "0.30.0",
"version": "0.31.0",
"homepage": "https://commonmark.org",

@@ -38,6 +38,6 @@ "keywords": [

"dependencies": {
"entities": "~2.0",
"entities": "~3.0.1",
"mdurl": "~1.0.1",
"minimist": ">=1.2.2",
"string.prototype.repeat": "^0.2.0"
"minimist": "~1.2.5",
"string.prototype.repeat": "^1.0.0"
},

@@ -54,18 +54,18 @@ "directories": {

"@rollup/plugin-node-resolve": "^7.0.0",
"acorn": ">=5.7.4",
"acorn": ">=8.7.0",
"benchmark": "^2.1.4",
"bower": "^1.8.8",
"bower": "^1.8.13",
"cached-path-relative": "^1.0.2",
"eslint": "^7.4.0",
"http-server": "^0.12.3",
"eslint": "^8.6.0",
"http-server": "^14.1.0",
"lodash": "^4.17.21",
"markdown-it": "^12.0",
"marked": "^2.1",
"markdown-it": ">= 12.3",
"marked": ">=4.0.10",
"mem": ">=4.0.0",
"rollup": "^1.29.0",
"rollup-plugin-uglify": "^6.0.4",
"serialize-javascript": "^6.0.0",
"showdown": "^1.9.1",
"uglify-js": "^3.4.0",
"serialize-javascript": ">=3.1.0"
"uglify-js": "^3.14.5"
}
}

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

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