2017-04-29 10:24:43 -04:00
|
|
|
/**
|
|
|
|
* Render markdown code blocks as `<code-example>` tags
|
|
|
|
*/
|
|
|
|
module.exports = function code(h, node) {
|
|
|
|
var value = node.value ? ('\n' + node.value + '\n') : '';
|
|
|
|
var lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/);
|
2019-07-20 13:40:17 -04:00
|
|
|
var props = {};
|
2017-04-29 10:24:43 -04:00
|
|
|
|
|
|
|
if (lang) {
|
|
|
|
props.language = lang;
|
|
|
|
}
|
|
|
|
|
|
|
|
return h(node, 'code-example', props, [{ type: 'text', value }]);
|
|
|
|
};
|