Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
code(node: MDASTCodeNode): JSAST {
let value = node.value ? detab(node.value + '\n') : '';
value = this.encode(value);
value = this.renderText(value);
return this.renderElement('Code', null, value);
}
export default function code (h, node) {
const value = node.value ? detab(node.value + '\n') : ''
const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/)
const props = {}
if (lang) {
props.className = ['language-' + lang]
}
return h(node.position, 'pre', [h(node, 'code', props, [u('text', value)])])
}
const codeHandler = (h, node) => {
const value = node.value ? detab(node.value + '\n') : ''
const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/)
const props = {}
if (lang) {
props.className = ['language-' + lang]
props.lang = lang
}
return h(node.position, 'pre', props, [unist('text', value)])
}
export default function code(h, node) {
const value = node.value ? detab(node.value + '\n') : ''
const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/)
const props = {}
if (lang) {
props.className = ['language-' + lang]
}
return h(node.position, 'pre', [
h(node, 'code', props, [u(node.highlighted ? 'raw' : 'text', value)])
])
}
export default function codeToHast(h, node) {
const value = node.value ? detab(node.value + '\n') : '';
const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/);
const codeProps = {className: `language-${lang}`};
const preProps = {className: 'line-numbers'};
if (node.meta) {
const {line} = querystring.parse(node.meta);
preProps.dataLine = line;
}
return h(node.position, 'pre', preProps, [
h(node, 'code', codeProps, [u('text', value)])
]);
}
const codeHandler = (h, node, parent) => {
const props = {
lang: node.lang
}
const value = node.value ? detab(node.value + '\n') : ''
return h(node.position, 'pre', props, [unist('text', value)])
}