stathissideris / dali

dali is a Clojure library for representing, exporting and manipulating the SVG graphics format.
291 stars 16 forks source link

Bare :close in path drops following element #22

Open cursive-ide opened 3 years ago

cursive-ide commented 3 years ago

If I have the following path (trimmed for succinctness from a real one):

(dali/render-svg-string
  [:dali/page
   [:path
    :move-to
    [2.23828125 0.0]
    :line-to
    [2.23828125 -17.34375]
    :close
    :move-to
    [4.67578125 -8.75390625]
    :line-to
    [5.671875 -8.75390625]
    :close]])
=>
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
 <svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"15.671875\" height=\"10.0\"><path d=\"M 2.23828125 0.0 L 2.23828125 -17.34375 Z L 5.671875 -8.75390625 Z\"></path></svg>"

Notice how the generated path does not include the second :move-to. If I do the following, then it works:

(dali/render-svg-string
  [:dali/page
   [:path
    :move-to
    [2.23828125 0.0]
    :line-to
    [2.23828125 -17.34375]
    :close
    []
    :move-to
    [4.67578125 -8.75390625]
    :line-to
    [5.671875 -8.75390625]
    :close]])
=>
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
 <svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"15.671875\" height=\"10.0\"><path d=\"M 2.23828125 0.0 L 2.23828125 -17.34375 Z M 4.67578125 -8.75390625 L 5.671875 -8.75390625 Z\"></path></svg>"

Oddly, replacing the bare [] with nil doesn't work.