summaryrefslogtreecommitdiff
path: root/packages/markdown/remark/src/rehype-escape.ts
blob: e0094b463eca37f34d9cecaedf5e33e86e048cfe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
import { SKIP, visit } from 'unist-util-visit';

export default function rehypeEscape(): any {
  return function (node: any): any {
    return visit(node, 'element', (el) => {
      if (el.tagName === 'code' || el.tagName === 'pre') {
        el.properties['data-astro-raw'] = true;
      }
      return el;
    });
  };
}