From 8982dcae103d38cad97e8112d57d09f3ad1e9933 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Tue, 17 May 2022 08:13:12 -0400 Subject: [PATCH] =?UTF-8?q?Replace=20"m1234"=20with=20"=CF=BB1234"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/components/linkify.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/components/linkify.tsx b/web/components/linkify.tsx index 459fdf0c..dbe7042d 100644 --- a/web/components/linkify.tsx +++ b/web/components/linkify.tsx @@ -4,7 +4,12 @@ import { SiteLink } from './site-link' // Return a JSX span, linkifying @username, #hashtags, and https://... // TODO: Use a markdown parser instead of rolling our own here. export function Linkify(props: { text: string; gray?: boolean }) { - const { text, gray } = props + let { text, gray } = props + // Replace "m1234" with "ϻ1234" + const mRegex = /(\W|^)m(\d+)/g + text = text.replace(mRegex, (_, pre, num) => `${pre}ϻ${num}`) + + // Find instances of @username, #hashtag, and https://... const regex = /(?:^|\s)(?:[@#][a-z0-9_]+|https?:\/\/[-A-Za-z0-9+&@#\/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#\/%=~_|])/gi const matches = text.match(regex) || []