Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(options) {
highlight.configure(options);
let normalizedOptions = Object.assign({}, defaults, options);
let {selector} = normalizedOptions;
return function highlightContent(root, data, metalsmith, done) {
Array.from(root.querySelectorAll(selector)).forEach(node => {
highlight.highlightBlock(node);
// Tag the parent node as well for style adjustments
if (node.parentNode && node.parentNode.classList) {
node.parentNode.classList.add('lang-highlight');
}
});
done();
};
};
module.exports = function(options = {}) {
highlightjs.configure(options);
/**
* @param {Object} files files
* @param {Metalsmith} metalsmith metalsmith
* @param {Function} done done
* @returns {void}
*/
return function(files, metalsmith, done) {
let file, data;
for (file in files) {
if (HTML_FILENAME_REGEXP.test(file)) {
data = files[file];
data.contents = Buffer.from(highlightFile(data.contents.toString()));
}
}
options.markedOptions.highlight = function (code) {
var hl = require('highlight.js');
hl.configure(options.highlightjs.options || {});
return hl.highlightAuto(code).value;
};
}
constructor (options, comments) {
this.linkerStack = new LinkerStack(options)
.namespaceResolver(comments, (namespace) => {
const slugger = new GithubSlugger()
return '#' + slugger.slug(namespace)
})
this.options = options
this.comments = comments
this.formatters = createFormatters(this.linkerStack.link)
this.options.hljs = this.options.hljs || {}
hljs.configure(this.options.hljs)
this.formatType = this.formatters.type
this.autolink = this.formatters.autolink
}
module.exports = function (comments, options, callback) {
var linkerStack = createLinkerStack(options)
.namespaceResolver(comments, function (namespace) {
var slugger = new GithubSlugger();
return '#' + slugger.slug(namespace);
});
var formatters = createFormatters(linkerStack.link);
hljs.configure(options.hljs || {});
var sharedImports = {
imports: {
slug: function (str) {
var slugger = new GithubSlugger();
return slugger.slug(str);
},
shortSignature: function (section) {
var prefix = '';
if (section.kind === 'class') {
prefix = 'new ';
} else if (section.kind !== 'function') {
return section.name;
}
return prefix + section.name + formatters.parameters(section, true);
},