mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -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))
|
"skewX" (apply gmt/skew-matrix (format-skew-x-params params))
|
||||||
"skewY" (apply gmt/skew-matrix (format-skew-y-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
|
(defn parse-transform
|
||||||
[transform]
|
[transform]
|
||||||
(if (string? transform)
|
(if (string? transform)
|
||||||
(->> (re-seq matrices-regex transform)
|
(->> (re-seq matrices-regex transform)
|
||||||
(map (fn [[_ type params]]
|
(map (fn [[_ type params]]
|
||||||
(let [params (->> (re-seq number-regex params)
|
(let [params (parse-numbers params)]
|
||||||
(map first)
|
|
||||||
(keep not-empty)
|
|
||||||
(map d/parse-double))]
|
|
||||||
(to-matrix type params))))
|
(to-matrix type params))))
|
||||||
(reduce gmt/multiply (gmt/matrix)))
|
(reduce gmt/multiply (gmt/matrix)))
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,7 @@
|
||||||
viewbox (or (:viewBox attrs)
|
viewbox (or (:viewBox attrs)
|
||||||
(dm/str "0 0 " width " " height))
|
(dm/str "0 0 " width " " height))
|
||||||
|
|
||||||
[x y width height] (->> (str/split viewbox #"[\s,]+")
|
[x y width height] (csvg/parse-numbers viewbox)
|
||||||
(map d/parse-double))
|
|
||||||
|
|
||||||
width (if (= width 0) 1 width)
|
width (if (= width 0) 1 width)
|
||||||
height (if (= height 0) 1 height)]
|
height (if (= height 0) 1 height)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue