mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-13 06:23:18 +00:00
fix: remove indentation while preserving HTML structure in ExtractContentWithCSS
This commit is contained in:
@@ -564,13 +564,20 @@ func ExtractContentWithCSS(content, includeSelector string, excludeSelectors []s
|
||||
return "", fmt.Errorf("error extracting content with CSS selector: %v", err)
|
||||
}
|
||||
|
||||
// Trim leading and trailing whitespace, but preserve internal newlines
|
||||
// Trim leading and trailing whitespace
|
||||
selectedContent = strings.TrimSpace(selectedContent)
|
||||
|
||||
// Normalize newlines
|
||||
selectedContent = strings.ReplaceAll(selectedContent, "\r\n", "\n")
|
||||
selectedContent = strings.ReplaceAll(selectedContent, "\r", "\n")
|
||||
|
||||
// Remove indentation while preserving structure
|
||||
lines := strings.Split(selectedContent, "\n")
|
||||
for i, line := range lines {
|
||||
lines[i] = strings.TrimSpace(line)
|
||||
}
|
||||
selectedContent = strings.Join(lines, "\n")
|
||||
|
||||
// Remove any leading or trailing newlines
|
||||
selectedContent = strings.Trim(selectedContent, "\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user