Preserve leading spaces on string

I’d like to preserve the spaces in the strings below (before 222 and 333) such that 222 and 333 look indented as compared to 111, but I’m not sure how to accomplish this without doing a replace operation with &nbsp.

    New-UDButton -Text "Show Modal" -OnClick {
        Show-UDModal -Header {
            New-UDHeading -Size 3 -Text "Test Definition YAML"
        } -Content {
            new-udcard -endpoint {
                $lines = @("111", "  2222", "  333")
                foreach ($line in $lines) {
                    New-UDElement -Tag "div" -Content { "$line" }        
                }
            }
        }
    }

Hi @clr2of8,

Can you try with New-UDHTML instead?
If you want the “div” wrapping around the data, just manually add it.

New-UDHTML -Markup "<div>$($line)</div>"

Thank you @BoSen29, I ended up discovering that the pre tag preserves whites space, including new-lines, which is exactly what I needed.

New-UDElement -Tag pre -Content { $message }
1 Like