UNPKG

@memori.ai/memori-react

Version:

[![npm version](https://img.shields.io/github/package-json/v/memori-ai/memori-react)](https://www.npmjs.com/package/@memori.ai/memori-react) ![Tests](https://github.com/memori-ai/memori-react/workflows/CI/badge.svg?branch=main) ![TypeScript Support](https

32 lines 1.05 kB
export function stripMarkdown(text) { return text .replace(/\*\*(.*?)\*\*/g, '$1') .replace(/\*(.*?)\*/g, '$1') .replace(/__(.*?)__/g, '$1') .replace(/_(.*?)_/g, '$1') .replace(/~~(.*?)~~/g, '$1') .replace(/```(.*?)```/gs, '$1') .replace(/`(.*?)`/g, '$1') .replace(/\[(.*?)\]\((.*?)\)/g, '$1'); } export function stripEmojis(text) { return text.replace(/[\u{1F600}-\u{1F64F}|\u{1F300}-\u{1F5FF}|\u{1F680}-\u{1F6FF}|\u{2600}-\u{26FF}|\u{2700}-\u{27BF}]/gu, ''); } export function stripHTML(text) { return text.replace(/<[^>]*>/g, ''); } export function stripOutputTags(text) { return text; } export function escapeHTML(text) { return text .replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/"/g, '&quot;') .replace(/'/g, '&apos;'); } export function sanitizeText(text) { return escapeHTML(stripMarkdown(stripEmojis(stripHTML(stripOutputTags(text))))); } //# sourceMappingURL=sanitizer.js.map