Tcl Library Source Code

View Ticket
Login
Ticket UUID: 2bcc38cc1d93cff317a2ed7573d7eeb0e2991d9b
Title: huddle2yaml of yaml package doesn't preserve string indentation
Type: Bug Version: tcllib 1.21
Submitter: georgtree Created on: 2024-08-29 09:52:52
Subsystem: yaml Assigned To: nobody
Priority: 5 Medium Severity: Cosmetic
Status: Open Last Modified: 2024-08-29 09:52:52
Resolution: None Closed By: nobody
    Closed on:
Description:
Hello!
I found if I put code with indentation in a huddle string object, when I call huddle2yaml, the code indentation is lost. For example:
```
package require yaml
package require huddle
set huddleString [huddle string {proc find {{basedir .} {filterScript {}}} {
    set oldwd [pwd]
    cd $basedir
    set cwd [pwd]
    set filenames [glob -nocomplain * .*]
    set files {}
    set filt [string length $filterScript]
    foreach filename $filenames {
        if {!$filt || [eval $filterScript [list $filename]]} {
            lappend files [file join $cwd $filename]
        }
        if {[file isdirectory $filename]} {
            set files [concat $files [find $filename $filterScript]]
        }
    }
    cd $oldwd
    return $files
}
}]
puts [::yaml::huddle2yaml $huddleString 4 40]
```

It returns:

```
---
|
proc find {{basedir .} {filterScript {}}} {
set oldwd [pwd]
cd $basedir
set cwd [pwd]
set filenames [glob -nocomplain * .*]
set files {}
set filt [string length $filterScript]
foreach filename $filenames {
if {!$filt || [eval $filterScript [list $filename]]} {
lappend files [file join $cwd $filename]
}
if {[file isdirectory $filename]} {
set files [concat $files [find $filename $filterScript]]
}
}
cd $oldwd
return $files
}
```

Thank you in advance!