Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
prettyprint: function (html, options) {
var beautify = require('js-beautify').html_beautify;
var opts = {
indent_size: this.options.indentSize,
wrap_line_length: 120,
unformatted: ['pre']
};
// js-beautify sometimes trips when the first character isn't a <. not
// sure... but might as well do this.
html = html.trim();
var output = beautify(html, extend(opts, options));
// cheerio output tends to have a bunch of extra newlines. kill them.
output = output.replace(/\n\n+/g, "\n\n");
return output;
},
"preserve_newlines": true,
"max_preserve_newlines": 5,
"jslint_happy": false,
"brace_style": "collapse",
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"break_chained_methods": false,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0
});
break;
default:
content = beautify.html_beautify(content, {
"indent_inner_html": true,
"indent_size": 4,
"indent_char": " ",
"brace_style": "collapse",
"indent_scripts": "normal",
"wrap_line_length": 0,
"preserve_newlines": true,
"max_preserve_newlines": 10
});
break;
}
console.log('Content beautify as ' + type);
return content;
},
let instanceHTML
switch (dataHTML) {
case 'outer':
instanceHTML = element.parentNode.querySelector('.instance').outerHTML
break
case '':
instanceHTML = element.parentNode.querySelector('.instance').innerHTML
break
default:
instanceHTML = this.templates[dataHTML]()
break
}
renderAce({
where: element,
mode: 'html',
value: beautify.html_beautify(instanceHTML, {
unformatted: [''],
}),
view: this,
})
})
this.$el.find('.editor[data-css]').each((index, element) => {
}
let { dir } = parse(this.path);
let styles = meta.get("styles");
let tpl = (({ template, type } = {}) => {
switch (type) {
case "link":
return readFileSync(join(dir, template)).toString();
case "inline":
return template;
default:
return "";
}
})(meta.get("template"));
return beautify([
...this.links.map(module => ``),
...this.scripts.map(module => ``),
nonEmpty``,
`${[
nonEmpty`\n<template>${[
...styles.map(({ style, type }) => {
switch (type) {
case "link":
return `${readFileSync(join(dir, style))}`;
case "inline":
if (!this.isES6) {
style = style.replace(/\\n/g, "\n").replace(/\\"/g, '"');
}
return `${style}`;
case "shared":</template>
super(props);
const config = {
globalConsentLocation: `//${CURRENT_LOCATION}portal.html`,
storeConsentGlobally: true,
storePublisherData: false
};
const bookmarkScript = `javascript:(function(){
${buildScript(config, `//${CURRENT_LOCATION}../cmp.bundle.js`)}
window.__cmp('showConsentTool');
}());`.replace(/}\n/g, '};');
this.setState({
bookmarklet: bookmarkScript,
tag: beautify(``),
});
}
function htmlFormat(filename){
var content = f.read(filename);
f.write(filename, beautify.html_beautify(content));
logger.info('jdf format ['+filename+'] success');
}
prettify: function(opts, cb) {
opts.indent_size = opts.indent_size || 4;
opts.indent_char = opts.indent_char || " ";
opts.wrap_line_length = opts.wrap_line_length || 0;
opts.preserve_newlines = opts.preserve_newlines || false;
var pretty = beautify.html_beautify(opts.input, opts);
cb({
output: pretty
});
}
},