diff --git a/src/convert/streams.ts b/src/convert/streams.ts
index f9bffccbb1..5fc18e1719 100644
--- a/src/convert/streams.ts
+++ b/src/convert/streams.ts
@@ -257,14 +257,16 @@ export class JsToXml extends Readable {
cdataPropName: '__cdata',
commentPropName: XML_COMMENT_PROP_NAME,
});
-
const builtXml = String(builder.build(this.xmlObject));
- const xmlContent = XML_DECL.concat(handleSpecialEntities(builtXml));
+ const xmlContent = correctComments(XML_DECL.concat(handleSpecialEntities(builtXml)));
this.push(xmlContent);
this.push(null);
}
}
+/** xmlBuilder likes to add newline and indent before/after the comment (hypothesis: it uses `<` as a hint to newlint/indent) */
+const correctComments = (xml: string): string =>
+ xml.includes('\s+/g, '') : xml;
/**
* use this function to handle special html entities.
* XmlBuilder will otherwise replace ex: ` ` with `' '` (escape the &)
diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objectTranslations/Contact-en_US.objectTranslation b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objectTranslations/Contact-en_US.objectTranslation
index 7fe08d1632..3661fcc07f 100644
--- a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objectTranslations/Contact-en_US.objectTranslation
+++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-md-files.expected/objectTranslations/Contact-en_US.objectTranslation
@@ -2,24 +2,16 @@
-
-
-
-
+
+
Example__c
One
-
-
-
+
Two
-
-
-
+
diff --git a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Example__c.fieldTranslation-meta.xml b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Example__c.fieldTranslation-meta.xml
index a4e92fd529..880116e2d4 100644
--- a/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Example__c.fieldTranslation-meta.xml
+++ b/test/snapshot/sampleProjects/xmlComments/__snapshots__/verify-source-files.expected/force-app/main/default/objectTranslations/Contact-en_US/Example__c.fieldTranslation-meta.xml
@@ -1,22 +1,14 @@
-
-
-
-
+
+
Example__c
One
-
-
-
+
Two
-
-
-
+