All files / src/plugins/default markbind-plugin-shorthandSyntax.ts

100% Statements 5/5
85.71% Branches 6/7
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23              2x   60x       1x 1x 1x              
import { MbNode } from '../../utils/node.js';
import { PluginContext } from '../Plugin.js';
 
/**
 * Converts shorthand syntax to proper MarkBind syntax
 * @param content of the page
 */
const processNode = (_pluginContext: PluginContext, node: MbNode) => {
  // panel>span[heading]
  if (node.name === 'span'
       && node.attribs.heading !== undefined
       && node.parent
       && node.parent.name === 'panel') {
    node.attribs.slot = 'header';
    node.attribs.class = node.attribs.class ? `${node.attribs.class} card-title` : 'card-title';
    delete node.attribs.heading;
  }
};
 
export {
  processNode,
};