2 * Rehype plugin to provide comprehensive RTL support by adding dir="auto"
3 * to all text-containing elements.
5 * This operates directly on the HAST tree, ensuring that all elements
6 * (including those not in a predefined list) receive the attribute.
9 import type { Plugin } from 'unified';
10 import type { Root, Element } from 'hast';
11 import { visit } from 'unist-util-visit';
14 * Rehype plugin to add dir="auto" to all elements that have children.
15 * This provides bidirectional text support for mixed RTL/LTR content.
17 export const rehypeRtlSupport: Plugin<[], Root> = () => {
18 return (tree: Root) => {
19 visit(tree, 'element', (node: Element) => {
20 if (node.children && node.children.length > 0) {