mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-14 15:45:55 +08:00
fix: the complex regexp caused node.js process to hang
Co-authored-by: Claude 3 opus
This commit is contained in:
parent
fef1d0faf1
commit
2e025d10cf
@ -27,7 +27,3 @@ process.on('uncaughtException', (err) => {
|
||||
console.error('Uncaught exception, process quit.');
|
||||
throw err;
|
||||
});
|
||||
|
||||
if (!process.env.FUNCTIONS_EMULATOR) {
|
||||
registry.walk_around_firebase_stall = true;
|
||||
}
|
||||
|
@ -2,14 +2,14 @@
|
||||
export function tidyMarkdown(markdown: string): string {
|
||||
|
||||
// Step 1: Handle complex broken links with text and optional images spread across multiple lines
|
||||
let normalizedMarkdown = markdown.replace(/\[\s*([^]+?)\s*\]\s*\(\s*([^)]+)\s*\)/g, (match, text, url) => {
|
||||
let normalizedMarkdown = markdown.replace(/\[\s*([^\]\n]+?)\s*\]\s*\(\s*([^)]+)\s*\)/g, (match, text, url) => {
|
||||
// Remove internal new lines and excessive spaces within the text
|
||||
text = text.replace(/\s+/g, ' ').trim();
|
||||
url = url.replace(/\s+/g, '').trim();
|
||||
return `[${text}](${url})`;
|
||||
});
|
||||
|
||||
normalizedMarkdown = normalizedMarkdown.replace(/\[\s*([^!]*?)\s*\n*(?:!\[([^\]]*)\]\((.*?)\))?\s*\n*\]\s*\(\s*([^)]+)\s*\)/g, (match, text, alt, imgUrl, linkUrl) => {
|
||||
normalizedMarkdown = normalizedMarkdown.replace(/\[\s*([^\]\n!]*?)\s*\n*(?:!\[([^\]]*)\]\((.*?)\))?\s*\n*\]\s*\(\s*([^)]+)\s*\)/g, (match, text, alt, imgUrl, linkUrl) => {
|
||||
// Normalize by removing excessive spaces and new lines
|
||||
text = text.replace(/\s+/g, ' ').trim();
|
||||
alt = alt ? alt.replace(/\s+/g, ' ').trim() : '';
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 21e6ece0f378fe26db888bc5ff7715a43bf022bd
|
||||
Subproject commit d3bb3a7335ec9d96c68d1edf1b66fdf5e2fe5b7c
|
Loading…
x
Reference in New Issue
Block a user