Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
node.delim = /`/.test(node.text) ? '``' : '`';
if (node.html) {
var type = node.parent.type;
node.lang = type === 'pre' ? utils.getLang(node.attribs) : '';
var text = {type: 'text', val: unescape(node.html)};
if (node.lang) {
text.val = node.text;
}
define(text, 'parent', node);
define(text, 'prev', {});
define(text, 'next', {});
node.nodes = [text];
util.wrapNodes(node, Node);
}
this.mapVisit(node);
})
.set('code.open', function(node) {
started = true;
tbody = { type: 'tbody', nodes: [] };
define(tbody, 'parent', ast);
nodes.push(tbody);
}
if (started) {
define(node, 'parent', tbody);
tbody.nodes.push(node);
} else {
nodes.push(node);
}
}
if (tbody) {
util.wrapNodes(tbody, Node);
}
ast.nodes = [open];
ast.nodes = ast.nodes.concat(nodes);
ast.nodes.push(close);
}
var codeInner = opts.literalPre === true
? code.html && code.html()
: code.text && code.text();
var text = codeInner || $(node).text();
node.gfm = true;
node.text = '\n' + text.trim() + '\n';
node.html = '\n' + (code ? text : html).trim() + '\n';
node.attr = (code.attr && code.attr());
} else {
var tok = { type: 'text', val: html };
node.nodes = [tok];
define(tok, 'parent', node);
if (!isSelfClosing(node.type)) {
util.wrapNodes(node, Node);
}
}
} else if (node.name === 'code') {
node.html = $(node).html();
node.text = $(node).text();
}
}
if (opts.literalPre && node.type === 'pre') {
node.normalize = false;
}
if (node.name === 'link' && node.attribs && node.attribs.rel === 'canonical') {
ast.canonical = node.attribs.href;
}
return node;
var br = {type: 'text', val: '<br>', prev: {}, next: {}};
define(br, 'parent', firstTh);
nodes.push(br);
col.nodes.forEach(function(node, ci) {
if (ci === 0 || ci === col.nodes.length - 1) return;
define(node, 'parent', firstTh);
nodes.push(node);
});
firstTh.nodes = [firstThOpen].concat(nodes);
firstTh.nodes.push(firstThClose);
});
}
thead.nodes = [firstRow];
util.wrapNodes(thead, Node);
}
function createHead(ast) {
var thead = { type: 'thead', nodes: [] };
define(thead, 'parent', ast);
if (ast.nodes.length === 3) {
var text = { type: 'text', val: '' };
var th = { type: 'th', attribs: { align: 'center'}, nodes: [text] };
define(text, 'parent', th);
define(th, 'parent', thead);
thead.nodes.push(th);
util.wrapNodes(th, Node);
util.wrapNodes(thead, Node);
ast.nodes.splice(1, 0, thead);
return ast;
}
for (var i = 0; i < ast.nodes.length; i++) {
var node = ast.nodes[i];
if (node.nodes && util.hasType(node, 'th')) {
define(node, 'parent', thead);
thead.nodes.push(node);
util.wrapNodes(thead, Node);
ast.nodes[i] = thead;
break;
}
}
var th = { type: 'th', attribs: { align: 'center'}, nodes: [text] };
define(text, 'parent', th);
define(th, 'parent', thead);
thead.nodes.push(th);
util.wrapNodes(th, Node);
util.wrapNodes(thead, Node);
ast.nodes.splice(1, 0, thead);
return ast;
}
for (var i = 0; i < ast.nodes.length; i++) {
var node = ast.nodes[i];
if (node.nodes && util.hasType(node, 'th')) {
define(node, 'parent', thead);
thead.nodes.push(node);
util.wrapNodes(thead, Node);
ast.nodes[i] = thead;
break;
}
}
return ast;
}
function createHead(ast) {
var thead = { type: 'thead', nodes: [] };
define(thead, 'parent', ast);
if (ast.nodes.length === 3) {
var text = { type: 'text', val: '' };
var th = { type: 'th', attribs: { align: 'center'}, nodes: [text] };
define(text, 'parent', th);
define(th, 'parent', thead);
thead.nodes.push(th);
util.wrapNodes(th, Node);
util.wrapNodes(thead, Node);
ast.nodes.splice(1, 0, thead);
return ast;
}
for (var i = 0; i < ast.nodes.length; i++) {
var node = ast.nodes[i];
if (node.nodes && util.hasType(node, 'th')) {
define(node, 'parent', thead);
thead.nodes.push(node);
util.wrapNodes(thead, Node);
ast.nodes[i] = thead;
break;
}
}
return ast;