mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 12:28:54 -05:00
🐛 Fixes issue when parsing exponential numbers in paths
This commit is contained in:
parent
f0439da293
commit
b9ca4e7f9b
2 changed files with 12 additions and 10 deletions
|
@ -10,6 +10,7 @@
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
- Fixes problem with pan and space [#811](https://github.com/penpot/penpot/issues/811)
|
- Fixes problem with pan and space [#811](https://github.com/penpot/penpot/issues/811)
|
||||||
|
- Fixes issue when parsing exponential numbers in paths
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
(into [] (impl-simplify/simplify points tolerance true)))))
|
(into [] (impl-simplify/simplify points tolerance true)))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(def commands-regex #"(?i)[a-z][^a-z]*")
|
(def commands-regex #"(?i)[mzlhvcsqta][^mzlhvcsqta]*")
|
||||||
|
|
||||||
;; Matches numbers for path values allows values like... -.01, 10, +12.22
|
;; Matches numbers for path values allows values like... -.01, 10, +12.22
|
||||||
;; 0 and 1 are special because can refer to flags
|
;; 0 and 1 are special because can refer to flags
|
||||||
(def num-regex #"[+-]?(\d+(\.\d+)?|\.\d+)")
|
(def num-regex #"[+-]?(\d+(\.\d+)?|\.\d+)(e[+-]?\d+)?")
|
||||||
|
|
||||||
(def flag-regex #"[01]")
|
(def flag-regex #"[01]")
|
||||||
|
|
||||||
|
@ -370,14 +370,15 @@
|
||||||
(reduce simplify-command [[start] start-pos start-pos start-pos start-pos])
|
(reduce simplify-command [[start] start-pos start-pos start-pos start-pos])
|
||||||
(first))))
|
(first))))
|
||||||
|
|
||||||
(defn path->content [string]
|
(defn path->content [path-str]
|
||||||
(let [clean-string (-> string
|
(let [clean-path-str
|
||||||
(str/trim)
|
(-> path-str
|
||||||
;; Change "commas" for spaces
|
(str/trim)
|
||||||
(str/replace #"," " ")
|
;; Change "commas" for spaces
|
||||||
;; Remove all consecutive spaces
|
(str/replace #"," " ")
|
||||||
(str/replace #"\s+" " "))
|
;; Remove all consecutive spaces
|
||||||
commands (re-seq commands-regex clean-string)]
|
(str/replace #"\s+" " "))
|
||||||
|
commands (re-seq commands-regex clean-path-str)]
|
||||||
(-> (mapcat parse-command commands)
|
(-> (mapcat parse-command commands)
|
||||||
(simplify-commands))))
|
(simplify-commands))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue