All files / src/plugins reservedMeta.ts

80% Statements 4/5
57.14% Branches 4/7
100% Functions 3/3
80% Lines 4/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            1x 4x 4x 10x            
import type { Plugin } from 'unified';
import { Root, RootContent } from 'hast';
import { visit } from 'unist-util-visit';
 
export interface ReservedMetaOptions {}
 
export const reservedMeta: Plugin<[ReservedMetaOptions?], Root> = (options = {}) => {
  return (tree) => {
    visit(tree, (node: Root | RootContent) => {
      Iif (node.type === 'element' && node.tagName === 'code' && node.data && node.data.meta) {
        node.properties = { ...node.properties, 'data-meta': String(node.data.meta) };
      }
    });
  };
};