Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('marked', () => {
const marked = require('marked');
const getCleanMarkup = markeup => marked(markeup).replace(/\r\n|\r|\n/g, ''); // remove new lines charactes
const originalOptions = { ...marked.defaults };
afterEach(() => {
marked.setOptions(originalOptions);
});
// This functionality was broken by initial version of markedjsOverrides.js. So put tests here
// to avoid this in future.
it('Table is rendered', () => {
const inputString = `| a | b | c | d | e |
|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 |`;
const html = '<table><thead><tr><th>a</th><th>b</th><th>c</th><th>d</th><th>e</th></tr></thead><tbody><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr></tbody></table>';
expect(getCleanMarkup(inputString)).to.be.equal(html);
});
const listOptionTests = isSmartLists => {
// This functionality was broken by initial version of markedjsOverrides.js. So put tests here
.then(content => {
/* parsing tokens and put tokens into each page */
markedopt = merge({} , marked.defaults , { renderer: renderer
, promise: true});
var tokens = marked.Lexer.lex(content, markedopt);
var pageTokens = [];
tokens.forEach(token => {
if (pageTokens.length === 0) {
pageTokens.push([token]);
} else if (token.type === 'heading' && token.depth === 1) {
pageTokens.push([token]);
} else {
pageTokens[pageTokens.length-1].push(token);
}
});
pageTokens.forEach(toks => {
toks.links = tokens.links;
});
function ultramarked (src, opt) {
var options = assign({}, marked.defaults, opt);
var aliases = options.aliases || ultramarked.aliases;
var no = 'no-highlight';
if (options.terminal) {
delete options.ultralight;
delete options.ultrasanitize;
}
if (options.ultralight) {
options.langPrefix = 'ultralight-lang-'; // placeholder
options.highlight = function (code, lang) {
if (!lang) {
return code;
}
var lower = lang.toLowerCase();
try {
return hljs.highlight(aliases[lower] || lower, code).value;
function(Lexer, InlineLexer, Renderer, TOC, Tasklist) {
var gui = require('nw.gui'),
win = gui.Window.get();
var marked = require("marked");
var options = store.get('Markdown') || {
breaks: true,
smartLists: true,
langPrefix: '',
smartypants: true
};
var defaults = merge(marked.defaults, options, {
renderer: Renderer
});
var lexer = Lexer(defaults);
marked.InlineLexer = InlineLexer(defaults);
// marked.setOptions(defaults);
var parse = window.marked = function(src) {
var tokens = lexer.lex(src);
// var toc = TOC(tokens);
var tasks = Tasklist(tokens);
// var title = toc.tokens[0] && toc.tokens[0].heading;
var res = {};
// res.title = title || i18n.t('untitled');
function renderCode(rend, defaults, text, language) {
var config = getConfig(defaults, text, language);
if (!config) return marked.defaults.renderer.code.call(rend, text.trim(), language);
// remove config line
text = text.slice(text.indexOf("\n") + 1);
// will be prepended to a later box
if (config.withNext) {
if (rend._demobox_next) {
rend._demobox_next.push([text, config, language]);
} else {
rend._demobox_next = [[text, config, language]];
}
return "";
}
var attrs = configAttrs(config);
if (!rend._demobox_next) {
return "<textarea data-demobox="">\n" + textAreaSafe(text) + "\n</textarea>";
+ "\n\\fB"
+ name
+ "\\fR"
+ resc(text);
}
function manDate(date) {
var stamp = parseInt(date);
if (!isNaN(stamp) && stamp.toString().length == date.length) date = stamp;
date = new Date(date);
var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][date.getMonth()];
return month + " " + date.getFullYear();
}
marked.defaults.format = "roff";
marked.defaults.name = "";
if (marked.defaults.date == null) marked.defaults.date = new Date;
marked.defaults.section = "";
marked.defaults.manVersion = "";
marked.defaults.manual = "";
marked.defaults.gfm = true;
marked.defaults.breaks = false;
marked.defaults.ronn = false;
module.exports = marked;
+ quote("NAME")
+ "\n\\fB"
+ name
+ "\\fR"
+ resc(text);
}
function manDate(date) {
var stamp = parseInt(date);
if (!isNaN(stamp) && stamp.toString().length == date.length) date = stamp;
date = new Date(date);
var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][date.getMonth()];
return month + " " + date.getFullYear();
}
marked.defaults.format = "roff";
marked.defaults.name = "";
if (marked.defaults.date == null) marked.defaults.date = new Date;
marked.defaults.section = "";
marked.defaults.manVersion = "";
marked.defaults.manual = "";
marked.defaults.gfm = true;
marked.defaults.breaks = false;
marked.defaults.ronn = false;
module.exports = marked;
+ resc(text);
}
function manDate(date) {
var stamp = parseInt(date);
if (!isNaN(stamp) && stamp.toString().length == date.length) date = stamp;
date = new Date(date);
var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][date.getMonth()];
return month + " " + date.getFullYear();
}
marked.defaults.format = "roff";
marked.defaults.name = "";
if (marked.defaults.date == null) marked.defaults.date = new Date;
marked.defaults.section = "";
marked.defaults.manVersion = "";
marked.defaults.manual = "";
marked.defaults.gfm = true;
marked.defaults.breaks = false;
marked.defaults.ronn = false;
module.exports = marked;
var stamp = parseInt(date);
if (!isNaN(stamp) && stamp.toString().length == date.length) date = stamp;
date = new Date(date);
var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][date.getMonth()];
return month + " " + date.getFullYear();
}
marked.defaults.format = "roff";
marked.defaults.name = "";
if (marked.defaults.date == null) marked.defaults.date = new Date;
marked.defaults.section = "";
marked.defaults.manVersion = "";
marked.defaults.manual = "";
marked.defaults.gfm = true;
marked.defaults.breaks = false;
marked.defaults.ronn = false;
module.exports = marked;
+ "\n.SH "
+ quote("NAME")
+ "\n\\fB"
+ name
+ "\\fR"
+ resc(text);
}
function manDate(date) {
var stamp = parseInt(date);
if (!isNaN(stamp) && stamp.toString().length == date.length) date = stamp;
date = new Date(date);
var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][date.getMonth()];
return month + " " + date.getFullYear();
}
marked.defaults.format = "roff";
marked.defaults.name = "";
if (marked.defaults.date == null) marked.defaults.date = new Date;
marked.defaults.section = "";
marked.defaults.manVersion = "";
marked.defaults.manual = "";
marked.defaults.gfm = true;
marked.defaults.breaks = false;
marked.defaults.ronn = false;
module.exports = marked;