|
@@ -34,14 +34,12 @@ const turndownService = new TurndownService({
|
|
|
// Remove image tags from markdown
|
|
// Remove image tags from markdown
|
|
|
turndownService.remove('img');
|
|
turndownService.remove('img');
|
|
|
|
|
|
|
|
-// Clean up text: remove excessive whitespace, newlines, tabs
|
|
|
|
|
|
|
+// Clean up text: minimal cleanup to preserve markdown formatting
|
|
|
const cleanupText = (text: string): string => {
|
|
const cleanupText = (text: string): string => {
|
|
|
return text
|
|
return text
|
|
|
- .replace(/\t/g, ' ') // Replace tabs with spaces
|
|
|
|
|
- .replace(/[ ]+/g, ' ') // Replace multiple spaces with single space
|
|
|
|
|
- .replace(/\n{3,}/g, '\n\n') // Replace 3+ newlines with 2 newlines
|
|
|
|
|
- .replace(/^\s+|\s+$/gm, '') // Trim whitespace from each line
|
|
|
|
|
- .trim(); // Trim overall
|
|
|
|
|
|
|
+ .replace(/\n{4,}/g, '\n\n\n') // Limit to max 3 consecutive newlines (preserve paragraph spacing)
|
|
|
|
|
+ .replace(/[ \t]+$/gm, '') // Remove trailing spaces/tabs from each line
|
|
|
|
|
+ .trim(); // Trim overall leading/trailing whitespace
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export function CustomContentTextEntry({ onSuccess }: CustomContentTextEntryProps) {
|
|
export function CustomContentTextEntry({ onSuccess }: CustomContentTextEntryProps) {
|