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 24 25 26 27 28 29 30 | 1x 38x 38x 5x 15x 15x | import { PluggableList, Pluggable } from 'unified';
import { rehype } from 'rehype';
export const processHtml = (html: string, plugins: PluggableList = [] as Pluggable[]) => {
return rehype()
.data('settings', { fragment: true })
.use([...plugins])
.processSync(`${html}`)
.toString();
};
export function htmlEncode(sHtml: string) {
return sHtml
.replace(/```(tsx?|jsx?|html|xml)(.*)\s+([\s\S]*?)(\s.+)?```/g, (str: string) => {
return str.replace(
/[<&"]/g,
(c: string) => (({ '<': '<', '>': '>', '&': '&', '"': '"' }) as Record<string, string>)[c],
);
})
.replace(
/[<&"]/g,
(c: string) => (({ '<': '<', '>': '>', '&': '&', '"': '"' }) as Record<string, string>)[c],
);
}
export function stopPropagation(e: React.KeyboardEvent<HTMLTextAreaElement>) {
e.stopPropagation();
e.preventDefault();
}
|