From 1f05830540c4646045b5111f7a58c42c4a583661 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 20 Feb 2025 11:26:43 -0600 Subject: [PATCH 1/7] Fix typos --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9d536e0..e1eb7a6 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,8 @@ let text = r#" b. Sub point b 2. Point 2 a. Sub point a - b. Sub piont b - 1b. Sub piont 1b + b. Sub point b + 1b. Sub point 1b "#; // Expected output after applying auto indentation @@ -119,8 +119,8 @@ String Auto Indent b. Sub point b 2. Point 2 a. Sub point a - b. Sub piont b - 1b. Sub piont 1b + b. Sub point b + 1b. Sub point 1b "#; // Verify that `auto_indent` correctly normalizes indentation From 65386554b84353acdb857163720663b382c4db3a Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 20 Feb 2025 11:27:09 -0600 Subject: [PATCH 2/7] Bump to v0.1.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46072bb..d351a19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ dependencies = [ [[package]] name = "string-auto-indent" -version = "0.1.0" +version = "0.1.1" dependencies = [ "doc-comment", "line-ending", diff --git a/Cargo.toml b/Cargo.toml index 362fa90..3978c64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "string-auto-indent" -version = "0.1.0" +version = "0.1.1" authors = ["Jeremy Harris "] edition = "2021" description = "Normalizes multi-line string indentation while preserving platform-specific line endings." From f5159006fc47c051cf73366a6f41c75296c1bbf7 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 20 Feb 2025 11:29:01 -0600 Subject: [PATCH 3/7] `Install` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1eb7a6..40da511 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ When working with multi-line strings inside indented code blocks, unwanted leadi `string-auto-indent` provides an automated way to normalize multi-line strings without modifying the first line's indentation. -## Installation +## Install ```sh cargo add string-auto-indent From 7e85db31ad5495277255c201d4b1d82c47ba8ee8 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 20 Feb 2025 11:36:54 -0600 Subject: [PATCH 4/7] Add better example --- README.md | 109 ++++++++++++++---------------------------------------- 1 file changed, 27 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 40da511..abb3778 100644 --- a/README.md +++ b/README.md @@ -29,98 +29,43 @@ cargo add string-auto-indent ## Usage -## Example 1: Basic Indentation - -This example removes unnecessary leading spaces while preserving the relative indentation of nested lines. - ```rust use string_auto_indent::{auto_indent, LineEnding}; let text = r#" - String Auto Indent - - Level 1 - Level 2 - Level 3 - "#; - -// Expected output after applying auto indentation -let expected = r#" -String Auto Indent - -Level 1 - Level 2 - Level 3 -"#; - -// Verify that `auto_indent` correctly normalizes indentation -assert_eq!( - auto_indent(text), - expected, - "The auto_indent function should normalize leading whitespace." -); - -// Ensure the original text is not identical to the expected output -// This confirms that `auto_indent` actually modifies the string. -assert_ne!( - text, - expected, - "The original text should *not* be identical to the expected output before normalization." -); -``` - -### Example Output - -#### With `auto-indent` - -```text -String Auto Indent - -Level 1 - Level 2 - Level 3 -``` + Best Practices for Text Indentation + ----------------------------------- -#### Without `auto-intent` + 1. Importance of Proper Indentation + a. Enhances readability by clearly defining structure. + b. Prevents misinterpretation of hierarchical content. + c. Improves maintainability in collaborative environments. -```text - String Auto Indent - - Level 1 - Level 2 - Level 3 -``` - -## Example 2: Mixed Indentation - -This example demonstrates how `auto_indent` normalizes inconsistent indentation while preserving the relative structure of nested content. - -```rust -use string_auto_indent::{auto_indent, LineEnding}; - -let text = r#" - String Auto Indent + 2. Common Indentation Guidelines + a. Use consistent spacing (e.g., 2 or 4 spaces per level). + b. Avoid mixing spaces and tabs to ensure uniform formatting. + c. Align nested elements to maintain structural clarity. + 1b. Maintain relative indentation depth across all nested elements. + 2b. Ensure indentation reflects logical hierarchy. + "#; - 1. Point 1 - a. Sub point a - b. Sub point b - 2. Point 2 - a. Sub point a - b. Sub point b - 1b. Sub point 1b - "#; // Expected output after applying auto indentation let expected = r#" -String Auto Indent - - 1. Point 1 - a. Sub point a - b. Sub point b - 2. Point 2 - a. Sub point a - b. Sub point b - 1b. Sub point 1b +Best Practices for Text Indentation +----------------------------------- + + 1. Importance of Proper Indentation + a. Enhances readability by clearly defining structure. + b. Prevents misinterpretation of hierarchical content. + c. Improves maintainability in collaborative environments. + + 2. Common Indentation Guidelines + a. Use consistent spacing (e.g., 2 or 4 spaces per level). + b. Avoid mixing spaces and tabs to ensure uniform formatting. + c. Align nested elements to maintain structural clarity. + 1b. Maintain relative indentation depth across all nested elements. + 2b. Ensure indentation reflects logical hierarchy. "#; // Verify that `auto_indent` correctly normalizes indentation From b64ed8f7b7cd0d57adb6810da6d8055790f8e08b Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 20 Feb 2025 11:46:00 -0600 Subject: [PATCH 5/7] Refine example --- README.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index abb3778..6c3db7c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ cargo add string-auto-indent ```rust use string_auto_indent::{auto_indent, LineEnding}; -let text = r#" +let excessively_indented_text = r#" Best Practices for Text Indentation ----------------------------------- @@ -51,7 +51,7 @@ let text = r#" // Expected output after applying auto indentation -let expected = r#" +let normalized_indentation = r#" Best Practices for Text Indentation ----------------------------------- @@ -70,18 +70,10 @@ Best Practices for Text Indentation // Verify that `auto_indent` correctly normalizes indentation assert_eq!( - auto_indent(text), - expected, + auto_indent(excessively_indented_text), + normalized_indentation, "The auto_indent function should normalize leading whitespace." ); - -// Ensure the original text is not identical to the expected output -// This confirms that `auto_indent` actually modifies the string. -assert_ne!( - text, - expected, - "The original text should *not* be identical to the expected output before normalization." -); ``` ## How It Works From 22941ff6e182568a68eb2130f79312c4dfd7f21c Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 20 Feb 2025 11:47:59 -0600 Subject: [PATCH 6/7] Use package name in example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c3db7c..886dc9e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ let excessively_indented_text = r#" "#; -// Expected output after applying auto indentation +// Expected output after applying `auto-indent` let normalized_indentation = r#" Best Practices for Text Indentation ----------------------------------- From 46ce057af672ff5941930694c43ac306ef5fbce7 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 20 Feb 2025 11:49:01 -0600 Subject: [PATCH 7/7] Use correct function name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 886dc9e..b3aabde 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ let excessively_indented_text = r#" "#; -// Expected output after applying `auto-indent` +// Expected output after applying `auto_indent` let normalized_indentation = r#" Best Practices for Text Indentation -----------------------------------