Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var updatedTokens = [];
//console.log('file:', file.filename, 'tags:', commonTags);
for (i = 0; i < tokens.length; i++) {
if ((i !== 0) && (tokens[i].type === 'heading')) {
if (tokens[i].depth <= 2) {
updatedTokens.push({'type': 'paragraph', 'text': '#HSLIDE'});
} else if (tokens[i].depth <= (commonTags.slideshow.headingLevel ? commonTags.slideshow.headingLevel : 3)) {
updatedTokens.push({'type': 'paragraph', 'text': '#VSLIDE'});
}
}
updatedTokens.push(tokens[i]);
}
updatedTokens.links = tokens.links;
//console.log(updatedTokens);
var renderer = mdRenderer(new marked.Renderer());
var parser = new marked.Parser({renderer: renderer});
var slideMarkdown = parser.parse(updatedTokens);
// HTML content *************************************************************
var content = marked.parser(tokens);
// Autoreload tag ***********************************************************
var autoReload = '';
if ((config.mode === 'serve') && config.serveAutoReload) {
autoReload = '' +
'';
}
// Add content to index *****************************************************
let tokens;
try {
tokens = lexer.lex(src);
} catch (err) {
throw new Error(`Lexer Error ${err}`);
}
tokens = extractTokenRange(tokens, fromHeaderId, toHeaderId);
// render
let renderer;
if (toHeaderId === EXTERNAL_READER_NODE_MODE_SPECIAL_ID) {
renderer = getHTMLRendererForExternalNode();
} else {
renderer = getHTMLRendererForExternalRange();
}
const parser = new marked.Parser({
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: false,
silent: false,
highlight: null,
langPrefix: 'lang-',
smartypants: false,
headerPrefix: '',
renderer: renderer,
xhtml: false,
});
const oldTok = parser.tok;
parser.tok = function() {
var log = require('debug')('um');
var la = require('lazy-ass');
var check = require('check-more-types');
var read = require('fs').readFileSync;
var write = require('fs').writeFileSync;
var _ = require('lodash');
var marked = require('marked');
var mdRenderer = require('marked-to-md');
var renderer = mdRenderer(new marked.Renderer());
var parser = new marked.Parser({renderer: renderer});
// '## bar' -> 'bar'
function headerText(text) {
la(check.unemptyString(text), 'missing text', text);
var tokens = marked.lexer(text);
la(tokens.length, 'missing tokens', tokens, 'from', text);
return tokens[0].text;
}
function isHeading(token) {
return token && token.type === 'heading';
}
// returns indices, both could be -1 or the end could be -1
function findSection(tokens, heading) {
var text = headerText(heading);
let tokens;
try {
tokens = lexer.lex(src);
} catch (err) {
throw new Error(`Lexer Error ${err}`);
}
tokens = extractTokenRange(tokens, fromHeaderId, toHeaderId);
// render
let renderer;
if (toHeaderId === EXTERNAL_READER_NODE_MODE_SPECIAL_ID) {
renderer = getHTMLRendererForExternalNode();
} else {
renderer = getHTMLRendererForExternalRange();
}
let parser = new marked.Parser({
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: false,
silent: false,
highlight: null,
langPrefix: 'lang-',
smartypants: false,
headerPrefix: '',
renderer: renderer,
xhtml: false,
});
let oldTok = parser.tok;
parser.tok = function() {
let tokens;
try {
tokens = lexer.lex(src);
} catch (err) {
throw new Error(`Lexer Error ${err}`);
}
tokens = extractTokenRange(tokens, fromHeaderId, toHeaderId);
// render
let renderer;
if (toHeaderId === EXTERNAL_READER_NODE_MODE_SPECIAL_ID) {
renderer = getHTMLRendererForExternalNode();
} else {
renderer = getHTMLRendererForExternalRange();
}
const parser = new marked.Parser({
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: false,
silent: false,
highlight: null,
langPrefix: 'lang-',
smartypants: false,
headerPrefix: '',
renderer: renderer,
xhtml: false,
});
const oldTok = parser.tok;
parser.tok = function() {
const _inlineDeMarkdown = function(token) {
// called by parseNavigationItems,
// html, paragraph, and text needs inline parsing to strip markdown marks.
const payload = [token];
payload.links = tokens.links;
const parser = new marked.Parser({
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: false,
silent: false,
highlight: null,
langPrefix: 'lang-',
smartypants: false,
headerPrefix: '',
renderer: getPlainRenderer(),
xhtml: false,
});
const text = parser.parse(payload);
return text;
return text + level.toString() + slugger.slug(raw);
};
renderer.hr = () => {
return `\n`;
};
renderer.checkbox = (checked) => {
return checked ? 'CHECKED' : 'UNCHECKED';
};
const rendererOptions: marked.MarkedOptions = renderer.options;
const textRenderer = new marked.TextRenderer();
console.log(textRenderer.strong(text));
const parseTestText = '- list1\n - list1.1\n\n listend';
const parseTestTokens: marked.TokensList = marked.lexer(parseTestText, options);
const parser = new marked.Parser();
console.log(parser.parse(parseTestTokens));
console.log(marked.Parser.parse(parseTestTokens));
const parserOptions: marked.MarkedOptions = parser.options;
const links = ['http', 'image'];
const inlineLexer = new marked.InlineLexer(links);
console.log(inlineLexer.output('http://'));
console.log(marked.InlineLexer.output('http://', links));
console.log(marked.InlineLexer.rules);
const inlineLexerOptions: marked.MarkedOptions = inlineLexer.options;
Object.keys(result.tokens).forEach((key) => {
var renderer = this.customMarkdownRenderer(cardShortId, key);
var parser = new marked.Parser({
gfm: true,
breaks: true,
tables: false,
renderer: renderer
});
var html = parser.parse(result.tokens[key]);
result.card[key] = html.replace(/\n+$/, '');
});
converted.push(result.card);
constructor(appKey, authToken, boardId) {
this.api = new Trello(appKey, authToken);
this.boardId = boardId;
this.lexer = new marked.Lexer({
gfm: true,
breaks: true,
tables: false
});
this.parser = new marked.Parser({
gfm: true,
breaks: true,
tables: false
});
this.options = Converter.defaultOptions;
this.results = {};
this.warnings = [];
}
baseMarked.Parser.parse = function (src, options) {
let parser = new baseMarked.Parser(options)
parser.renderer.headingCount = undefined
parser.renderer._parser = parser
return parser.parse(src)
}