From 2431dd193e2098531745835a33c13f64be45309a Mon Sep 17 00:00:00 2001 From: patzick <13100280+patzick@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:06:10 +0100 Subject: [PATCH 1/3] fix: trim content in file generator --- docs/2.generators/file.md | 1 - src/generators/file.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/2.generators/file.md b/docs/2.generators/file.md index 64dcf29..468ef9d 100644 --- a/docs/2.generators/file.md +++ b/docs/2.generators/file.md @@ -40,7 +40,6 @@ The `file` generator reads a file and inlines it's contents. subkey: "value", }, }; - ``` diff --git a/src/generators/file.ts b/src/generators/file.ts index a0870f8..3cc1f5a 100644 --- a/src/generators/file.ts +++ b/src/generators/file.ts @@ -9,6 +9,7 @@ export const file = defineGenerator({ async generate({ args, config, url }) { const fullPath = resolvePath(args.src, { url, dir: config.dir }); let contents = await readFile(fullPath, "utf8"); + contents = contents.trim(); if (args.code) { contents = md.codeBlock( From 932d4b1fe86fb09d8fe8142a9c703535cb0063c1 Mon Sep 17 00:00:00 2001 From: patzick <13100280+patzick@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:30:11 +0100 Subject: [PATCH 2/3] feat: add noTrim flag --- docs/2.generators/file.md | 2 ++ src/generators/file.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/2.generators/file.md b/docs/2.generators/file.md index 468ef9d..433775f 100644 --- a/docs/2.generators/file.md +++ b/docs/2.generators/file.md @@ -66,4 +66,6 @@ Code lang. File name in code. Use `no-name` to disable name in code. :: +::field{name="noTrim" type="boolean"} +Don't trim the file contents. :: diff --git a/src/generators/file.ts b/src/generators/file.ts index 3cc1f5a..966239d 100644 --- a/src/generators/file.ts +++ b/src/generators/file.ts @@ -9,7 +9,9 @@ export const file = defineGenerator({ async generate({ args, config, url }) { const fullPath = resolvePath(args.src, { url, dir: config.dir }); let contents = await readFile(fullPath, "utf8"); - contents = contents.trim(); + if (!args.noTrim) { + contents = contents.trim(); + } if (args.code) { contents = md.codeBlock( From e5b1b42b4ac78db2dc971b3237b0ac92b31f5547 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:28:30 +0000 Subject: [PATCH 3/3] chore: apply automated fixes --- docs/2.generators/file.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/2.generators/file.md b/docs/2.generators/file.md index 433775f..b43f59e 100644 --- a/docs/2.generators/file.md +++ b/docs/2.generators/file.md @@ -40,6 +40,7 @@ The `file` generator reads a file and inlines it's contents. subkey: "value", }, }; + ```