From ce1087b5a2182371e5b8e0593e59826fd05715eb Mon Sep 17 00:00:00 2001 From: Arne Roomann-Kurrik Date: Sat, 30 Aug 2025 14:22:22 -0700 Subject: [PATCH 1/2] fix: clean up readme --- .prettierrc.json | 1 + .vscode/settings.json | 2 +- README.md | 73 +++++++------------------------------------ 3 files changed, 13 insertions(+), 63 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 2644892..e220d75 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,6 +3,7 @@ "tabWidth": 2, "useTabs": false, "proseWrap": "preserve", + "embeddedLanguageFormatting": "off", "singleQuote": true, "trailingComma": "all" } diff --git a/.vscode/settings.json b/.vscode/settings.json index baa1dce..99f8d49 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,6 @@ "editor.defaultFormatter": "biomejs.biome" }, "[markdown]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "esbenp.prettier-vscode", } } diff --git a/README.md b/README.md index f686348..0b9c3fa 100644 --- a/README.md +++ b/README.md @@ -23,23 +23,10 @@ const result = cleanstring(` // Result: "Any literal\nwhich needs to be split\non multiple lines for readability." // Custom prefix example -const markdown = cleanstring( - ` - >This is a markdown quote - >with multiple lines -`, - { prefix: '>' }, -); -// Result: "This is a markdown quote\nwith multiple lines" - -// Custom prefix with trailing space example (note the prefix contains a space) -const markdown = cleanstring( - ` +const markdown = cleanstring(` > This is a markdown quote > with multiple lines -`, - { prefix: '> ' }, -); +`, { prefix: '> ' }); // Result: "This is a markdown quote\nwith multiple lines" ``` @@ -79,62 +66,22 @@ const sql = cleanstring(` ```typescript // Markdown quotes with > prefix -const quote = cleanstring( - ` - > This is a quote - > from someone famous -`, - { prefix: '>' }, -); -// Result: " This is a quote\n from someone famous" - -// Shell comments with # prefix -const script = cleanstring( - ` - # This is a shell script - # with multiple comment lines -`, - { prefix: '#' }, -); -// Result: " This is a shell script\n with multiple comment lines" - -// List items with * prefix -const list = cleanstring( - ` - * First item - * Second item - * Third item -`, - { prefix: '*' }, -); -// Result: " First item\n Second item\n Third item" +const quote = cleanstring(` + >This is a quote + >from someone famous +`, { prefix: '>' }); +// Result: "This is a quote\nfrom someone famous" ``` ### Multi-character prefixes for space stripping -If you want to strip a space after the prefix (reproducing the old behavior), include the space as part of the prefix: - ```typescript // Using "> " (greater than + space) strips the space after > -const cleanQuote = cleanstring( - ` +const cleanQuote = cleanstring(` > This is a quote > with multiple lines -`, - { prefix: '> ' }, -); +`, { prefix: '> ' }); // Result: "This is a quote\nwith multiple lines" - -// Using "| " (pipe + space) strips the space after | -const cleanCode = cleanstring( - ` - | function example() { - | return 'hello world'; - | } -`, - { prefix: '| ' }, -); -// Result: "function example() {\n return 'hello world';\n}" ``` ### Mixed content with prefix @@ -151,6 +98,8 @@ const script = cleanstring(` ### Without prefixes +Note that leading/trailing blank lines are still stripped. + ```typescript const text = cleanstring(` From 42ec6d782643f04f10cb4f35c85ce68bb2cac7ae Mon Sep 17 00:00:00 2001 From: Arne Roomann-Kurrik Date: Sat, 30 Aug 2025 14:23:03 -0700 Subject: [PATCH 2/2] fix: remove trailing comma --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 99f8d49..baa1dce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,6 @@ "editor.defaultFormatter": "biomejs.biome" }, "[markdown]": { - "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.defaultFormatter": "esbenp.prettier-vscode" } }