Skip to content

Commit 0453f4e

Browse files
authored
fix(document): ignore empty lines in compare (#169)
1 parent b50f513 commit 0453f4e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/module/src/runtime/utils/document.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ export async function isDocumentMatchingContent(content: string, document: Datab
154154
const { body: generatedBody, ...generatedDocumentData } = generatedDocument
155155
const { body: documentBody, ...documentData } = document
156156

157-
if (stringify(withoutLastStyles(generatedBody as MarkdownRoot)) !== stringify(withoutLastStyles(documentBody as MarkdownRoot))) {
157+
const generatedBodyStringified = stringify(withoutLastStyles(generatedBody as MarkdownRoot))
158+
// remove new lines because they are not significant for the comparison
159+
.replace(/\n/g, '')
160+
const documentBodyStringified = stringify(withoutLastStyles(documentBody as MarkdownRoot))
161+
// remove new lines because they are not significant for the comparison
162+
.replace(/\n/g, '')
163+
if (generatedBodyStringified !== documentBodyStringified) {
158164
return false
159165
}
160166

0 commit comments

Comments
 (0)