Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mdToJsonSchema(mdStr, maxDepth, imagePath) {
var renderer = new marked.Renderer();
renderer.link = function (href, title, text) {
if (href.match(/^~/)) { // Property link
return '<a href="#' + href.slice(1) + '">' + text + '</a>';
}
else {
// All other links are opened in new page
return '<a href="' + href + '">' + text + '</a>';
}
};
renderer.image = function (href, title, text) {
var size = (text || '').split('x');
if (isNaN(size[0])) {
size[0] = 'auto';
}
if (isNaN(size[1])) {
const jdown = require('../dist');
const marked = require('marked');
// See https://marked.js.org/#/USING_PRO.md#renderer
const renderer = new marked.Renderer();
renderer.heading = (text, level) =>
`${text}`;
jdown('example/content', {
fileInfo: true,
markdown: {renderer},
assets: {output: 'example/public', path: '/'}
}).then(content => console.log(content));
const express = require('express');
const marked = require('marked');
const hljs = require('highlight.js');
const router = express.Router();
// Monkey patch the default markdown renderer to allow code highlighting
const renderer = new marked.Renderer();
renderer.code = (code, language) =>
`<pre><code class="hljs ${language}">${hljs.highlightAuto(code, language ? [language] : null).value}</code></pre>`;
// GET home page
router.get('/', async (req, res, next) => {
try {
const data = await req.kb.getAllTags({ includeShortDesc: true });
res.render('index', { data });
} catch (e) {
next(e);
}
});
// Get tag details
router.get('/:source/:tag', async (req, res, next) => {
var options = {
src: '**/*.md',
dest: 'build/data',
includeFilename: true,
compileMarkdown: true,
bodyProperty: 'body',
exportName: 'content.json',
singleFile: false,
writeFiles: false,
writeStdout: true
};
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: true,
pedantic: false,
// sanitize: true,
smartLists: true,
// smartypants: false,
highlight: function(code) {
return require('highlight.js').highlightAuto(code).value;
}
});
function parseFile(input) {
var output = {};
var hasFrontmatter = input.data.slice(0, 3) === MD_SEPERATOR;
_initRenderer() {
const renderer = new marked.Renderer()
const {linkTarget, linkRel, router, contentBase} = this
const _self = this
const origin = {}
/**
* Render anchor tag
* @link https://github.com/markedjs/marked#overriding-renderer-methods
*/
origin.heading = renderer.heading = function (text, level) {
let {str, config} = getAndRemoveConfig(text)
const nextToc = {level, title: str}
if (/{docsify-ignore}/g.test(str)) {
str = str.replace('{docsify-ignore}', '')
nextToc.title = str
nextToc.ignoreSubHeading = true
.then(data => marked(data, {
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false
}))
.catch(manageErrors),
const isProduction = process.env.NODE_ENV === 'production';
const codeRenderer = function(code, lang) {
lang = lang === 'js' ? 'javascript' : lang;
if (lang === 'html') {
lang = 'xml';
}
let hlCode = lang ?
hl.highlight(lang, code).value : hl.highlightAuto(code).value;
return `<div class="doc-highlight"><pre><code class="${lang || ''}">${hlCode}</code></pre></div>`;
};
let renderer = new marked.Renderer();
renderer.code = codeRenderer;
const entry = './docs/app.js';
const devEntry = [
'webpack/hot/dev-server',
'webpack-hot-middleware/client?reload=true',
entry,
];
const basePlugins = [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
new HTMLWebpackPlugin({
title: 'Amaze UI React',
/**
* Created by chief on 16/11/28.
*/
var router = require("koa-router")();
var fs = require("fs");
var path = require("path");
var cate = require("../static/json/catalog-0.1.json");
var markdown = require("markdown").markdown;
var marked = require("marked");
var axios = require('axios')
var renderer = new marked.Renderer();
var components = require('../static/components/components.json');
var qs = require('querystring');
renderer.link = function (href,title,text) {
var target = '';
if(href){
target="_blank";
}else{
href = 'javacript:void(0);'
}
return `<a href="${href}">${text}</a>`;
};
marked.setOptions({
renderer: renderer,
gfm: true,
renderContent () {
const renderer = new marked.Renderer()
renderer.heading = (text, level, raw) => {
const id = raw.toLowerCase().replace(/[^\w]+/g, '-')
return (
`` +
text +
`\n`
)
}
renderer.paragraph = (text) => {
return `<p class="${this.config.classNames.p}">${text}</p>\n`
}
renderer.listitem = (text) => {
return `<li class="${this.config.classNames.li}">${text}</li>\n`
}
renderer.code = (source, infoString) => {
handlebars.registerHelper('markdown', function(md) {
var renderer = new marked.Renderer();
renderer.table = function(header, body) {
return ''
+ `${header}`
+ `${body}`
+ '<table class="table"><thead></thead><tbody></tbody></table>'
};
renderer.code = codeBlock
return md ? new handlebars.SafeString(marked(md, { renderer: renderer })) : '';
});
handlebars.registerHelper('upperCase', _.method('toUpperCase'));