vn-verdnaturachat/app/containers/markdown/formatText.ts

7 lines
230 B
TypeScript
Raw Normal View History

// Support <http://link|Text>
export const formatText = (text: string): string =>
text.replace(
new RegExp('(?:<|<)((?:https|http):\\/\\/[^\\|]+)\\|(.+?)(?=>|>)(?:>|>)', 'gm'),
(match, url, title) => `[${title}](${url})`
);