Comparing version 2.1.1 to 2.2.0
@@ -12,11 +12,8 @@ 'use strict'; | ||
var children = parent && parent.children; | ||
var length = children && children.length; | ||
var index = -1; | ||
var results = []; | ||
while (++index < length) { | ||
results[index] = one(ctx, children[index], index, parent); | ||
} | ||
if (!children) return ''; | ||
return results.join(''); | ||
return children.map(function (child, index) { | ||
return one(ctx, child, index, parent); | ||
}).join(''); | ||
} |
@@ -56,3 +56,3 @@ 'use strict'; | ||
function escapeRegExp(str) { | ||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); // eslint-disable-line no-useless-escape | ||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); | ||
} |
@@ -47,6 +47,6 @@ 'use strict'; | ||
if (!type) { | ||
throw new Error('Expected node, not `' + node + '`'); | ||
throw new Error('Received node \'' + node + '\' does not have a type.'); | ||
} | ||
if (!(has(h, type) && typeof h[type] === 'function')) { | ||
if (!has(h, type) || typeof h[type] !== 'function') { | ||
throw new Error('Cannot compile unknown node `' + type + '`'); | ||
@@ -53,0 +53,0 @@ } |
@@ -11,28 +11,22 @@ 'use strict'; | ||
function root(ctx, node, _, parent) { | ||
var values = []; | ||
var children = node.children; | ||
var length = children.length; | ||
var index = -1; | ||
var child = void 0; | ||
var prev = void 0; | ||
if (!children) return ''; | ||
while (++index < length) { | ||
child = children[index]; | ||
var previous = void 0; | ||
if (prev) { | ||
if (child.type === prev.type && prev.type === 'list') { | ||
values.push(prev.ordered === child.ordered ? '\n\n\n' : '\n\n'); | ||
} else if (prev.type === 'list' && child.type === 'code' && !child.lang) { | ||
values.push('\n\n\n'); | ||
return children.reduce(function (output, child, index) { | ||
if (previous) { | ||
if (child.type === previous.type && previous.type === 'list') { | ||
output += previous.ordered === child.ordered ? '\n\n\n' : '\n\n'; | ||
} else if (previous.type === 'list' && child.type === 'code' && !child.lang) { | ||
output += '\n\n\n'; | ||
} else { | ||
values.push('\n\n'); | ||
output += '\n\n'; | ||
} | ||
} | ||
values.push(one(ctx, child, index, node, node)); | ||
prev = child; | ||
} | ||
return values.join(''); | ||
output += one(ctx, child, index, node, node); | ||
previous = child; | ||
return output; | ||
}, ''); | ||
} |
{ | ||
"name": "rebber", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Stringifies MDAST to LaTeX", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/zestedesavoir/zmarkdown/tree/master/packages/rebber", |
@@ -10,11 +10,8 @@ /* Dependencies. */ | ||
const children = parent && parent.children | ||
const length = children && children.length | ||
let index = -1 | ||
const results = [] | ||
while (++index < length) { | ||
results[index] = one(ctx, children[index], index, parent) | ||
} | ||
if (!children) return '' | ||
return results.join('') | ||
return children | ||
.map((child, index) => one(ctx, child, index, parent)) | ||
.join('') | ||
} |
@@ -53,3 +53,3 @@ /* Dependencies. */ | ||
function escapeRegExp (str) { | ||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') // eslint-disable-line no-useless-escape | ||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&') | ||
} |
@@ -45,6 +45,6 @@ /* Dependencies. */ | ||
if (!type) { | ||
throw new Error(`Expected node, not \`${node}\``) | ||
throw new Error(`Received node '${node}' does not have a type.`) | ||
} | ||
if (!(has(h, type) && typeof h[type] === 'function')) { | ||
if (!has(h, type) || typeof h[type] !== 'function') { | ||
throw new Error(`Cannot compile unknown node \`${type}\``) | ||
@@ -51,0 +51,0 @@ } |
@@ -9,28 +9,22 @@ /* Dependencies. */ | ||
function root (ctx, node, _, parent) { | ||
const values = [] | ||
const children = node.children | ||
const length = children.length | ||
let index = -1 | ||
let child | ||
let prev | ||
if (!children) return '' | ||
while (++index < length) { | ||
child = children[index] | ||
let previous | ||
if (prev) { | ||
if (child.type === prev.type && prev.type === 'list') { | ||
values.push(prev.ordered === child.ordered ? '\n\n\n' : '\n\n') | ||
} else if (prev.type === 'list' && child.type === 'code' && !child.lang) { | ||
values.push('\n\n\n') | ||
return children.reduce((output, child, index) => { | ||
if (previous) { | ||
if (child.type === previous.type && previous.type === 'list') { | ||
output += previous.ordered === child.ordered ? '\n\n\n' : '\n\n' | ||
} else if (previous.type === 'list' && child.type === 'code' && !child.lang) { | ||
output += '\n\n\n' | ||
} else { | ||
values.push('\n\n') | ||
output += '\n\n' | ||
} | ||
} | ||
values.push(one(ctx, child, index, node, node)) | ||
prev = child | ||
} | ||
return values.join('') | ||
output += one(ctx, child, index, node, node) | ||
previous = child | ||
return output | ||
}, '') | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42268
1112