11# Multi-line String Auto Indent
22
3+ [ ![ made-with-rust] [ rust-logo ]] [ rust-src-page ]
4+ [ ![ crates.io] [ crates-badge ]] [ crates-page ]
5+ [ ![ Documentation] [ docs-badge ]] [ docs-page ]
6+ [ ![ MIT licensed] [ license-badge ]] [ license-page ]
7+
8+
9+ | OS | Status |
10+ | ---------------| --------------------------------------------------------------------------------------|
11+ | Ubuntu-latest | [ ![ Ubuntu Tests] [ ubuntu-latest-badge ]] [ ubuntu-latest-workflow ] |
12+ | macOS-latest | [ ![ macOS Tests] [ macos-latest-badge ]] [ macos-latest-workflow ] |
13+ | Windows-latest| [ ![ Windows Tests] [ windows-latest-badge ]] [ windows-latest-workflow ] |
14+
15+
316A Rust utility for automatically normalizing multi-line string indentation while preserving platform-specific line endings.
417
518## Overview
@@ -14,12 +27,11 @@ When working with multi-line strings inside indented code blocks, unwanted leadi
1427cargo install string-auto-indent
1528```
1629
17- ## Example
30+ ## Usage
1831
1932``` rust
2033use string_auto_indent :: {auto_indent, LineEnding };
2134
22- println! ("" );
2335let text = r # "
2436 String Auto Indent
2537
@@ -28,23 +40,46 @@ let text = r#"
2840 Level 3
2941" # ;
3042
43+ // For cross-platform testing
3144let line_ending = LineEnding :: detect (text );
3245
3346// With auto-indent
3447assert_eq! (
3548 auto_indent (text ),
36- // Restore platform-specific line endings for testing
49+ // For cross-platform testing: Restore platform-specific line endings
3750 line_ending . restore (" String Auto Indent\ n\ n Level 1\ n Level 2\ n Level 3\ n" )
3851);
3952
4053// Without auto-indent
4154assert_eq! (
4255 text ,
43- // Restore platform-specific line endings for testing
56+ // For cross-platform testing: Restore platform-specific line endings
4457 line_ending . restore (" \ n String Auto Indent\ n\ n Level 1\ n Level 2\ n Level 3\ n" ),
4558);
4659```
4760
61+ ### Example Output
62+
63+ ** With ` auto-indent ` enabled.**
64+
65+ ``` text
66+ String Auto Indent
67+
68+ Level 1
69+ Level 2
70+ Level 3
71+ ```
72+
73+ ** With ` auto-intent ` disabled.**
74+
75+ ``` text
76+ String Auto Indent
77+
78+ Level 1
79+ Level 2
80+ Level 3
81+ ```
82+
4883## How It Works
4984
50851 . Detects the platform’s line endings (` \n ` , ` \r\n ` , ` \r ` ) and normalizes input for processing.
@@ -62,5 +97,23 @@ assert_eq!(
6297## License
6398Licensed under ** MIT** . See [ ` LICENSE ` ] [ license-page ] for details.
6499
65- [ license-page ] : https://github.com/jzombie/rust-cargo-pkg-info-struct-builder/blob/main/LICENSE
100+ [ rust-src-page ] : https://www.rust-lang.org/
101+ [ rust-logo ] : https://img.shields.io/badge/Made%20with-Rust-black?&logo=Rust
102+
103+ [ crates-page ] : https://crates.io/crates/string-auto-indent
104+ [ crates-badge ] : https://img.shields.io/crates/v/string-auto-indent.svg
105+
106+ [ docs-page ] : https://docs.rs/string-auto-indent
107+ [ docs-badge ] : https://docs.rs/string-auto-indent/badge.svg
108+
109+ [ license-page ] : https://github.com/jzombie/rust-string-auto-indent/blob/main/LICENSE
66110[ license-badge ] : https://img.shields.io/badge/license-MIT-blue.svg
111+
112+ [ ubuntu-latest-badge ] : https://github.com/jzombie/rust-string-auto-indent/actions/workflows/rust-tests.yml/badge.svg?branch=main&job=Run%20Rust%20Tests%20(OS%20=%20ubuntu-latest)
113+ [ ubuntu-latest-workflow ] : https://github.com/jzombie/rust-string-auto-indent/actions/workflows/rust-tests.yml?query=branch%3Amain
114+
115+ [ macos-latest-badge ] : https://github.com/jzombie/rust-string-auto-indent/actions/workflows/rust-tests.yml/badge.svg?branch=main&job=Run%20Rust%20Tests%20(OS%20=%20macos-latest)
116+ [ macos-latest-workflow ] : https://github.com/jzombie/rust-string-auto-indent/actions/workflows/rust-tests.yml?query=branch%3Amain
117+
118+ [ windows-latest-badge ] : https://github.com/jzombie/rust-string-auto-indent/actions/workflows/rust-tests.yml/badge.svg?branch=main&job=Run%20Rust%20Tests%20(OS%20=%20windows-latest)
119+ [ windows-latest-workflow ] : https://github.com/jzombie/rust-string-auto-indent/actions/workflows/rust-tests.yml?query=branch%3Amain
0 commit comments