Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
highlight: function(str, lang) {
const language = !lang || lang === 'html' ? 'markup' : lang;
try {
if (!Prism.languages[language]) {
require(`prismjs/components/prism-${language}.min.js`);
}
if (Prism.languages[language]) {
return Prism.highlight(str, Prism.languages[language]);
}
} catch (__) {
// eslint-disable-next-line
console.error(__);
}
return '';
},
});
onChange={e => {
this.updateAmount(e);
}}
placeholder="AMOUNT_IN_ETH"
/>
<br>
<button>Send!</button>
<br>
{this.state.err === '' ? '' : this.state.err}
<div>
</div>
const highlighter = (code, lang) => {
if (typeof lang === 'undefined') lang = 'markup'
if (!Prism.languages.hasOwnProperty(lang)) {
try {
require('prismjs/components/prism-' + lang + '.js')
} catch (e) {
Prism.languages[lang] = false
}
}
return Prism.languages[lang] ? Prism.highlight(code, Prism.languages[lang]) : code
}
nb.highlighter = (text, pre, code, lang) => {
if (options.sliceCode) {
const JSX_REG = /(````)(?:jsx?)([^\1]*?)(\1)/g;
const STYLE_REG = /(````)(?:css|style?)([^\1]*?)(\1)/g;
const jsxMatched = JSX_REG.exec(result.content);
const styleMatched = STYLE_REG.exec(result.content);
if (jsxMatched) {
result.code = jsxMatched[2] || '';
result.content = result.content.replace(jsxMatched[0], '');
}
if (styleMatched) {
const styleCode = styleMatched[2] || '';
result.highlightedStyle = prismjs.highlight(styleCode.trim(), prismjs.languages.css);
}
result.highlightedCode = prismjs.highlight(result.code.trim(), prismjs.languages.jsx);
result.compiledCode = bableCompile(result.code, babelConfig);
}
result.content = marked(result.content);
return result;
};
};
return text => {
if (text) {
return Prism.highlight(text, Prism.languages.html);
}
return text;
};
}
header.appendChild(img);
let headline = document.createElement('h2');
headline.textContent = 'Image #' + (index + 1);
header.appendChild(headline);
report.appendChild(header);
let errors = buildErrors(image.data, image.images);
if (errors.length) {
errors.forEach(error => report.appendChild(error));
let markup = document.createElement('pre');
let html = '<code>' + prism.highlight(
buildMarkup(image.markup),
prism.languages.html,
'html'
) + '</code>';
Object.keys(image.images).sort(
(a, b) => b.length - a.length
).forEach(src => {
html = html.replace(new RegExp(
'([>,\\s])('
+ src.replace(/&/g, '&').replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&')
+ ')([<,\\s])'
, 'g'), '$1<a href="' + image.images[src].url + '" class="token regex">$2</a>$3');
});
markup.innerHTML = html;
showExam (name, color = '') {
const newcolor = color !== '' ? `color="${color}"` : ''
const code = ``
return Prism.highlight(code, Prism.languages.markup, 'markup')
}
}
.then(([fCode, fLazyCode, fAsyncCode]) => ({
name,
fCode: prism.highlight(fCode, prism.languages.javascript),
fLazyCode: fLazyCode && prism.highlight(fLazyCode, prism.languages.javascript),
fAsyncCode: fAsyncCode && prism.highlight(fAsyncCode, prism.languages.javascript),
}));
})
function highlight (lang, code) {
const startTag = `<figure class="highlight ${lang}"><table><tbody><tr><td class="code"><pre>`
const endTag = '</pre></td></tr></tbody></table></figure>'
let parsedCode = ''
if (Prism.languages[lang]) {
parsedCode = Prism.highlight(code, Prism.languages[lang])
} else {
parsedCode = code
}
return startTag + parsedCode + endTag
}
private skipStyle(item: LoadParams, container: Element) {
const styleStr = item.load
const styleEl = getStyleEl()
let originContent = ''
const code = Prism.highlight(styleStr, Prism.languages.css)
if (!item.rewrite) {
originContent = container.innerHTML
}
styleEl.innerHTML = styleStr
container.innerHTML = originContent + code
}