Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.map(function(section) {
// Run through marked parser to generate HTML.
return {
title: section.title ? section.title.trim() : '',
slug: section.slug || '',
docs: trimNewLines(marked.parser(section.docs)),
code: trimNewLines(section.code)
};
});
};
function render(token, idx) {
var tok;
tok = [ token ];
tok.links = _links;
html = marked.parser(tok);
window.ee.emit('markdown.fragment.change', html, idx);
}
try {
let lex = marked.lexer(editor.value);
lex.forEach((token, i) => {
if (token.text && token.type !== 'code') {
token.text = mdmath(token.text);
lex[i] = token;
}
if (token.type === 'table') {
token.cells = token.cells.map((row) => {
return row.map((cell) => {
return mdmath(cell);
})
})
}
});
viewer.innerHTML = marked.parser(lex);
} catch (error) { console.log(error) }
}
newTokens.push({ type: 'html', pre: 'false', text: '' });
inDiv = false;
}
newTokens.push({ type: 'html', pre: false, text: '<div id="page' + anchorCount + '" class="page">' });
inDiv = true;
token.text = '<a id="page' + anchorCount + '"></a>' + token.text;
anchorCount++;
} else if (token.type === 'code') {
token.text = hljs(token.text, token.lang).value;
token.escaped = true;
}
newTokens.push(token);
}
newTokens.links = tokens.links;
text = marked_.parser(newTokens);
return text;
}
</div>
swig.setFilter('markdownify', function (input) {
var tokens = marked.lexer(input);
return ( marked.parser(tokens) );
})
depth: token.depth,
anchor: anchor,
});
finalTokens.push({
type: 'html',
text: '<a name="' + anchor + '"></a>',
pre: false,
});
}
finalTokens.push(token);
}
finalTokens.links = tokens.links;
this.html = marked.parser(finalTokens, markedOptions);
}
var tokens = marked.lexer(text)
, l = tokens.length
, token;
for (var i = 0; i < l; i++) {
token = tokens[i];
if (token.type == 'code') {
var lang = token.lang || 'javascript';
if (lang == 'js') lang = 'javascript';
if (lang == 'html') lang = 'xml';
token.text = highlight.highlight(lang, token.text).value;
token.escaped = true;
}
}
text = marked.parser(tokens);
return text;
};
function parseMarkdown (text) {
var tokens = marked.lexer(text)
, l = tokens.length
, token;
for (var i = 0; i < l; i++) {
token = tokens[i];
if (token.type == 'code') {
var lang = token.lang || 'javascript';
if (lang == 'js') lang = 'javascript';
token.text = highlight.highlight(lang, token.text).value;
token.escaped = true;
}
}
text = marked.parser(tokens);
return text;
};
var parse = function(src, options) {
options = options || opt;
return marked.parser(marked.lexer(src, options), options, renderer);
}
export default function compileMarkdown(source, config) {
let tokens = marked.lexer(source);
let markedOptions = {
highlight: highlightCode,
renderer: new HBSRenderer(config)
};
if (config && config.targetHandlebars) {
tokens = compactParagraphs(tokens);
}
return `<div class="docs-md">${marked.parser(tokens, markedOptions).trim()}</div>`;
}