New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mdast

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

11

History.md
0.9.0 / 2015-03-07
==================
* Update mdast dependency (6b1bd06)
* Update eslint (bd30d2e)
* Update chalk (aea84ed)
* Update browser build (7a8485e)
* Fix link parsing/stringification support (05d25f0)
* Refactor escape, entity, inline code support (e15f43c)
* Fix blockquote, paragraph support (089ca44)
0.8.0 / 2015-02-27

@@ -3,0 +14,0 @@ ==================

25

lib/expressions.js

@@ -14,5 +14,5 @@ /* This file is generated by `script/build-expressions.js` */

'list': /^([ \t]*)((?:[*+-]|\d+\.))((?:[ \t][\s\S]+?)(?:\n+(?=\1?(?:[-*_][ \t]*){3,}(?:\n|$))|\n+(?=[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))|\n{2,}(?![ \t])(?!\1(?:[*+-]|\d+\.)[ \t])|\s*$))/,
'blockquote': /^([ \t]*>[^\n]+(\n(?![ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)*)+/,
'html': /^[ \t]*(?:<!--[\s\S]*?-->[ \t]*(?:\n|\s*$)|<((?!(?: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+(?!:\/|[^\w\s@]*@)\b)[\s\S]+?<\/\1>[ \t]*(?:\n{2,}|\s*$)|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b(?:"[^"]*"|'[^']*'|[^'">])*?>[ \t]*(?:\n{2,}|\s*$))/,
'paragraph': /^(?:(?:[^\n]+\n?(?![ \t]*([-*_])( *\1){2,} *(?=\n|$)|([ \t]*)(#{1,6})([ \t]*)([^\n]*?)[ \t]*#*[ \t]*(?=\n|$)|(\ {0,3})([^\n]+?)[ \t]*\n\ {0,3}(=|-){1,}[ \t]*(?=\n|$)|[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$)|([ \t]*>[^\n]+(\n(?![ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)*)+|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/,
'blockquote': /^(?=[ \t]*>)(?:(?:(?:[ \t]*>[^\n]*\n)*(?:[ \t]*>[^\n]+(?=\n|$))|(?![ \t]*>)(?![ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)(?:\n|$))*(?:[ \t]*>[ \t]*(?:\n[ \t]*>[ \t]*)*)?/,
'html': /^[ \t]*(?:<!--[\s\S]*?-->[ \t]*(?:\n|\s*$)|<((?!(?: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+(?!:\/|[^\w\s@]*@)\b)[\s\S]+?<\/\1>[ \t]*(?:\n{2,}|\s*$)|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b(?:"[^"]*"|'[^']*'|[^'">])*?>[ \t]*(?:\n{2,}|\s*$))/i,
'paragraph': /^(?:(?:[^\n]+\n?(?![ \t]*([-*_])( *\1){2,} *(?=\n|$)|([ \t]*)(#{1,6})([ \t]*)([^\n]*?)[ \t]*#*[ \t]*(?=\n|$)|(\ {0,3})([^\n]+?)[ \t]*\n\ {0,3}(=|-){1,}[ \t]*(?=\n|$)|[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$)|(?=[ \t]*>)(?:(?:(?:[ \t]*>[^\n]*\n)*(?:[ \t]*>[^\n]+(?=\n|$))|(?![ \t]*>)(?![ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)(?:\n|$))*(?:[ \t]*>[ \t]*(?:\n[ \t]*>[ \t]*)*)?|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/,
'escape': /^\\([\\`*{}\[\]()#+\-.!_>])/,

@@ -24,9 +24,7 @@ 'autoLink': /^<([^ >]+(@|:\/)[^ >]+)>/,

'emphasis': /^\b(_)((?:__|[\s\S])+?)_\b|^(\*)((?:\*\*|[\s\S])+?)\*(?!\*)/,
'inlineCode': /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
'inlineCode': /^(`+)((?!`)[\s\S]*?(?:`\s+|[^`]))?(\1)(?!`)/,
'break': /^ {2,}\n(?!\s*$)/,
'text': /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/,
'inside': /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,
'href': /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,
'link': /^(!?\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*)\]\(\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*\)/,
'referenceLink': /^(!?\[)((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]\s*\[([^\]]*)\]/
'link': /^(!?\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*)\]\(\s*(?:(?!<)((?:\((?:\\[\s\S]|[^\)])*?\)|\\[\s\S]|[\s\S])*?)|<([\s\S]*?)>)(?:\s+['"]([\s\S]*?)['"])?\s*\)/,
'referenceLink': /^(!?\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*)\]\s*\[((?:\\[\s\S]|[^\]])*)\]/
},

@@ -39,3 +37,3 @@ 'tables': {

'fences': /^( *)(([`~])\3{2,})[ \t]*([^\s`~]+)?[ \t]*(?:\n([\s\S]*?))??(?:\n\ {0,3}\2\3*[ \t]*(?=\n|$)|$)/,
'paragraph': /^(?:(?:[^\n]+\n?(?![ \t]*([-*_])( *\1){2,} *(?=\n|$)|( *)(([`~])\5{2,})[ \t]*([^\s`~]+)?[ \t]*(?:\n([\s\S]*?))??(?:\n\ {0,3}\4\5*[ \t]*(?=\n|$)|$)|([ \t]*)((?:[*+-]|\d+\.))((?:[ \t][\s\S]+?)(?:\n+(?=\8?(?:[-*_][ \t]*){3,}(?:\n|$))|\n+(?=[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))|\n{2,}(?![ \t])(?!\8(?:[*+-]|\d+\.)[ \t])|\s*$))|([ \t]*)(#{1,6})([ \t]*)([^\n]*?)[ \t]*#*[ \t]*(?=\n|$)|(\ {0,3})([^\n]+?)[ \t]*\n\ {0,3}(=|-){1,}[ \t]*(?=\n|$)|[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$)|([ \t]*>[^\n]+(\n(?![ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)*)+|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/,
'paragraph': /^(?:(?:[^\n]+\n?(?![ \t]*([-*_])( *\1){2,} *(?=\n|$)|( *)(([`~])\5{2,})[ \t]*([^\s`~]+)?[ \t]*(?:\n([\s\S]*?))??(?:\n\ {0,3}\4\5*[ \t]*(?=\n|$)|$)|([ \t]*)((?:[*+-]|\d+\.))((?:[ \t][\s\S]+?)(?:\n+(?=\8?(?:[-*_][ \t]*){3,}(?:\n|$))|\n+(?=[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))|\n{2,}(?![ \t])(?!\8(?:[*+-]|\d+\.)[ \t])|\s*$))|([ \t]*)(#{1,6})([ \t]*)([^\n]*?)[ \t]*#*[ \t]*(?=\n|$)|(\ {0,3})([^\n]+?)[ \t]*\n\ {0,3}(=|-){1,}[ \t]*(?=\n|$)|[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$)|(?=[ \t]*>)(?:(?:(?:[ \t]*>[^\n]*\n)*(?:[ \t]*>[^\n]+(?=\n|$))|(?![ \t]*>)(?![ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)(?:\n|$))*(?:[ \t]*>[ \t]*(?:\n[ \t]*>[ \t]*)*)?|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/,
'escape': /^\\([\\`*{}\[\]()#+\-.!_>~|])/,

@@ -58,7 +56,10 @@ 'url': /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,

'heading': /^([ \t]*)(#{1,6})(?:([ \t]+)([^\n]+?))??(?:[ \t]+#+)?[ \t]*(?=\n|$)/,
'blockquote': /^([ \t]*>[^\n]+(\n(?![ \t]*([-*_])( *\3){2,} *(?=\n|$)|[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)*)+/,
'paragraph': /^(?:(?:[^\n]+\n?(?!\ {0,3}([-*_])( *\1){2,} *(?=\n|$)|(\ {0,3})(#{1,6})(\ {0,3})([^\n]*?)\ {0,3}#*\ {0,3}(?=\n|$)|(\ {0,3}>[^\n]+(\n(?!\ {0,3}\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?\ {0,3}(?=\n|$))[^\n]+)*)+|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/
'link': /^(!?\[)((?:(?:\[(?:\[(?:\\[\s\S]|[^\[\]])*?\]|\\[\s\S]|[^\[\]])*?\])|\\[\s\S]|[^\[\]])*?)\]\(\s*(?:(?!<)((?:\((?:\\[\s\S]|[^\(\)\s])*?\)|\\[\s\S]|[^\(\)\s])*?)|<([^\n]*?)>)(?:\s+(?:\'((?:\\[\s\S]|[^\'])*?)\'|"((?:\\[\s\S]|[^"])*?)"|\(((?:\\[\s\S]|[^\)])*?)\)))?\s*\)/,
'referenceLink': /^(!?\[)((?:(?:\[(?:\[(?:\\[\s\S]|[^\[\]])*?\]|\\[\s\S]|[^\[\]])*?\])|\\[\s\S]|[^\[\]])*?)\]\s*\[((?:\\[\s\S]|[^\[\]])*)\]/,
'paragraph': /^(?:(?:[^\n]+\n?(?!\ {0,3}([-*_])( *\1){2,} *(?=\n|$)|(\ {0,3})(#{1,6})(\ {0,3})([^\n]*?)\ {0,3}#*\ {0,3}(?=\n|$)|(?=\ {0,3}>)(?:(?:(?:\ {0,3}>[^\n]*\n)*(?:\ {0,3}>[^\n]+(?=\n|$))|(?!\ {0,3}>)(?!\ {0,3}\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?\ {0,3}(?=\n|$))[^\n]+)(?:\n|$))*(?:\ {0,3}>\ {0,3}(?:\n\ {0,3}>\ {0,3})*)?|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/,
'blockquote': /^(?=[ \t]*>)(?:(?:(?:[ \t]*>[^\n]*\n)*(?:[ \t]*>[^\n]+(?=\n|$))|(?![ \t]*>)(?![ \t]*([-*_])( *\1){2,} *(?=\n|$)|([ \t]*)((?:[*+-]|\d+\.))((?:[ \t][\s\S]+?)(?:\n+(?=\3?(?:[-*_][ \t]*){3,}(?:\n|$))|\n+(?=[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))|\n{2,}(?![ \t])(?!\3(?:[*+-]|\d+\.)[ \t])|\s*$))|( *)(([`~])\11{2,})[ \t]*([^\s`~]+)?[ \t]*(?:\n([\s\S]*?))??(?:\n\ {0,3}\10\11*[ \t]*(?=\n|$)|$)|((?: {4}|\t)[^\n]*\n?([ \t]*\n)*)+|[ \t]*\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?[ \t]*(?=\n|$))[^\n]+)(?:\n|$))*(?:[ \t]*>[ \t]*(?:\n[ \t]*>[ \t]*)*)?/,
'escape': /^\\(\n|[\\`*{}\[\]()#+\-.!_>"$%&',/:;<=?@^~|])/
},
'commonmarkGFM': {
'paragraph': /^(?:(?:[^\n]+\n?(?!\ {0,3}([-*_])( *\1){2,} *(?=\n|$)|( *)(([`~])\5{2,})\ {0,3}([^\s`~]+)?\ {0,3}(?:\n([\s\S]*?))??(?:\n\ {0,3}\4\5*\ {0,3}(?=\n|$)|$)|(\ {0,3})((?:[*+-]|\d+\.))((?:[ \t][\s\S]+?)(?:\n+(?=\8?(?:[-*_]\ {0,3}){3,}(?:\n|$))|\n+(?=\ {0,3}\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?\ {0,3}(?=\n|$))|\n{2,}(?![ \t])(?!\8(?:[*+-]|\d+\.)[ \t])|\s*$))|(\ {0,3})(#{1,6})(\ {0,3})([^\n]*?)\ {0,3}#*\ {0,3}(?=\n|$)|(\ {0,3}>[^\n]+(\n(?!\ {0,3}\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?\ {0,3}(?=\n|$))[^\n]+)*)+|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/
'paragraph': /^(?:(?:[^\n]+\n?(?!\ {0,3}([-*_])( *\1){2,} *(?=\n|$)|( *)(([`~])\5{2,})\ {0,3}([^\s`~]+)?\ {0,3}(?:\n([\s\S]*?))??(?:\n\ {0,3}\4\5*\ {0,3}(?=\n|$)|$)|(\ {0,3})((?:[*+-]|\d+\.))((?:[ \t][\s\S]+?)(?:\n+(?=\8?(?:[-*_]\ {0,3}){3,}(?:\n|$))|\n+(?=\ {0,3}\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?\ {0,3}(?=\n|$))|\n{2,}(?![ \t])(?!\8(?:[*+-]|\d+\.)[ \t])|\s*$))|(\ {0,3})(#{1,6})(\ {0,3})([^\n]*?)\ {0,3}#*\ {0,3}(?=\n|$)|(?=\ {0,3}>)(?:(?:(?:\ {0,3}>[^\n]*\n)*(?:\ {0,3}>[^\n]+(?=\n|$))|(?!\ {0,3}>)(?!\ {0,3}\[((?:[^\\](?:\\|\\(?:\\{2})+)\]|[^\]])+)\]:[ \t\n]*(<[^>\[\]]+>|[^\s\[\]]+)(?:[ \t\n]+['"(]([^\n]+)['")])?\ {0,3}(?=\n|$))[^\n]+)(?:\n|$))*(?:\ {0,3}>\ {0,3}(?:\n\ {0,3}>\ {0,3})*)?|<(?!(?: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+(?!:\/|[^\w\s@]*@)\b))+)/
},

@@ -65,0 +66,0 @@ 'breaks': {

@@ -19,6 +19,6 @@ 'use strict';

var trim = utilities.trim;
var trimRight = utilities.trimRight;
var trimRightLines = utilities.trimRightLines;
var clean = utilities.clean;
var validate = utilities.validate;
var normalize = utilities.normalizeReference;
var has = Object.prototype.hasOwnProperty;

@@ -70,2 +70,52 @@

/**
* Wrapper arround he’s `decode` function.
*
* @param {string} value
* @return {string}
*/
function decode(value) {
return he.decode(value);
}
/**
* Factory to de-escape a value, based on an expression
* at `key` in `scope`.
*
* @param {Object} scope
* @param {string} key
* @return {function(string): string}
*/
function descapeFactory(scope, key) {
var globalExpression;
var expression;
/**
* Private method to get a global expression
* from the expression at `key` in `scope`.
*
* @return {RegExp}
*/
function generate() {
if (scope[key] !== globalExpression) {
globalExpression = scope[key];
expression = new RegExp(
scope[key].source.replace(CARET, EMPTY), 'g'
);
}
return expression;
}
/**
* De-escape a string.
*
* @param {string} value
* @return {string}
*/
return function (value) {
return value.replace(generate(), '$1');
};
}
/*

@@ -94,3 +144,2 @@ * Tab size.

var EXPRESSION_HTML_LINK_CLOSE = /^<\/a>/i;
var EXPRESSION_WHITE_SPACES = /\s+/g;
var EXPRESSION_LOOSE_LIST_ITEM = /\n\n(?!\s*$)/;

@@ -318,2 +367,6 @@

MERGEABLE_NODES.blockquote = function (prev, token) {
if (this.options.commonmark) {
return token;
}
prev.children = prev.children.concat(token.children);

@@ -365,5 +418,3 @@

* is exdented, we first have to ensure at least
* those spaces are available. Additionally, to work
* around `removeIndentation` from removing to much
* white space, we add a simple line
* those spaces are available.
*/

@@ -431,2 +482,4 @@

$0 = trimRightLines($0);
eat($0)(this.renderBlockquote($0, now));

@@ -531,3 +584,3 @@ }

function tokenizeLinkDefinition(eat, $0, $1, $2, $3) {
var identifier = $1.toLowerCase();
var identifier = normalize($1);
var add = eat($0);

@@ -541,3 +594,3 @@

this.links[identifier] = add({}, this.renderLink(
true, $2, null, $3
true, this.descape($2), null, $3
));

@@ -764,4 +817,10 @@ }

function tokenizeParagraph(eat, $0) {
$0 = trimRight($0);
if (trim($0) === EMPTY) {
eat($0);
return;
}
$0 = trimRightLines($0);
eat($0)(this.renderBlock(PARAGRAPH, $0));

@@ -792,3 +851,3 @@ }

'type': CODE,
'lang': language || null,
'lang': language ? decode(this.descape(language)) : null,
'value': trimRightLines(value || EMPTY)

@@ -1068,3 +1127,4 @@ };

function renderLink(isLink, href, text, title, position) {
var exitLink = this.enterLink();
var self = this;
var exitLink = self.enterLink();
var token;

@@ -1074,11 +1134,18 @@

'type': isLink ? LINK : IMAGE,
'title': title || null
'title': title ? decode(self.descape(title)) : null
};
/*
* The `href` should not always be descaped, functions
* that invoke `renderLink` should handle that.
*/
href = decode(href);
if (isLink) {
token.href = href;
token.children = this.tokenizeInline(text, position);
token.children = self.tokenizeInline(text, position);
} else {
token.src = href;
token.alt = text || null;
token.alt = text ? decode(self.descape(text)) : null;
}

@@ -1139,2 +1206,3 @@

function tokenizeAutoLink(eat, $0, $1, $2) {
var self = this;
var href = $1;

@@ -1144,5 +1212,9 @@ var text = $1;

var offset = 1;
var tokenize;
if ($2 === AT_SIGN) {
if (text.substr(0, MAILTO_PROTOCOL.length) !== MAILTO_PROTOCOL) {
if (
text.substr(0, MAILTO_PROTOCOL.length).toLowerCase() !==
MAILTO_PROTOCOL
) {
href = MAILTO_PROTOCOL + text;

@@ -1157,3 +1229,12 @@ } else {

eat($0)(this.renderLink(true, href, text, null, now));
/*
* Temporarily remove support for escapes in autlinks.
*/
tokenize = self.inlineTokenizers.escape;
self.inlineTokenizers.escape = null;
eat($0)(self.renderLink(true, href, text, null, now));
self.inlineTokenizers.escape = tokenize;
}

@@ -1202,8 +1283,14 @@

* @param {string} $0 - Whole link.
* @param {string} $1 - Content.
* @param {string} $2 - URL.
* @param {string?} $3 - Title.
* @param {string} $1 - Prefix.
* @param {string} $2 - Text.
* @param {string?} $3 - URL wrapped in angle braces.
* @param {string?} $4 - Literal URL.
* @param {string?} $5 - Title wrapped in single or double quotes.
* @param {string?} $6 - Title wrapped in double quotes.
* @param {string?} $7 - Title wrapped in parentheses.
*/
function tokenizeLink(eat, $0, $1, $2, $3, $4) {
function tokenizeLink(eat, $0, $1, $2, $3, $4, $5, $6, $7) {
var isLink = $0.charAt(0) !== EXCLAMATION_MARK;
var href = $4 || $3 || '';
var title = $7 || $6 || $5;
var now;

@@ -1216,3 +1303,3 @@

eat($0)(this.renderLink(isLink, $3, $2, $4, now));
eat($0)(this.renderLink(isLink, this.descape(href), $2, title, now));
}

@@ -1234,4 +1321,5 @@ }

var self = this;
var text = ($3 || $2).replace(EXPRESSION_WHITE_SPACES, SPACE);
var url = self.links[text.toLowerCase()];
var text = $3 || $2;
var identifier = normalize(text);
var url = self.links[identifier];
var token;

@@ -1242,4 +1330,4 @@ var now;

self.options.footnotes &&
text.charAt(0) === CARET &&
self.footnotes[text.substr(1)]
identifier.charAt(0) === CARET &&
self.footnotes[identifier.substr(1)]
) {

@@ -1253,7 +1341,7 @@ /*

eat($0)(self.renderFootnote(text.substr(1)));
eat($0)(self.renderFootnote(identifier.substr(1)));
} else if (!url || !url.href) {
if (
self.options.footnotes &&
text.charAt(0) === CARET &&
identifier.charAt(0) === CARET &&
text.indexOf(SPACE) > -1

@@ -1297,3 +1385,4 @@ ) {

eat($0)(self.renderLink(
$0.charAt(0) !== EXCLAMATION_MARK, url.href, $2, url.title, now
$0.charAt(0) !== EXCLAMATION_MARK, self.descape(url.href),
$2, url.title, now
));

@@ -1376,7 +1465,7 @@ }

* @param {string} $0 - Whole code.
* @param {string} $1 - Delimiter.
* @param {string} $1 - Initial markers.
* @param {string} $2 - Content.
*/
function tokenizeInlineCode(eat, $0, $1, $2) {
eat($0)(this.renderRaw(INLINE_CODE, trimRight($2)));
eat($0)(this.renderRaw(INLINE_CODE, trim($2 || '')));
}

@@ -1472,2 +1561,4 @@

}
self.descape = descapeFactory(rules, 'escape');
}

@@ -1764,3 +1855,3 @@

if (type === INLINE && token.type === TEXT) {
token.value = he.decode(token.value);
token.value = decode(token.value);
}

@@ -1773,4 +1864,8 @@

) {
token = MERGEABLE_NODES[token.type](prev, token, type);
} else {
token = MERGEABLE_NODES[token.type].call(
self, prev, token, type
);
}
if (token !== prev) {
children.push(token);

@@ -1837,2 +1932,3 @@ }

match = rules[name] &&
method &&
(!method.onlyAtStart || self.atStart) &&

@@ -1839,0 +1935,0 @@ (!method.onlyAtTop || self.atTop) &&

@@ -19,2 +19,3 @@ 'use strict';

var validate = utilities.validate;
var count = utilities.countCharacter;

@@ -29,2 +30,4 @@ /*

var EXPRESSIONS_WHITE_SPACE = /\s/;
/*

@@ -34,3 +37,4 @@ * Characters.

var ANGLE_BRACKET = '>';
var ANGLE_BRACKET_CLOSE = '>';
var ANGLE_BRACKET_OPEN = '<';
var ASTERISK = '*';

@@ -51,2 +55,3 @@ var CARET = '^';

var QUOTE_DOUBLE = '"';
var QUOTE_SINGLE = '\'';
var SPACE = ' ';

@@ -115,2 +120,37 @@ var SQUARE_BRACKET_OPEN = '[';

/**
* Checks if `url` needs to be enclosed by angle brackets.
*
* @param {string} uri
* @return {boolean}
*/
function needsAngleBraceEnclosure(uri) {
return !uri.length ||
EXPRESSIONS_WHITE_SPACE.test(uri) ||
count(uri, PARENTHESIS_OPEN) !== count(uri, PARENTHESIS_CLOSE);
}
/**
* There is currently no way to support nested delimiters
* across Markdown.pl, CommonMark, and GitHub (RedCarpet).
* The following supports Markdown.pl, and GitHub.
* CommonMark is not supported when mixing double- and
* single quotes inside a title.
*
* @see https://github.com/vmg/redcarpet/issues/473
* @see https://github.com/jgm/CommonMark/issues/308
*
* @param {string} title
* @return {string}
*/
function encloseTitle(title) {
var delimiter = QUOTE_DOUBLE;
if (title.indexOf(QUOTE_DOUBLE) !== -1) {
delimiter = QUOTE_SINGLE;
}
return delimiter + title + delimiter;
}
/**
* Helper to get the keys in an object.

@@ -144,3 +184,3 @@ *

var length = value.length;
var currentCount;
var currentCount = 0;
var currentCharacter;

@@ -464,4 +504,4 @@

compilerPrototype.blockquote = function (token, parent, level) {
return ANGLE_BRACKET + SPACE + this.visitAll(token, level)
.join(BREAK).split(LINE).join(LINE + ANGLE_BRACKET + SPACE);
return ANGLE_BRACKET_CLOSE + SPACE + this.visitAll(token, level)
.join(BREAK).split(LINE).join(LINE + ANGLE_BRACKET_CLOSE + SPACE);
};

@@ -482,2 +522,6 @@

if (!self.options.referenceLinks && needsAngleBraceEnclosure(link)) {
link = ANGLE_BRACKET_OPEN + link + ANGLE_BRACKET_CLOSE;
}
value = SQUARE_BRACKET_OPEN +

@@ -487,3 +531,3 @@ self.visitAll(token, level).join(EMPTY) + SQUARE_BRACKET_CLOSE;

if (token.title) {
link += SPACE + QUOTE_DOUBLE + token.title + QUOTE_DOUBLE;
link += SPACE + encloseTitle(token.title);
}

@@ -696,11 +740,16 @@

compilerPrototype.image = function (token) {
var source = token.src;
var value;
if (needsAngleBraceEnclosure(source)) {
source = ANGLE_BRACKET_OPEN + source + ANGLE_BRACKET_CLOSE;
}
value = EXCLAMATION_MARK + SQUARE_BRACKET_OPEN + (token.alt || EMPTY) +
SQUARE_BRACKET_CLOSE;
value += PARENTHESIS_OPEN + token.src;
value += PARENTHESIS_OPEN + source;
if (token.title) {
value += SPACE + QUOTE_DOUBLE + token.title + QUOTE_DOUBLE;
value += SPACE + encloseTitle(token.title);
}

@@ -707,0 +756,0 @@

@@ -18,3 +18,3 @@ 'use strict';

var EXPRESSION_SYMBOL_FOR_NEW_LINE = /\u2424/g;
var EXPRESSION_NO_BREAK_SPACE = /\u00a0/g;
var WHITE_SPACE_COLLAPSABLE = /[ \t\n]+/g;

@@ -165,2 +165,12 @@ /**

/**
* Collapse white space.
*
* @param {string} value
* @return {string}
*/
function collapse(value) {
return String(value).replace(WHITE_SPACE_COLLAPSABLE, ' ');
}
/**
* Clean a string in preperation of parsing.

@@ -174,3 +184,2 @@ *

.replace(EXPRESSION_LINE_BREAKS, '\n')
.replace(EXPRESSION_NO_BREAK_SPACE, ' ')
.replace(EXPRESSION_SYMBOL_FOR_NEW_LINE, '\n');

@@ -202,20 +211,35 @@ }

/*
* Expose `repeat`.
/**
* Normalize an reference identifier. Collapses
* multiple white space characters into a single space,
* and removes casing.
*
* @param {string} value
* @return {string}
*/
function normalizeReference(value) {
return collapse(value).toLowerCase();
}
exports.repeat = repeat;
/*
* Expose `copy`.
/**
* Count how many characters `character` occur in `value`.
*
* @param {string} value
* @param {string} character
* @return {number}
*/
function countCharacter(value, character) {
var index = -1;
var length = value.length;
var count = 0;
exports.copy = copy;
while (++index < length) {
if (value.charAt(index) === character) {
count++;
}
}
/*
* Expose `raise`.
*/
return count;
}
exports.raise = raise;
/*

@@ -232,3 +256,3 @@ * Expose `validate`.

/*
* Expose `trim` methods.
* Expose string methods.
*/

@@ -240,7 +264,8 @@

exports.trimRightLines = trimRightLines;
/*
* Expose `clean`.
*/
exports.collapse = collapse;
exports.normalizeReference = normalizeReference;
exports.clean = clean;
exports.raise = raise;
exports.copy = copy;
exports.repeat = repeat;
exports.countCharacter = countCharacter;
{
"name": "mdast",
"version": "0.8.0",
"version": "0.9.0",
"description": "Speedy Markdown parser/stringifier for multipurpose analysis",

@@ -42,5 +42,5 @@ "license": "MIT",

"browserify": "^9.0.0",
"chalk": "^0.5.0",
"chalk": "^1.0.0",
"diff": "^1.0.0",
"eslint": "^0.14.0",
"eslint": "^0.15.0",
"esmangle": "^1.0.0",

@@ -52,3 +52,3 @@ "istanbul": "^0.3.0",

"matcha": "^0.6.0",
"mdast": "^0.5.0",
"mdast": "^0.8.0",
"mdast-usage": "^0.1.0",

@@ -55,0 +55,0 @@ "mocha": "^2.0.0"

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