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.3.0 to 0.4.0

lib/expressions.js

4

cli.js

@@ -224,3 +224,2 @@ #!/usr/bin/env node

console.log(' - `reference-links` (boolean, default: false)');
console.log(' - `reference-footnotes` (boolean, default: true)');
console.log(' - `fences` (boolean, default: false)');

@@ -266,6 +265,7 @@ console.log(' - `bullet` ("-", "*", or "+", default: "-")');

function run(value) {
var doc;
debug('Using options `%j`', program.setting);
try {
var doc = parser.parse(value, program.setting);
doc = parser.parse(value, program.setting);
} catch (exception) {

@@ -272,0 +272,0 @@ fail(exception);

0.4.0 / 2015-02-15
==================
* Refactor module to use more constants instead of literal strings
* Remove ensured new line at end of file
* Refactor istanbul ignore, error message
* Remove support for `referenceFootnotes: false`
* Add `lib/expressions.js` with precompiled expressions
* Refactor module
* Add support for escaped pipes in table cells
* Fix bug in node@0.10 re invalid error exit code
0.3.0 / 2015-02-08

@@ -26,3 +38,2 @@ ==================

0.2.0 / 2015-02-02

@@ -29,0 +40,0 @@ ==================

@@ -7,6 +7,4 @@ 'use strict';

var Ware;
var Ware = require('ware');
Ware = require('ware');
/*

@@ -16,8 +14,5 @@ * Components.

var parse,
stringify;
var parse = require('./lib/parse.js');
var stringify = require('./lib/stringify.js');
parse = require('./lib/parse.js');
stringify = require('./lib/stringify.js');
/**

@@ -54,6 +49,4 @@ * Throws if passed an exception.

function runParse(_, options) {
var node;
var node = parse.apply(parse, arguments);
node = parse.apply(parse, arguments);
this.ware.run(node, options, fail);

@@ -70,6 +63,4 @@

function use(plugin) {
var self;
var self = this;
self = this;
if (!(self instanceof MDAST)) {

@@ -76,0 +67,0 @@ self = new MDAST();

@@ -7,8 +7,6 @@ 'use strict';

var he,
utilities;
var he = require('he');
var utilities = require('./utilities.js');
var expressions = require('./expressions.js');
he = require('he');
utilities = require('./utilities.js');
/*

@@ -18,16 +16,9 @@ * Cached methods.

var copy,
raise,
trimRight,
trimRightLines,
clean,
validate;
var copy = utilities.copy;
var raise = utilities.raise;
var trimRight = utilities.trimRight;
var trimRightLines = utilities.trimRightLines;
var clean = utilities.clean;
var validate = utilities.validate;
copy = utilities.copy;
raise = utilities.raise;
trimRight = utilities.trimRight;
trimRightLines = utilities.trimRightLines;
clean = utilities.clean;
validate = utilities.validate;
/*

@@ -37,18 +28,39 @@ * Constants.

var MAILTO_PROTOCOL,
EQUALS,
AT_SIGN,
EXCLAMATION_MARK,
SPACE,
NEW_LINE,
CARET;
var AT_SIGN = '@';
var CARET = '^';
var EQUALS = '=';
var EXCLAMATION_MARK = '!';
var MAILTO_PROTOCOL = 'mailto:';
var NEW_LINE = '\n';
var SLASH = '\\';
var SPACE = ' ';
var EMPTY = '';
var BLOCK = 'block';
var INLINE = 'inline';
var HORIZONTAL_RULE = 'horizontalRule';
var HTML = 'html';
var YAML = 'yaml';
var TABLE = 'table';
var TABLE_CELL = 'tableCell';
var TABLE_HEADER = 'tableHeader';
var TABLE_ROW = 'tableRow';
var PARAGRAPH = 'paragraph';
var TEXT = 'text';
var CODE = 'code';
var LIST = 'list';
var LIST_ITEM = 'listItem';
var FOOTNOTE_DEFINITION = 'footnoteDefinition';
var HEADING = 'heading';
var BLOCKQUOTE = 'blockquote';
var LINK = 'link';
var IMAGE = 'image';
var FOOTNOTE = 'footnote';
var ESCAPE = 'escape';
var STRONG = 'strong';
var EMPHASIS = 'emphasis';
var DELETE = 'delete';
var INLINE_CODE = 'inlineCode';
var BREAK = 'break';
var ROOT = 'root';
MAILTO_PROTOCOL = 'mailto:';
EQUALS = '=';
AT_SIGN = '@';
EXCLAMATION_MARK = '!';
SPACE = ' ';
NEW_LINE = '\n';
CARET = '^';
/*

@@ -58,56 +70,20 @@ * Expressions.

var EXPRESSION_START,
EXPRESSION_INITIAL_SPACES,
EXPRESSION_RIGHT_ALIGNMENT,
EXPRESSION_CENTER_ALIGNMENT,
EXPRESSION_SPACES_ONLY_LINE,
EXPRESSION_TABLE_FENCE,
EXPRESSION_TABLE_BORDER,
EXPRESSION_BLOCK_QUOTE,
EXPRESSION_BULLET,
EXPRESSION_INITIAL_INDENT,
EXPRESSION_LOOSE_LIST_ITEM,
EXPRESSION_INITIAL_TAB,
EXPRESSION_HTML_LINK_OPEN,
EXPRESSION_HTML_LINK_CLOSE,
EXPRESSION_WHITE_SPACES;
EXPRESSION_START = /(^|[^\[])\^/g;
EXPRESSION_INITIAL_SPACES = /^ +/;
EXPRESSION_RIGHT_ALIGNMENT = /^ *-+: *$/;
EXPRESSION_CENTER_ALIGNMENT = /^ *:-+: *$/;
EXPRESSION_SPACES_ONLY_LINE = /^ +$/gm;
EXPRESSION_TABLE_FENCE = /^ *|\| *$/g;
var EXPRESSION_INITIAL_SPACES = /^ +/;
var EXPRESSION_RIGHT_ALIGNMENT = /^ *-+: *$/;
var EXPRESSION_CENTER_ALIGNMENT = /^ *:-+: *$/;
var EXPRESSION_SPACES_ONLY_LINE = /^ +$/gm;
var EXPRESSION_TABLE_FENCE = /^ *|\| *$/g;
var EXPRESSION_TABLE_INITIAL = /^ *\| */g;
var EXPRESSION_TABLE_CONTENT = /([\s\S]+?)( *\| *\n?|\n?$)/g;
var EXPRESSION_TABLE_BORDER = / *\| */;
var EXPRESSION_BLOCK_QUOTE = /^ *> ?/gm;
var EXPRESSION_BULLET = /^ *([*+-]|\d+\.) +/;
var EXPRESSION_INITIAL_INDENT = /^ {1,4}/gm;
var EXPRESSION_INITIAL_TAB = /^( {4})?/gm;
var EXPRESSION_HTML_LINK_OPEN = /^<a /i;
var EXPRESSION_HTML_LINK_CLOSE = /^<\/a>/i;
var EXPRESSION_WHITE_SPACES = /\s+/g;
var EXPRESSION_LOOSE_LIST_ITEM = /\n\n(?!\s*$)/;
EXPRESSION_TABLE_BORDER = / *\| */;
EXPRESSION_BLOCK_QUOTE = /^ *> ?/gm;
EXPRESSION_BULLET = /^ *([*+-]|\d+\.) +/;
EXPRESSION_INITIAL_INDENT = /^ {1,4}/gm;
EXPRESSION_INITIAL_TAB = /^( {4})?/gm;
EXPRESSION_HTML_LINK_OPEN = /^<a /i;
EXPRESSION_HTML_LINK_CLOSE = /^<\/a>/i;
EXPRESSION_WHITE_SPACES = /\s+/g;
/*
* Use
* /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
* for discount behaviour.
*/
EXPRESSION_LOOSE_LIST_ITEM = /\n\n(?!\s*$)/;
/**
* Clean an expression.
*
* @param {RegExp|string} expression
* @return {string}
*/
function cleanExpression(expression) {
return (expression.source || expression).replace(EXPRESSION_START, '$1');
}
/**
* Remove the minimum indent from `value`.

@@ -119,14 +95,8 @@ *

function removeIndent(value) {
var index,
minIndent,
indent,
values,
expression;
var values = value.split(NEW_LINE);
var index = values.length;
var minIndent = Infinity;
var indent;
var expression;
values = value.split(NEW_LINE);
index = values.length;
minIndent = Infinity;
while (index--) {

@@ -156,3 +126,3 @@ if (values[index].length === 0) {

while (index--) {
values[index] = values[index].replace(expression, '');
values[index] = values[index].replace(expression, EMPTY);
}

@@ -171,11 +141,7 @@ }

function getAlignment(rows) {
var results,
index,
length,
alignment;
var results = [];
var index = -1;
var length = rows.length;
var alignment;
results = [];
index = -1;
length = rows.length;
while (++index < length) {

@@ -197,274 +163,2 @@ alignment = rows[index];

/*
* Block helpers.
*/
var block;
block = {};
block.newline = /^\n+/;
block.bullet = /(?:[*+-]|\d+\.)/;
block.code = /^( {4}[^\n]+\n*)+/;
block.horizontalRule = /^( *[-*_]){3,} *(?=\n|$)/;
block.heading = /^ *((#{1,6}) *)([^\n]+?) *#* *(?=\n|$)/;
block.lineHeading = /^([^\n]+)\n *(=|-){2,} *(?=\n|$)/;
block.linkDefinition =
/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?=\n|$)/;
block.text = /^[^\n]+/;
block.item = new RegExp(
'^( *)(' +
cleanExpression(block.bullet) +
') [^\\n]*(?:\\n(?!\\1' +
cleanExpression(block.bullet) +
' )[^\\n]*)*',
'gm');
block.list = new RegExp(
'^' +
'( *)' +
'(' + cleanExpression(block.bullet) + ')' +
'(' +
'(?: [\\s\\S]+?)' +
'(?:' +
/*
* Modified Horizontal rule:
*/
'\\n+(?=\\1?(?:[-*_] *){3,}(?=\\n|$))' +
'|' +
/*
* Modified Link Definition:
*/
'\\n+(?=' + cleanExpression(block.linkDefinition) + ')' +
'|' +
'\\n{2,}(?! )(?!\\1' +
cleanExpression(block.bullet) +
' )' +
'|' +
'\\s*$' +
')' +
')'
);
block.blockquote = new RegExp(
'^( *>[^\\n]+(\\n(?!' +
cleanExpression(block.linkDefinition) +
')[^\\n]+)*)+'
);
block.tag = (
'(?!' +
'(?:' +
'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'
);
block.html = new RegExp(
'^ *(?:' +
/*
* HTML comment.
*/
cleanExpression('<!--[\\s\\S]*?-->') +
' *(?:\\n|\\s*$)|' +
/*
* Closed tag.
*/
cleanExpression('<(' + block.tag + ')[\\s\\S]+?<\\/\\1>') +
' *(?:\\n{2,}|\\s*$)|' +
/*
* Closing tag.
*/
cleanExpression(
'<' + block.tag + '(?:"[^"]*"|\'[^\']*\'|[^\'">])*?>'
) +
' *' +
'(?:\\n{2,}|\\s*$)' +
')'
);
block.paragraph = new RegExp(
'^(?:(?:' +
'[^\\n]+\\n?' +
'(?!' +
cleanExpression(block.horizontalRule) +
'|' +
cleanExpression(block.heading) +
'|' +
cleanExpression(block.lineHeading) +
'|' +
cleanExpression(block.blockquote) +
'|' +
cleanExpression('<' + block.tag) +
'|' +
cleanExpression(block.linkDefinition) +
')' +
')+)'
);
/*
* GFM + Tables Block Grammar
*/
var gfmLooseTable,
gfmTable;
gfmLooseTable =
/^( *(\S.*\|.*))\n( *([-:]+ *\|[-| :]*)\n)((?:.*\|.*(?:\n|$))*)/;
gfmTable = /^( *\|(.+))\n( *\|( *[-:]+[-| :]*)\n)((?: *\|.*(?:\n|$))*)/;
/*
* GFM Block Grammar
*/
var gfmCodeFences,
gfmParagraph;
gfmCodeFences = /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]*?)\s*\1 *(?=\n|$)/;
gfmParagraph = new RegExp(
block.paragraph.source.replace('(?!', '(?!' +
cleanExpression(gfmCodeFences).replace('\\1', '\\2') +
'|' +
cleanExpression(block.list).replace('\\1', '\\3') +
'|'
)
);
/*
* Footnote block grammar
*/
var footnoteDefinition;
footnoteDefinition = /^( *\[\^([^\]]+)\]: *)([^\n]+(\n+ +[^\n]+)*)/;
/*
* YAML front matter.
*/
var yamlFrontMatter;
yamlFrontMatter = /^-{3}\n([\s\S]+?\n)?-{3}/;
/*
* Inline-Level Grammar.
*/
var inline;
inline = {};
inline.escape = /^\\([\\`*{}\[\]()#+\-.!_>])/;
inline.autoLink = /^<([^ >]+(@|:\/)[^ >]+)>/;
inline.tag = /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/;
inline.invalidLink = /^(!?\[)((?:\[[^\]]*\]|[^\[\]])*)\]/;
inline.strong = /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/;
inline.emphasis = /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/;
inline.code = /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/;
inline.break = /^ {2,}\n(?!\s*$)/;
inline.text = /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/;
inline.inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
inline.href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
inline.link = new RegExp(
'^(!?\\[)(' +
cleanExpression(inline.inside) +
')\\]\\(' +
cleanExpression(inline.href) +
'\\)'
);
inline.referenceLink = new RegExp(
'^(!?\\[)(' +
cleanExpression(inline.inside) +
')\\]\\s*\\[([^\\]]*)\\]'
);
/*
* Pedantic Inline Grammar.
*/
var pedanticStrong,
pedanticEmphasis;
pedanticStrong =
/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/;
pedanticEmphasis =
/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/;
/*
* GFM Inline Grammar
*/
var gfmEscape,
gfmURL,
gfmDeletion,
gfmText;
gfmEscape = new RegExp(
inline.escape.source.replace('])', '~|])')
);
gfmURL = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/;
gfmDeletion = /^~~(?=\S)([\s\S]*?\S)~~/;
gfmText = new RegExp(
inline.text.source
.replace(']|', '~]|')
.replace('|', '|https?://|')
);
/*
* GFM + Line Breaks Inline Grammar
*/
var breaksBreak,
breaksText,
breaksGFMText;
breaksBreak = new RegExp(inline.break.source.replace('{2,}', '*'));
breaksText = new RegExp(inline.text.source.replace('{2,}', '*'));
breaksGFMText = new RegExp(gfmText.source.replace('{2,}', '*'));
/*
* Define nodes of a type which can be merged.

@@ -483,3 +177,3 @@ */

MERGEABLE_NODES.html = function (prev, token) {
prev.value += '\n\n' + token.value;
prev.value += NEW_LINE + NEW_LINE + token.value;

@@ -497,3 +191,3 @@ return prev;

MERGEABLE_NODES.text = function (prev, token, type) {
prev.value += (type === 'block' ? '\n' : '') + token.value;
prev.value += (type === BLOCK ? NEW_LINE : EMPTY) + token.value;

@@ -561,8 +255,5 @@ return prev;

function tokenizeHeading(eat, $0, $1, $2, $3) {
var offset,
line;
var offset = this.offset;
var line = eat.now().line;
offset = this.offset;
line = eat.now().line;
offset[line] = (offset[line] || 0) + $1.length;

@@ -592,3 +283,3 @@

function tokenizeHorizontalRule(eat, $0) {
eat($0)(this.renderVoid('horizontalRule'));
eat($0)(this.renderVoid(HORIZONTAL_RULE));
}

@@ -603,6 +294,4 @@

function tokenizeBlockquote(eat, $0) {
var now;
var now = eat.now();
now = eat.now();
eat($0)(this.renderBlockquote($0, now));

@@ -620,35 +309,16 @@ }

function tokenizeList(eat, $0, $1, $2) {
var self,
now,
matches,
firstBullet,
bullet,
index,
length,
add,
item,
enterTop,
exitBlockquote,
list;
var self = this;
var firstBullet = $2;
var matches = trimRight($0).match(self.rules.item);
var length = matches.length;
var index = -1;
var now;
var bullet;
var add;
var item;
var enterTop;
var exitBlockquote;
var list;
self = this;
firstBullet = $2;
/*
* Remove indent.
*/
$0 = trimRight($0);
/*
* Parse the list.
*/
matches = $0.match(self.blockRules.item);
length = matches.length;
index = -1;
/*
* Determine if all list-items belong to the

@@ -660,3 +330,3 @@ * same list.

while (++index < length) {
bullet = block.bullet.exec(matches[index])[0];
bullet = self.rules.bullet.exec(matches[index])[0];

@@ -680,3 +350,3 @@ if (

add = eat('');
add = eat(EMPTY);

@@ -713,3 +383,3 @@ enterTop = self.exitTop();

eat($0)(this.renderRaw('html', $0));
eat($0)(this.renderRaw(HTML, $0));
}

@@ -746,3 +416,3 @@

function tokenizeYAMLFrontMatter(eat, $0, $1) {
eat($0)(this.renderRaw('yaml', $1 ? trimRightLines($1) : ''));
eat($0)(this.renderRaw(YAML, $1 ? trimRightLines($1) : EMPTY));
}

@@ -764,15 +434,8 @@

function tokenizeFootnoteDefinition(eat, $0, $1, $2, $3) {
var self,
token,
now,
line,
offset;
var self = this;
var now = eat.now();
var line = now.line;
var offset = self.offset;
var token;
self = this;
now = eat.now();
line = now.line;
offset = self.offset;
$3 = $3.replace(EXPRESSION_INITIAL_TAB, function (value) {

@@ -782,3 +445,3 @@ offset[line] = (offset[line] || 0) + value.length;

return '';
return EMPTY;
});

@@ -811,14 +474,10 @@

function tokenizeTable(eat, $0, $1, $2, $3, $4, $5) {
var self,
table,
index,
length;
var self = this;
var table;
var index;
var length;
var queue;
self = this;
$0 = trimRightLines($0);
$5 = trimRightLines($5);
table = eat('')({
'type': 'table',
table = eat(EMPTY)({
'type': TABLE,
'align': [],

@@ -837,3 +496,3 @@ 'children': []

return '';
return EMPTY;
}

@@ -856,8 +515,44 @@

*/
return function (value, content, pipe) {
eat(content)(row, self.renderBlock('tableCell', content));
return function (value, content, pipe, pos, input) {
var lastIndex = content.length;
/*
* Support escaped pipes in table cells.
*/
while (lastIndex--) {
if (content.charAt(lastIndex) !== SLASH) {
break;
}
if (content.charAt(--lastIndex) !== SLASH) {
/*
* Escaped pipe, add it to normal
* content, or, queue it for the
* next cell.
*/
if (pos + content.length + 1 === input.length) {
content += pipe;
pipe = EMPTY;
break;
} else {
queue = content + pipe;
return content + pipe;
}
}
}
if (queue) {
content = queue + content;
queue = EMPTY;
}
eat(content)(row, self.renderBlock(TABLE_CELL, content));
eat(pipe);
return '';
return EMPTY;
};

@@ -873,6 +568,4 @@ }

function renderRow(type, value) {
var row;
var row = eat(EMPTY)(table, self.renderBlock(type, []));
row = eat('')(table, self.renderBlock(type, []));
value

@@ -889,3 +582,3 @@ .replace(EXPRESSION_TABLE_INITIAL, eatFence)

renderRow('tableHeader', $1);
renderRow(TABLE_HEADER, $1);

@@ -901,3 +594,3 @@ eat(NEW_LINE);

$4 = $4
.replace(EXPRESSION_TABLE_FENCE, '')
.replace(EXPRESSION_TABLE_FENCE, EMPTY)
.split(EXPRESSION_TABLE_BORDER);

@@ -911,3 +604,3 @@

$5 = $5.split(NEW_LINE);
$5 = trimRightLines($5).split(NEW_LINE);

@@ -918,3 +611,3 @@ index = -1;

while (++index < length) {
renderRow('tableRow', $5[index]);
renderRow(TABLE_ROW, $5[index]);

@@ -941,3 +634,3 @@ if (index !== length - 1) {

eat($0)(this.renderBlock('paragraph', $0));
eat($0)(this.renderBlock(PARAGRAPH, $0));
}

@@ -954,3 +647,3 @@

function tokenizeText(eat, $0) {
eat($0)(this.renderRaw('text', $0));
eat($0)(this.renderRaw(TEXT, $0));
}

@@ -967,5 +660,5 @@

return {
'type': 'code',
'type': CODE,
'lang': language || null,
'value': trimRightLines(removeIndent(value || ''))
'value': trimRightLines(removeIndent(value || EMPTY))
};

@@ -983,3 +676,3 @@ }

return {
'type': 'list',
'type': LIST,
'ordered': ordered,

@@ -997,13 +690,8 @@ 'children': children

function renderListItem(token, position) {
var space,
expression,
loose,
offset,
line;
var space = 0;
var offset = this.offset;
var line = position.line;
var expression;
var loose;
space = 0;
offset = this.offset;
line = position.line;
/*

@@ -1025,3 +713,3 @@ * Remove the list token's bullet.

return '';
return EMPTY;
});

@@ -1043,3 +731,3 @@

return '';
return EMPTY;
});

@@ -1055,3 +743,3 @@

return {
'type': 'listItem',
'type': LIST_ITEM,
'loose': loose,

@@ -1070,12 +758,8 @@ 'children': this.tokenizeBlock(token, position)

function renderFootnoteDefinition(id, value, position) {
var self,
token,
exitBlockquote;
var self = this;
var exitBlockquote = self.enterBlockquote();
var token;
self = this;
exitBlockquote = self.enterBlockquote();
token = {
'type': 'footnoteDefinition',
'type': FOOTNOTE_DEFINITION,
'id': id,

@@ -1101,3 +785,3 @@ 'children': self.tokenizeBlock(value, position)

return {
'type': 'heading',
'type': HEADING,
'depth': depth,

@@ -1115,15 +799,8 @@ 'children': value

function renderBlockquote(value, position) {
var self,
token,
exitBlockquote,
offset,
line;
var self = this;
var line = position.line;
var offset = self.offset;
var exitBlockquote = self.enterBlockquote();
var token;
self = this;
line = position.line;
offset = self.offset;
exitBlockquote = self.enterBlockquote();
value = value.replace(EXPRESSION_BLOCK_QUOTE, function ($0) {

@@ -1133,7 +810,7 @@ offset[line] = (offset[line] || 0) + $0.length;

return '';
return EMPTY;
});
token = {
'type': 'blockquote',
'type': BLOCKQUOTE,
'children': this.tokenizeBlock(value, position)

@@ -1197,7 +874,7 @@ };

function renderLink(isLink, href, text, title, position) {
var token,
exitLink;
var exitLink = this.enterLink();
var token;
token = {
'type': isLink ? 'link' : 'image',
'type': isLink ? LINK : IMAGE,
'title': title || null

@@ -1207,8 +884,4 @@ };

if (isLink) {
exitLink = this.enterLink();
token.href = href;
token.children = this.tokenizeInline(text, position);
exitLink();
} else {

@@ -1219,2 +892,4 @@ token.src = href;

exitLink();
return token;

@@ -1231,3 +906,3 @@ }

return {
'type': 'footnote',
'type': FOOTNOTE,
'id': id

@@ -1259,3 +934,3 @@ };

function tokenizeEscape(eat, $0, $1) {
eat($0)(this.renderRaw('escape', $1));
eat($0)(this.renderRaw(ESCAPE, $1));
}

@@ -1273,16 +948,7 @@

function tokenizeAutoLink(eat, $0, $1, $2) {
var href,
text,
now,
offset;
var href = $1;
var text = $1;
var now = eat.now();
var offset = 1;
href = $1;
text = $1;
/*
* `1` is for the length of an opening angle bracket.
*/
offset = 1;
if ($2 === AT_SIGN) {

@@ -1297,3 +963,2 @@ if (text.substr(0, MAILTO_PROTOCOL.length) !== MAILTO_PROTOCOL) {

now = eat.now();
now.column += offset;

@@ -1315,6 +980,4 @@

function tokenizeURL(eat, $0, $1) {
var now;
var now = eat.now();
now = eat.now();
eat($0)(this.renderLink(true, $1, $1, null, now));

@@ -1332,6 +995,4 @@ }

function tokenizeTag(eat, $0) {
var self;
var self = this;
self = this;
if (!self.inLink && EXPRESSION_HTML_LINK_OPEN.test($0)) {

@@ -1343,3 +1004,3 @@ self.inLink = true;

eat($0)(self.renderRaw('html', $0));
eat($0)(self.renderRaw(HTML, $0));
}

@@ -1357,7 +1018,5 @@

function tokenizeLink(eat, $0, $1, $2, $3, $4) {
var isLink,
now;
var isLink = $0.charAt(0) !== EXCLAMATION_MARK;
var now;
isLink = $0.charAt(0) !== EXCLAMATION_MARK;
if (!isLink || !this.inLink) {

@@ -1384,13 +1043,8 @@ now = eat.now();

function tokenizeReferenceLink(eat, $0, $1, $2, $3) {
var self,
text,
url,
token,
now;
var self = this;
var text = ($3 || $2).replace(EXPRESSION_WHITE_SPACES, SPACE);
var url = self.links[text.toLowerCase()];
var token;
var now;
self = this;
text = ($3 || $2).replace(EXPRESSION_WHITE_SPACES, SPACE);
url = self.links[text.toLowerCase()];
if (

@@ -1443,3 +1097,3 @@ self.options.footnotes &&

} else {
eat($0.charAt(0))(self.renderRaw('text', $0.charAt(0)));
eat($0.charAt(0))(self.renderRaw(TEXT, $0.charAt(0)));
}

@@ -1468,9 +1122,7 @@ } else {

function tokenizeStrong(eat, $0, $1, $2) {
var now;
var now = eat.now();
now = eat.now();
now.column += 2;
eat($0)(this.renderInline('strong', $2 || $1, now));
eat($0)(this.renderInline(STRONG, $2 || $1, now));
}

@@ -1487,9 +1139,7 @@

function tokenizeEmphasis(eat, $0, $1, $2) {
var now;
var now = eat.now();
now = eat.now();
now.column += 1;
eat($0)(this.renderInline('emphasis', $2 || $1, now));
eat($0)(this.renderInline(EMPHASIS, $2 || $1, now));
}

@@ -1505,9 +1155,7 @@

function tokenizeDeletion(eat, $0, $1) {
var now;
var now = eat.now();
now = eat.now();
now.column += 2;
eat($0)(this.renderInline('delete', $1, now));
eat($0)(this.renderInline(DELETE, $1, now));
}

@@ -1524,3 +1172,3 @@

function tokenizeInlineCode(eat, $0, $1, $2) {
eat($0)(this.renderRaw('inlineCode', trimRight($2)));
eat($0)(this.renderRaw(INLINE_CODE, trimRight($2)));
}

@@ -1535,3 +1183,3 @@

function tokenizeBreak(eat, $0) {
eat($0)(this.renderVoid('break'));
eat($0)(this.renderVoid(BREAK));
}

@@ -1546,3 +1194,3 @@

function tokenizeInlineText(eat, $0) {
eat($0)(this.renderRaw('text', $0));
eat($0)(this.renderRaw(TEXT, $0));
}

@@ -1557,8 +1205,5 @@

function Parser(options) {
var self,
blockRules,
inlineRules;
var self = this;
var rules = copy({}, expressions.rules);
self = this;
/*

@@ -1574,8 +1219,4 @@ * Create space for definition/reference type nodes.

inlineRules = copy({}, inline);
blockRules = copy({}, block);
self.rules = rules;
self.inlineRules = inlineRules;
self.blockRules = blockRules;
self.footnoteCounter = 1;

@@ -1589,18 +1230,11 @@

if (options.breaks) {
inlineRules.break = breaksBreak;
inlineRules.text = breaksText;
copy(rules, expressions.breaks);
}
if (options.gfm) {
inlineRules.text = gfmText;
inlineRules.deletion = gfmDeletion;
inlineRules.url = gfmURL;
inlineRules.escape = gfmEscape;
blockRules.paragraph = gfmParagraph;
blockRules.fences = gfmCodeFences;
copy(rules, expressions.gfm);
}
if (options.gfm && options.breaks) {
inlineRules.text = breaksGFMText;
copy(rules, expressions.breaksGFM);
}

@@ -1613,17 +1247,15 @@

if (options.tables) {
blockRules.table = gfmTable;
blockRules.looseTable = gfmLooseTable;
copy(rules, expressions.tables);
}
if (options.pedantic) {
inlineRules.strong = pedanticStrong;
inlineRules.emphasis = pedanticEmphasis;
copy(rules, expressions.pedantic);
}
if (options.yaml) {
blockRules.yamlFrontMatter = yamlFrontMatter;
copy(rules, expressions.yaml);
}
if (options.footnotes) {
blockRules.footnoteDefinition = footnoteDefinition;
copy(rules, expressions.footnotes);
}

@@ -1639,13 +1271,11 @@ }

Parser.prototype.parse = function (value) {
var self,
footnotes,
footnotesAsArray,
id,
index,
token,
start,
last;
var self = this;
var footnotes;
var footnotesAsArray;
var id;
var index;
var token;
var start;
var last;
self = this;
/*

@@ -1658,6 +1288,6 @@ * Add an `offset` matrix, used to keep track of

value = self.tokenizeAll(self.tokenizeBlock(clean(value)));
token = self.renderBlock(ROOT, self.tokenizeAll(
self.tokenizeBlock(clean(value))
));
token = self.renderBlock('root', value);
if (self.options.footnotes) {

@@ -1680,9 +1310,11 @@ footnotes = self.footnotes;

token.position = {
'start': {
'line': 1,
'column': 1
}
token.position = {};
start = {
'line': 1,
'column': 1
};
token.position.start = start;
token.position.end = last ? last.position.end : start;

@@ -1700,14 +1332,7 @@

Parser.prototype.tokenizeAll = function (tokens) {
var self,
index,
length,
out;
var self = this;
var out = [];
var index = -1;
var length = tokens.length;
self = this;
out = [];
index = -1;
length = tokens.length;
while (++index < length) {

@@ -1727,28 +1352,23 @@ out[index] = self.tokenizeOne(tokens[index]);

Parser.prototype.tokenizeOne = function (token) {
var self,
pos,
type;
var self = this;
var type = token.type;
var position = token.position;
self = this;
type = token.type;
pos = token.position;
if (type === 'text') {
token = self.renderBlock('paragraph', token.value);
token.position = pos;
if (type === TEXT) {
token = self.renderBlock(PARAGRAPH, token.value);
token.position = position;
token = self.tokenizeOne(token);
} else if (
type === 'heading' ||
type === 'paragraph' ||
type === 'tableCell'
type === HEADING ||
type === PARAGRAPH ||
type === TABLE_CELL
) {
token.children = self.tokenizeInline(token.children, pos.start);
token.children = self.tokenizeInline(token.children, position.start);
} else if (
type === 'blockquote' ||
type === 'list' ||
type === 'listItem' ||
type === 'table' ||
type === 'tableHeader' ||
type === 'tableRow'
type === BLOCKQUOTE ||
type === LIST ||
type === LIST_ITEM ||
type === TABLE ||
type === TABLE_HEADER ||
type === TABLE_ROW
) {

@@ -1781,3 +1401,3 @@ token.children = self.tokenizeAll(token.children);

'paragraph': tokenizeParagraph,
'text': tokenizeText
'blockText': tokenizeText
};

@@ -1805,3 +1425,3 @@

'paragraph',
'text'
'blockText'
];

@@ -1823,24 +1443,19 @@

return function (value, location) {
var self,
line,
column,
offset,
tokens,
methods,
tokenizers,
rules,
index,
length,
method,
name,
match,
matched,
valueLength;
var self = this;
var offset = self.offset;
var tokens = [];
var rules = self.rules;
var methods = self[type + 'Methods'];
var tokenizers = self[type + 'Tokenizers'];
var line = location ? location.line : 1;
var column = location ? location.column : 1;
var index;
var length;
var method;
var name;
var match;
var matched;
var valueLength;
var err;
self = this;
offset = self.offset;
tokens = [];
/*

@@ -1850,3 +1465,3 @@ * Trim white space only lines.

value = (value || '').replace(EXPRESSION_SPACES_ONLY_LINE, '');
value = (value || EMPTY).replace(EXPRESSION_SPACES_ONLY_LINE, EMPTY);

@@ -1857,13 +1472,2 @@ if (!value) {

methods = self[type + 'Methods'];
tokenizers = self[type + 'Tokenizers'];
rules = self[type + 'Rules'];
/*
* Positional information.
*/
line = location ? location.line : 1;
column = location ? location.column : 1;
/**

@@ -1875,7 +1479,5 @@ * Update line and column based on `value`.

function updatePosition(subvalue) {
var lines,
lastIndex;
var lines = subvalue.match(/\n/g);
var lastIndex = subvalue.lastIndexOf(NEW_LINE);
lines = subvalue.match(/\n/g);
if (lines) {

@@ -1885,4 +1487,2 @@ line += lines.length;

lastIndex = subvalue.lastIndexOf('\n');
if (lastIndex === -1) {

@@ -1931,6 +1531,4 @@ column = column + subvalue.length;

function position() {
var start;
var start = now();
start = now();
return function (node) {

@@ -1953,4 +1551,4 @@ start = node.position ? node.position.start : start;

function add(parent, token) {
var prev,
children;
var prev;
var children;

@@ -1970,3 +1568,3 @@ if (!token) {

if (type === 'inline' && token.type === 'text') {
if (type === INLINE && token.type === TEXT) {
token.value = he.decode(token.value);

@@ -2001,6 +1599,4 @@ }

function eat(subvalue) {
var pos;
var pos = position();
pos = position();
value = value.substring(subvalue.length);

@@ -2025,3 +1621,3 @@

updatePosition('');
updatePosition(EMPTY);

@@ -2060,3 +1656,2 @@ /*

/* istanbul ignore else */
if (matched) {

@@ -2070,5 +1665,8 @@ break;

if (!matched) {
throw new Error(
'Infinite loop on byte: ' + value.charCodeAt(0)
);
err = new Error(line + ':' + column + ': Infinite loop');
err.reason = 'Infinite loop';
err.line = line;
err.column = column;
throw err;
}

@@ -2088,3 +1686,3 @@ }

Parser.prototype.tokenizeBlock = tokenizeFactory('block');
Parser.prototype.tokenizeBlock = tokenizeFactory(BLOCK);

@@ -2120,3 +1718,3 @@ /*

'deletion': tokenizeDeletion,
'code': tokenizeInlineCode,
'inlineCode': tokenizeInlineCode,
'break': tokenizeBreak,

@@ -2137,3 +1735,3 @@ 'text': tokenizeInlineText

'deletion',
'code',
'inlineCode',
'break',

@@ -2150,3 +1748,3 @@ 'text'

Parser.prototype.tokenizeInline = tokenizeFactory('inline');
Parser.prototype.tokenizeInline = tokenizeFactory(INLINE);

@@ -2167,9 +1765,5 @@ /**

return function () {
var self,
current;
var self = this;
var current = self[property];
self = this;
current = self[property];
self[property] = !state;

@@ -2176,0 +1770,0 @@

@@ -7,8 +7,5 @@ 'use strict';

var table,
utilities;
var table = require('markdown-table');
var utilities = require('./utilities.js');
table = require('markdown-table');
utilities = require('./utilities.js');
/*

@@ -18,32 +15,15 @@ * Cached methods.

var copy,
raise,
trimLeft,
validate;
var copy = utilities.copy;
var raise = utilities.raise;
var trimLeft = utilities.trimLeft;
var validate = utilities.validate;
copy = utilities.copy;
raise = utilities.raise;
trimLeft = utilities.trimLeft;
validate = utilities.validate;
/*
* Expressions.
*/
var EXPRESSION_TRAILING_NEW_LINES;
EXPRESSION_TRAILING_NEW_LINES = /\n+$/g;
/*
* Constants.
*/
var HALF,
INDENT,
MINIMUM_CODE_FENCE_LENGTH;
var HALF = 2;
var INDENT = 4;
var MINIMUM_CODE_FENCE_LENGTH = 3;
HALF = 2;
INDENT = 4;
MINIMUM_CODE_FENCE_LENGTH = 3;
/*

@@ -53,48 +33,25 @@ * Characters.

var ANGLE_BRACKET,
ASTERISK,
CARET,
COLON,
DASH,
DOT,
EMPTY,
EQUALS,
EXCLAMATION_MARK,
HASH,
LINE,
PARENTHESIS_OPEN,
PARENTHESIS_CLOSE,
PIPE,
PLUS,
QUOTE_DOUBLE,
SPACE,
SQUARE_BRACKET_OPEN,
SQUARE_BRACKET_CLOSE,
TICK,
TILDE,
UNDERSCORE;
var ANGLE_BRACKET = '>';
var ASTERISK = '*';
var CARET = '^';
var COLON = ':';
var DASH = '-';
var DOT = '.';
var EMPTY = '';
var EQUALS = '=';
var EXCLAMATION_MARK = '!';
var HASH = '#';
var LINE = '\n';
var PARENTHESIS_OPEN = '(';
var PARENTHESIS_CLOSE = ')';
var PIPE = '|';
var PLUS = '+';
var QUOTE_DOUBLE = '"';
var SPACE = ' ';
var SQUARE_BRACKET_OPEN = '[';
var SQUARE_BRACKET_CLOSE = ']';
var TICK = '`';
var TILDE = '~';
var UNDERSCORE = '_';
ANGLE_BRACKET = '>';
ASTERISK = '*';
CARET = '^';
COLON = ':';
DASH = '-';
DOT = '.';
EMPTY = '';
EQUALS = '=';
EXCLAMATION_MARK = '!';
HASH = '#';
LINE = '\n';
PARENTHESIS_OPEN = '(';
PARENTHESIS_CLOSE = ')';
PIPE = '|';
PLUS = '+';
QUOTE_DOUBLE = '"';
SPACE = ' ';
SQUARE_BRACKET_OPEN = '[';
SQUARE_BRACKET_CLOSE = ']';
TICK = '`';
TILDE = '~';
UNDERSCORE = '_';
/*

@@ -104,10 +61,6 @@ * Character combinations.

var BREAK,
GAP,
DOUBLE_TILDE;
var BREAK = LINE + LINE;
var GAP = BREAK + LINE;
var DOUBLE_TILDE = TILDE + TILDE;
BREAK = LINE + LINE;
GAP = BREAK + LINE;
DOUBLE_TILDE = TILDE + TILDE;
/*

@@ -117,6 +70,4 @@ * Define allowed list-bullet characters.

var LIST_BULLETS;
var LIST_BULLETS = {};
LIST_BULLETS = {};
LIST_BULLETS[ASTERISK] = true;

@@ -130,6 +81,4 @@ LIST_BULLETS[DASH] = true;

var HORIZONTAL_RULE_BULLETS;
var HORIZONTAL_RULE_BULLETS = {};
HORIZONTAL_RULE_BULLETS = {};
HORIZONTAL_RULE_BULLETS[ASTERISK] = true;

@@ -143,6 +92,4 @@ HORIZONTAL_RULE_BULLETS[DASH] = true;

var EMPHASIS_MARKERS;
var EMPHASIS_MARKERS = {};
EMPHASIS_MARKERS = {};
EMPHASIS_MARKERS[UNDERSCORE] = true;

@@ -155,9 +102,16 @@ EMPHASIS_MARKERS[ASTERISK] = true;

var FENCE_MARKERS;
var FENCE_MARKERS = {};
FENCE_MARKERS = {};
FENCE_MARKERS[TICK] = true;
FENCE_MARKERS[TILDE] = true;
/*
* Define which method to use based on `list.ordered`.
*/
var ORDERED_MAP = {};
ORDERED_MAP.true = 'visitOrderedItems';
ORDERED_MAP.false = 'visitUnorderedItems';
/**

@@ -170,7 +124,5 @@ * Helper to get the keys in an object.

function getKeys(object) {
var results,
key;
var results = [];
var key;
results = [];
for (key in object) {

@@ -203,13 +155,8 @@ results.push(key);

function getLongestRepetition(value, character) {
var index,
length,
currentCount,
highestCount,
currentCharacter;
var highestCount = 0;
var index = -1;
var length = value.length;
var currentCount;
var currentCharacter;
highestCount = 0;
index = -1;
length = value.length;
while (++index < length) {

@@ -240,4 +187,4 @@ currentCharacter = value.charAt(index);

function pad(value, level) {
var index,
padding;
var index;
var padding;

@@ -265,7 +212,5 @@ value = value.split(LINE);

function Compiler(options) {
var self,
ruleRepetition;
var self = this;
var ruleRepetition;
self = this;
self.footnoteCounter = 0;

@@ -294,3 +239,2 @@ self.linkCounter = 0;

validate.bool(options, 'referenceLinks', false);
validate.bool(options, 'referenceFootnotes', true);
validate.bool(options, 'fences', false);

@@ -312,6 +256,4 @@ validate.num(options, 'ruleRepetition', 3);

var compilerPrototype;
var compilerPrototype = Compiler.prototype;
compilerPrototype = Compiler.prototype;
/**

@@ -346,19 +288,12 @@ * Visit a token.

* @param {Object} parent
* @param {Array.<Object>} tokens
* @param {number} level
* @return {Array.<string>}
*/
compilerPrototype.visitAll = function (parent, tokens, level) {
var self,
values,
index,
length;
compilerPrototype.visitAll = function (parent, level) {
var self = this;
var tokens = parent.children;
var values = [];
var index = -1;
var length = tokens.length;
self = this;
values = [];
index = -1;
length = tokens.length;
while (++index < length) {

@@ -375,19 +310,14 @@ values[index] = self.visit(tokens[index], parent, level);

* @param {Object} token
* @param {Array.<Object>} tokens
* @param {number} level
* @return {Array.<string>}
*/
compilerPrototype.visitOrderedItems = function (token, tokens, level) {
var self,
values,
index,
length,
bullet,
indent;
compilerPrototype.visitOrderedItems = function (token, level) {
var self = this;
var values = [];
var tokens = token.children;
var index = -1;
var length = tokens.length;
var bullet;
var indent;
self = this;
values = [];
index = -1;
length = tokens.length;
level = level + 1;

@@ -403,3 +333,3 @@

return values;
return values.join(LINE);
};

@@ -411,19 +341,14 @@

* @param {Object} token
* @param {Array.<Object>} tokens
* @param {number} level
* @return {Array.<string>}
*/
compilerPrototype.visitUnorderedItems = function (token, tokens, level) {
var self,
values,
index,
length,
bullet,
indent;
compilerPrototype.visitUnorderedItems = function (token, level) {
var self = this;
var values = [];
var tokens = token.children;
var index = -1;
var length = tokens.length;
var bullet;
var indent;
self = this;
values = [];
index = -1;
length = tokens.length;
level = level + 1;

@@ -439,3 +364,3 @@

return values;
return values.join(LINE);
};

@@ -452,16 +377,10 @@

compilerPrototype.root = function (token, parent, level) {
var self,
values,
tokens,
index,
length,
child,
prevType;
var self = this;
var values = [];
var tokens = token.children;
var index = -1;
var length = tokens.length;
var child;
var prevType;
self = this;
values = [];
index = -1;
tokens = token.children;
length = tokens.length;
while (++index < length) {

@@ -507,15 +426,8 @@ child = tokens[index];

compilerPrototype.heading = function (token, parent, level) {
var setext,
closeAtx,
depth,
content,
prefix;
var setext = this.options.setext;
var closeAtx = this.options.closeAtx;
var depth = token.depth;
var content = this.visitAll(token, level).join(EMPTY);
var prefix;
setext = this.options.setext;
closeAtx = this.options.closeAtx;
depth = token.depth;
content = this.visitAll(token, token.children, level).join(EMPTY);
if (setext && (depth === 1 || depth === 2)) {

@@ -565,3 +477,3 @@ return content + LINE +

compilerPrototype.paragraph = function (token, parent, level) {
return this.visitAll(token, token.children, level).join(EMPTY);
return this.visitAll(token, level).join(EMPTY);
};

@@ -578,5 +490,4 @@

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

@@ -593,14 +504,9 @@

compilerPrototype.link = function (token, parent, level) {
var self,
value,
link;
var self = this;
var link = token.href;
var value;
self = this;
value = SQUARE_BRACKET_OPEN +
self.visitAll(token, token.children, level).join(EMPTY) +
SQUARE_BRACKET_CLOSE;
self.visitAll(token, level).join(EMPTY) + SQUARE_BRACKET_CLOSE;
link = token.href;
if (token.title) {

@@ -634,7 +540,3 @@ link += SPACE + QUOTE_DOUBLE + token.title + QUOTE_DOUBLE;

compilerPrototype.list = function (token, parent, level) {
var methodName;
methodName = token.ordered ? 'visitOrderedItems' : 'visitUnorderedItems';
return this[methodName](token, token.children, level).join(LINE);
return this[ORDERED_MAP[token.ordered]](token, level);
};

@@ -652,18 +554,9 @@

compilerPrototype.listItem = function (token, parent, level, padding) {
var self,
tokens,
values,
index,
length,
value;
var self = this;
var tokens = token.children;
var values = [];
var index = -1;
var length = tokens.length;
var value;
self = this;
tokens = token.children;
values = [];
index = -1;
length = tokens.length;
while (++index < length) {

@@ -691,14 +584,7 @@ values[index] = self.visit(tokens[index], token, level);

compilerPrototype.inlineCode = function (token) {
var value,
ticks,
start,
end;
var value = token.value;
var ticks = repeat(getLongestRepetition(value, TICK) + 1, TICK);
var start = ticks;
var end = ticks;
value = token.value;
ticks = repeat(getLongestRepetition(value, TICK) + 1, TICK);
start = ticks;
end = ticks;
if (value.charAt(0) === TICK) {

@@ -722,8 +608,5 @@ start += SPACE;

compilerPrototype.yaml = function (token) {
var delimiter,
value;
var delimiter = repeat(3, DASH);
var value = token.value ? LINE + token.value : EMPTY;
delimiter = repeat(3, DASH);
value = token.value ? LINE + token.value : EMPTY;
return delimiter + value + LINE + delimiter;

@@ -739,9 +622,6 @@ };

compilerPrototype.code = function (token) {
var value,
fence,
marker;
var value = token.value;
var marker = this.options.fence;
var fence;
value = token.value;
marker = this.options.fence;
/*

@@ -777,9 +657,5 @@ * Probably pedantic.

compilerPrototype.horizontalRule = function () {
var options,
rule;
var options = this.options;
var rule = repeat(options.ruleRepetition, options.rule);
options = this.options;
rule = repeat(options.ruleRepetition, options.rule);
if (options.ruleSpaces) {

@@ -801,10 +677,7 @@ rule = rule.split(EMPTY).join(SPACE);

compilerPrototype.strong = function (token, parent, level) {
var marker;
var marker = this.options.strong;
marker = this.options.strong;
marker = marker + marker;
return marker + this.visitAll(token, token.children, level).join(EMPTY) +
marker;
return marker + this.visitAll(token, level).join(EMPTY) + marker;
};

@@ -821,8 +694,5 @@

compilerPrototype.emphasis = function (token, parent, level) {
var marker;
var marker = this.options.emphasis;
marker = this.options.emphasis;
return marker + this.visitAll(token, token.children, level).join(EMPTY) +
marker;
return marker + this.visitAll(token, level).join(EMPTY) + marker;
};

@@ -849,4 +719,3 @@

return DOUBLE_TILDE +
this.visitAll(token, token.children, level).join(EMPTY) +
DOUBLE_TILDE;
this.visitAll(token, level).join(EMPTY) + DOUBLE_TILDE;
};

@@ -884,24 +753,3 @@

compilerPrototype.footnote = function (token) {
var footnote;
footnote = this.footnotes[token.id];
/*
* Check if the user s inline footnotes.
* But, only expose footnotes inline when the
* footnote contains just one paragraph.
*/
if (
this.options.referenceFootnotes ||
footnote.children.length !== 1 ||
footnote.children[0].type !== 'paragraph'
) {
return SQUARE_BRACKET_OPEN + CARET + token.id + SQUARE_BRACKET_CLOSE;
}
this.footnotes[token.id] = false;
return SQUARE_BRACKET_OPEN + CARET + this.visit(footnote, null) +
SQUARE_BRACKET_CLOSE;
return SQUARE_BRACKET_OPEN + CARET + token.id + SQUARE_BRACKET_CLOSE;
};

@@ -916,4 +764,3 @@

compilerPrototype.footnoteDefinition = function (token) {
return this.visitAll(token, token.children)
.join(BREAK + repeat(INDENT, SPACE));
return this.visitAll(token).join(BREAK + repeat(INDENT, SPACE));
};

@@ -930,25 +777,12 @@

compilerPrototype.table = function (token, parent, level) {
var self,
index,
rows,
result,
loose,
spaced,
start;
var self = this;
var loose = self.options.looseTable;
var spaced = self.options.spacedTable;
var rows = token.children;
var index = rows.length;
var result = [];
var start;
self = this;
loose = self.options.looseTable;
spaced = self.options.spacedTable;
rows = token.children;
index = rows.length;
result = [];
while (index--) {
result[index] = self.visitAll(
rows[index], rows[index].children, level
);
result[index] = self.visitAll(rows[index], level);
}

@@ -981,3 +815,3 @@

compilerPrototype.tableCell = function (token, parent, level) {
return this.visitAll(token, token.children, level).join(EMPTY);
return this.visitAll(token, level).join(EMPTY);
};

@@ -992,54 +826,23 @@

compilerPrototype.visitFootnoteDefinitions = function (footnotes) {
var self,
keys,
key,
index,
length,
results;
var self = this;
var keys = getKeys(footnotes);
var index = -1;
var length = keys.length;
var results = [];
var key;
self = this;
keys = getKeys(footnotes);
/*
* First stringify the footnotes definitions,
* because new footnote references could be found.
*/
index = -1;
length = keys.length;
while (++index < length) {
key = keys[index];
if (footnotes[key]) {
footnotes[key] = SQUARE_BRACKET_OPEN + CARET + key +
SQUARE_BRACKET_CLOSE + COLON + SPACE +
self.visit(footnotes[key], null);
}
if (!length) {
return EMPTY;
}
/*
* Then, all footnotes that are stringified
* inline, are set to `false`. The reset, we
* add to the buffer below.
*/
results = [];
index = -1;
while (++index < length) {
key = keys[index];
if (footnotes[key] !== false) {
results.push(footnotes[key]);
}
results.push(
SQUARE_BRACKET_OPEN + CARET + key + SQUARE_BRACKET_CLOSE +
COLON + SPACE + self.visit(footnotes[key], null)
);
}
if (results.length) {
return LINE + results.join(LINE) + LINE;
}
return EMPTY;
return LINE + results.join(LINE) + LINE;
};

@@ -1056,8 +859,6 @@

function stringify(ast, options, CustomCompiler) {
var compiler,
footnotes,
value;
var compiler = new (CustomCompiler || Compiler)(options);
var footnotes;
var value;
compiler = new (CustomCompiler || Compiler)(options);
if (ast && ast.footnotes) {

@@ -1079,3 +880,3 @@ footnotes = copy({}, ast.footnotes);

return value.replace(EXPRESSION_TRAILING_NEW_LINES, LINE);
return value;
}

@@ -1082,0 +883,0 @@

@@ -7,6 +7,4 @@ 'use strict';

var has;
var has = Object.prototype.hasOwnProperty;
has = Object.prototype.hasOwnProperty;
/*

@@ -16,18 +14,10 @@ * Expressions.

var WHITE_SPACE_FINAL,
NEW_LINE_FINAL,
WHITE_SPACE_INITIAL,
EXPRESSION_TAB,
EXPRESSION_NO_BREAK_SPACE,
EXPRESSION_SYMBOL_FOR_NEW_LINE,
EXPRESSION_LINE_BREAKS;
var WHITE_SPACE_FINAL = /\s+$/;
var NEW_LINE_FINAL = /\n+$/;
var WHITE_SPACE_INITIAL = /^\s+/;
var EXPRESSION_LINE_BREAKS = /\r\n|\r/g;
var EXPRESSION_TAB = /\t/g;
var EXPRESSION_SYMBOL_FOR_NEW_LINE = /\u2424/g;
var EXPRESSION_NO_BREAK_SPACE = /\u00a0/g;
WHITE_SPACE_FINAL = /\s+$/;
NEW_LINE_FINAL = /\n+$/;
WHITE_SPACE_INITIAL = /^\s+/;
EXPRESSION_LINE_BREAKS = /\r\n|\r/g;
EXPRESSION_TAB = /\t/g;
EXPRESSION_SYMBOL_FOR_NEW_LINE = /\u2424/g;
EXPRESSION_NO_BREAK_SPACE = /\u00a0/g;
/**

@@ -44,3 +34,2 @@ * Shallow copy `context` into `target`.

for (key in context) {
/* istanbul ignore else */
if (has.call(context, key)) {

@@ -78,6 +67,4 @@ target[key] = context[key];

function validateBoolean(obj, name, def) {
var value;
var value = obj[name];
value = obj[name];
if (value === null || value === undefined) {

@@ -104,6 +91,4 @@ value = def;

function validateNumber(obj, name, def) {
var value;
var value = obj[name];
value = obj[name];
if (value === null || value === undefined) {

@@ -131,6 +116,4 @@ value = def;

function validateMap(obj, name, map, def) {
var value;
var value = obj[name];
value = obj[name];
if (value === null || value === undefined) {

@@ -137,0 +120,0 @@ value = def;

{
"name": "mdast",
"version": "0.3.0",
"version": "0.4.0",
"description": "Speedy Markdown parser/stringifier for multipurpose analysis",

@@ -65,3 +65,3 @@ "license": "MIT",

"lint-cli": "eslint --rule no-process-exit:false cli.js",
"lint-script": "eslint script/build-options.js example.js",
"lint-script": "eslint example.js script/build-options.js script/build-expressions.js",
"lint-test": "eslint --env mocha test/index.js test/fixtures.js test/plugin.js",

@@ -73,2 +73,3 @@ "lint-style": "jscs --reporter inline index.js benchmark.js cli.js example.js script/build-options.js lib/parse.js lib/stringify.js lib/utilities.js test/index.js test/fixtures.js test/plugin.js",

"build-man": "marked-man doc/mdast.1.md > man/mdast.1",
"build-expressions": "node script/build-expressions.js",
"build-usage": "mdast --use mdast-usage Readme.md -o Readme.md",

@@ -78,5 +79,5 @@ "build-options": "node script/build-options.js",

"postbuild-bundle": "esmangle mdast.js > mdast.min.js",
"build": "npm run build-usage && npm run build-options && npm run build-man && npm run build-bundle",
"build": "npm run build-expressions && npm run build-usage && npm run build-options && npm run build-man && npm run build-bundle",
"prepublish": "npm run build"
}
}

@@ -262,3 +262,2 @@ # ![mdast](https://cdn.rawgit.com/wooorm/mdast/master/logo.svg)

- `referenceLinks` (`boolean`, default: `false`). See [Reference Links](doc/Options.md#reference-links);
- `referenceFootnotes` (`boolean`, default: `true`). See [Inline Footnotes](doc/Options.md#inline-footnotes);
- `fence: string` (`"~"` or ``"`"``, default: `~`). See [Fence](doc/Options.md#fence);

@@ -265,0 +264,0 @@ - `fences` (`boolean`, default: `false`). See [Fences](doc/Options.md#fences);

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