mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 07:11:32 -05:00
🐛 Add better fix for parsing svg-dimensions
That covers more corner cases
This commit is contained in:
parent
a2a61e99a7
commit
0e724ac821
2 changed files with 14 additions and 6 deletions
|
@ -800,15 +800,24 @@
|
|||
"skewX" (apply gmt/skew-matrix (format-skew-x-params params))
|
||||
"skewY" (apply gmt/skew-matrix (format-skew-y-params params))))
|
||||
|
||||
(def ^:private
|
||||
xf-parse-numbers
|
||||
(comp
|
||||
(map first)
|
||||
(keep not-empty)
|
||||
(map d/parse-double)))
|
||||
|
||||
(defn parse-numbers
|
||||
[data]
|
||||
(->> (re-seq number-regex data)
|
||||
(into [] xf-parse-numbers)))
|
||||
|
||||
(defn parse-transform
|
||||
[transform]
|
||||
(if (string? transform)
|
||||
(->> (re-seq matrices-regex transform)
|
||||
(map (fn [[_ type params]]
|
||||
(let [params (->> (re-seq number-regex params)
|
||||
(map first)
|
||||
(keep not-empty)
|
||||
(map d/parse-double))]
|
||||
(let [params (parse-numbers params)]
|
||||
(to-matrix type params))))
|
||||
(reduce gmt/multiply (gmt/matrix)))
|
||||
|
||||
|
|
|
@ -63,8 +63,7 @@
|
|||
viewbox (or (:viewBox attrs)
|
||||
(dm/str "0 0 " width " " height))
|
||||
|
||||
[x y width height] (->> (str/split viewbox #"[\s,]+")
|
||||
(map d/parse-double))
|
||||
[x y width height] (csvg/parse-numbers viewbox)
|
||||
|
||||
width (if (= width 0) 1 width)
|
||||
height (if (= height 0) 1 height)]
|
||||
|
|
Loading…
Add table
Reference in a new issue