Skip to content

Commit 10ed354

Browse files
author
Yannick Scherer
committed
adjust printing of nodes.
1 parent 36047e2 commit 10ed354

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/rewrite_clj/node/protocols.clj

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,20 @@
7979

8080
(defn node->string
8181
[node]
82-
(str (if (printable-only? node)
83-
(pr-str (string node))
84-
(string node))
85-
(if (inner? node)
86-
(->> (children node)
87-
(map pr-str)
88-
(string/join ", ")
89-
(format ", children:[%s]"))
90-
"")))
82+
(let [n (str (if (printable-only? node)
83+
(pr-str (string node))
84+
(string node)))
85+
n' (if (re-find #"\n" n)
86+
(->> (string/replace n #"\r?\n" "\n ")
87+
(format "%n %s%n"))
88+
(str " " n))]
89+
(format "<%s:%s>" (name (tag node)) n')))
9190

9291
(defmacro make-printable!
9392
[class]
9493
`(defmethod print-method ~class
9594
[node# w#]
96-
(->> (str "<"
97-
(name (tag node#))
98-
" "
99-
(node->string node#)
100-
">")
101-
(.write w#))))
95+
(.write w# (node->string node#))))
10296

10397
;; ## Helpers
10498

0 commit comments

Comments
 (0)