mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user