From 393d882cfea96017abd79e217060c0773b36cd03 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Wed, 14 Jan 2026 11:07:53 +0100 Subject: [PATCH] fix(preprocessMarkdown): handle autolink syntax for video URLs Support markdown autolinks in addition to standard markdown links [text](url) for YouTube and Rumble videos. Co-Authored-By: Claude Opus 4.5 --- .../TipTap/utils/preprocessMarkdown.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/src/Components/TipTap/utils/preprocessMarkdown.ts b/lib/src/Components/TipTap/utils/preprocessMarkdown.ts index e790ae2e..2a87bee2 100644 --- a/lib/src/Components/TipTap/utils/preprocessMarkdown.ts +++ b/lib/src/Components/TipTap/utils/preprocessMarkdown.ts @@ -61,10 +61,23 @@ export function preprocessMarkdown(text: string): string { /** * Converts YouTube and Rumble markdown links to video-embed HTML tags. + * Handles both standard markdown links [Text](url) and autolinks */ export function preprocessVideoLinks(text: string): string { let result = text + // YouTube autolinks: + result = result.replace( + /&]+)[^>]*>/g, + '', + ) + + // YouTube short autolinks: + result = result.replace( + /?]+)[^>]*>/g, + '', + ) + // YouTube: [Text](https://www.youtube.com/watch?v=VIDEO_ID) result = result.replace( /\[([^\]]*)\]\(https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^)&]+)[^)]*\)/g, @@ -77,6 +90,12 @@ export function preprocessVideoLinks(text: string): string { '', ) + // Rumble autolinks: + result = result.replace( + /]+)>/g, + '', + ) + // Rumble embed URLs: [Text](https://rumble.com/embed/VIDEO_ID) result = result.replace( /\[([^\]]*)\]\(https?:\/\/rumble\.com\/embed\/([^)]+)\)/g,