Skip to content

Formatting

Jude Payne edited this page Dec 31, 2022 · 3 revisions

The dictim.format namespace exposes one public function, fmt which will clean up and re-format a d2 string.

user=> (use 'dictim.format)
nil
user=> (println d2-messy)
family1: The Jones' {
style:  {   fill: red;
  }; personA: Henrick
personB: Michael
     personA -- personB:   brothers;}
nil
user=> (println (fmt d2-messy))
family1: The Jones' {
  style:  {
     fill: red
  }
  personA: Henrick
  personB: Michael
  personA -- personB: brothers
}
nil

fmt can take one keyword argument :tab to set the number of spaces used for an indentation step. The default is 2.

The fmt fuunction is invoked by default on d2 compiled from dicitm.

Clone this wiki locally