Skip to main content

dedent_multiline

Function dedent_multiline 

Source
fn dedent_multiline(raw: &str) -> String
Expand description

Apply multiline string dedenting to raw source content.

Given raw content that starts with a newline (multiline string detected by caller), this function:

  1. Strips the leading newline
  2. Strips the trailing line (newline + any whitespace before closing quote)
  3. Computes the common whitespace prefix across all non-empty lines
  4. Removes that prefix from the start of each line

ยงExample

Input (raw):  "\n        hello\n          world\n        "
After strip:  "        hello\n          world"
Common prefix: "        " (8 spaces)
Result:       "hello\n  world"