fix: include manual post-number quotes in reply backlinks

Backlink map generation now merges protocol-level quotedCids with parsed >>number references from reply content. Manual quotes are resolved through numberToCid from usePostNumberStore and deduplicated using Set. Centralized QUOTE_NUMBER_REGEX in url-utils to keep markdown conversion and backlink detection aligned.
This commit is contained in:
plebeius
2026-02-10 16:53:34 +08:00
parent 35783ff627
commit 702816f99b
3 changed files with 51 additions and 17 deletions
+3 -2
View File
@@ -1,5 +1,7 @@
import { copyToClipboard } from './clipboard-utils';
export const QUOTE_NUMBER_REGEX = /(?<![>/\w])>>(\d+)/g;
export const getHostname = (url: string) => {
try {
return new URL(url).hostname.replace(/^www\./, '');
@@ -183,8 +185,7 @@ export const isValidCrossboardPattern = (pattern: string): boolean => {
// Transform >>{number} post number patterns to markdown links with special anchor
const preprocessPostNumberPatterns = (content: string): string => {
// Match >> followed by digits, avoid overlap with greentext (>>>), cross-board (>>>/), URLs, CID-like patterns
const pattern = /(?<![>/\w])>>(\d+)(?![\d/])/g;
return content.replace(pattern, (_, num) => `[>>${num}](#q-${num})`);
return content.replace(QUOTE_NUMBER_REGEX, (_, num) => `[>>${num}](#q-${num})`);
};
// Preprocess content to convert plain text 5chan cross-board patterns to markdown links