Files
coopgo/node_modules/react-markdown/node_modules/mdast-util-to-hast/lib/handlers/code.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

27 lines
569 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict'
module.exports = code
var u = require('unist-builder')
function code(h, node) {
var value = node.value ? node.value + '\n' : ''
// To do: next major, use `node.lang` w/o regex, the splittings been going
// on for years in remark now.
var lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/)
var props = {}
var code
if (lang) {
props.className = ['language-' + lang]
}
code = h(node, 'code', props, [u('text', value)])
if (node.meta) {
code.data = {meta: node.meta}
}
return h(node.position, 'pre', [code])
}