diff --git a/src/services/metadata/parse.ts b/src/services/metadata/parse.ts index cb3a3b86..0376d3fc 100644 --- a/src/services/metadata/parse.ts +++ b/src/services/metadata/parse.ts @@ -103,7 +103,9 @@ export const parseExistingMetadata = ( }; export const serializeMetadata = (objectMetadata: FileMetadata) => { - const dumped = unescapeLiquidSubstitutionSyntax(dump(objectMetadata).trimEnd()); + const dumped = unescapeLiquidSubstitutionSyntax( + dump(objectMetadata, {forceQuotes: true}).trimEnd(), + ); // This empty object check is a bit naive // The other option would be to check if all own fields are `undefined`, diff --git a/tests/e2e/__snapshots__/include-toc.test.ts.snap b/tests/e2e/__snapshots__/include-toc.test.ts.snap index 986277f4..4397cef6 100644 --- a/tests/e2e/__snapshots__/include-toc.test.ts.snap +++ b/tests/e2e/__snapshots__/include-toc.test.ts.snap @@ -4,14 +4,14 @@ exports[`Include toc Nested toc inclusions with mixed including modes 1`] = `"[" exports[`Include toc Nested toc inclusions with mixed including modes 2`] = ` "--- -sourcePath: product1/core/_includes/inc.md +sourcePath: 'product1/core/_includes/inc.md' --- This is the core include." `; exports[`Include toc Nested toc inclusions with mixed including modes 3`] = ` "--- -sourcePath: product1/core/article1.md +sourcePath: 'product1/core/article1.md' --- This is the core content of Article 1. @@ -31,7 +31,7 @@ deepBase: 1 exports[`Include toc Nested toc inclusions with mixed including modes 5`] = ` "--- -sourcePath: product2/core/_includes/inc.md +sourcePath: 'product2/core/_includes/inc.md' --- This is the core include. " @@ -39,7 +39,7 @@ This is the core include. exports[`Include toc Nested toc inclusions with mixed including modes 6`] = ` "--- -sourcePath: product2/overlay1/product/article1.md +sourcePath: 'product2/overlay1/product/article1.md' --- This is the overlay content of Article 1 for product 2. @@ -49,7 +49,7 @@ This is the overlay content of Article 1 for product 2. exports[`Include toc Nested toc inclusions with mixed including modes 7`] = ` "--- -sourcePath: product2/core/_includes/inc.md +sourcePath: 'product2/core/_includes/inc.md' --- This is the core include. " @@ -57,7 +57,7 @@ This is the core include. exports[`Include toc Nested toc inclusions with mixed including modes 8`] = ` "--- -sourcePath: product2/overlay2/product/article1.md +sourcePath: 'product2/overlay2/product/article1.md' --- This is the overlay number #2 of Article 1 content for product 2. @@ -67,7 +67,7 @@ This is the overlay number #2 of Article 1 content for product 2. exports[`Include toc Nested toc inclusions with mixed including modes 9`] = ` "--- -sourcePath: product2/core/_includes/inc.md +sourcePath: 'product2/core/_includes/inc.md' --- This is the core include. " @@ -75,7 +75,7 @@ This is the core include. exports[`Include toc Nested toc inclusions with mixed including modes 10`] = ` "--- -sourcePath: product2/core/article1.md +sourcePath: 'product2/core/article1.md' --- This is the core content of Article 1. @@ -160,9 +160,9 @@ exports[`Include toc Toc is included inline, not as a new section 3`] = ` exports[`Include toc Toc is included inline, not as a new section 4`] = ` "--- -title: File A -description: YFM description -sourcePath: folder/fileA.md +title: 'File A' +description: 'YFM description' +sourcePath: 'folder/fileA.md' --- # File A @@ -176,7 +176,7 @@ Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, wh exports[`Include toc Toc is included inline, not as a new section 5`] = ` "--- -sourcePath: folder/fileB.md +sourcePath: 'folder/fileB.md' --- # File B @@ -192,7 +192,7 @@ Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, wh exports[`Include toc Toc is included inline, not as a new section 6`] = ` "--- -sourcePath: folder/folder/fileC.md +sourcePath: 'folder/folder/fileC.md' --- # File C " @@ -205,8 +205,8 @@ exports[`Include toc Toc is included inline, not as a new section 7`] = ` exports[`Include toc Toc is included inline, not as a new section 8`] = ` "--- -title: File A -description: YFM description +title: 'File A' +description: 'YFM description' --- # File A @@ -233,7 +233,7 @@ Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, wh exports[`Include toc Toc is included inline, not as a new section 10`] = ` "--- -sourcePath: folder/folder/fileC.md +sourcePath: 'folder/folder/fileC.md' --- # File C " diff --git a/tests/e2e/__snapshots__/load-custom-resources.spec.ts.snap b/tests/e2e/__snapshots__/load-custom-resources.spec.ts.snap index 2cd2818b..a1b2e3da 100644 --- a/tests/e2e/__snapshots__/load-custom-resources.spec.ts.snap +++ b/tests/e2e/__snapshots__/load-custom-resources.spec.ts.snap @@ -474,12 +474,12 @@ links: exports[`Allow load custom resources md2md with custom resources 4`] = ` "--- metadata: - - name: yfm - content: builder + - name: 'yfm' + content: 'builder' style: - - _assets/style/test.css + - '_assets/style/test.css' script: - - _assets/script/test1.js + - '_assets/script/test1.js' --- Lorem @@ -489,9 +489,9 @@ Lorem exports[`Allow load custom resources md2md with custom resources 5`] = ` "--- style: - - _assets/style/test.css + - '_assets/style/test.css' script: - - _assets/script/test1.js + - '_assets/script/test1.js' --- Lorem" `; diff --git a/tests/e2e/__snapshots__/metadata.spec.ts.snap b/tests/e2e/__snapshots__/metadata.spec.ts.snap index 22e5d45f..524d985c 100644 --- a/tests/e2e/__snapshots__/metadata.spec.ts.snap +++ b/tests/e2e/__snapshots__/metadata.spec.ts.snap @@ -207,12 +207,12 @@ links: exports[`Allow load custom resources md2md with metadata 3`] = ` "--- metadata: - - name: yfm - content: builder in page - - name: test-yfm - content: inline test - - name: yfm-config - content: config test + - name: 'yfm' + content: 'builder in page' + - name: 'test-yfm' + content: 'inline test' + - name: 'yfm-config' + content: 'config test' --- Lorem" @@ -221,12 +221,12 @@ Lorem" exports[`Allow load custom resources md2md with metadata 4`] = ` "--- metadata: - - name: yfm - value: builder in config - - name: test-yfm - content: inline test - - name: yfm-config - content: config test + - name: 'yfm' + value: 'builder in config' + - name: 'test-yfm' + content: 'inline test' + - name: 'yfm-config' + content: 'config test' --- Lorem" diff --git a/tests/integrations/services/__snapshots__/liquidInFrontMatter.test.ts.snap b/tests/integrations/services/__snapshots__/liquidInFrontMatter.test.ts.snap index 9daa215b..a2d6f86b 100644 --- a/tests/integrations/services/__snapshots__/liquidInFrontMatter.test.ts.snap +++ b/tests/integrations/services/__snapshots__/liquidInFrontMatter.test.ts.snap @@ -11,10 +11,10 @@ exports[`Front matter (metadata) transformations do not break when a property ke exports[`Front matter (metadata) transformations do not break when a property key contains Liquid-style variable substitutions 2`] = ` "--- -prop-{{key-name}}: This one has a substitution in a key name. -{{key-name}}-prop: This one's key starts with a substitution. -{{key-name}}: This one's key only consists of a substitution. -{{ key-name }}: This one's key employs a different whitespace style in a substitution. +prop-{{key-name}}: 'This one has a substitution in a key name.' +{{key-name}}-prop: 'This one''s key starts with a substitution.' +{{key-name}}: 'This one''s key only consists of a substitution.' +{{ key-name }}: 'This one''s key employs a different whitespace style in a substitution.' --- Blah. " @@ -34,15 +34,13 @@ exports[`Front matter (metadata) transformations do not break when a property va exports[`Front matter (metadata) transformations do not break when a property value contains Liquid-style variable substitutions 2`] = ` "--- -prop1: This is a metadata property with a {{substitution}} in it. -prop2: This one contains {{multiple}} {{substitutions}}. -prop3: This one has {{substitutions}} of {{ different }} {{ styles}}. -prop4: >- - This one has a {{substitution}} as well, but the string literal is - single-quoted. -prop5: This one has no quotes at {{all}}. -prop6: {{this}} starts with a substitution. -prop7: {{this}} one is a multiline {{property}}. +prop1: 'This is a metadata property with a {{substitution}} in it.' +prop2: 'This one contains {{multiple}} {{substitutions}}.' +prop3: 'This one has {{substitutions}} of {{ different }} {{ styles}}.' +prop4: 'This one has a {{substitution}} as well, but the string literal is single-quoted.' +prop5: 'This one has no quotes at {{all}}.' +prop6: '{{this}} starts with a substitution.' +prop7: '{{this}} one is a multiline {{property}}.' --- Blah. "