 ;; w    -- int, width of output, in chars
 (defn harnify [code img w]
   (let [tokens (js->clj (js/esprima.tokenize code) :keywordize-keys true)
-        ts (map :value tokens)]
-    (comment apply str (interleave ts (repeat " ")))
+        ts (map token-to-text tokens)]
     (string/join "\n" (reverse (arrange-tokens ts img)))              ; img must be resized by now, no need in w
     ))
-    
 
 (let [code      "function skipComment() {
         var ch, start;

    (let [[line ts-rest] (arrange-tokens-line ts (first img))]
      (conj (arrange-tokens ts-rest (rest img)) line))))


;; Tries hard to make piece of code look like img
;; code -- string

;; Insert spaces between terms so they occupy exactly l chars
;; TODO: make spacing more even
(defn insert-spaces [terms l]
  (let [terms-interleaved terms ;; TODO: need better interleave that would work as string.join (without last space)
        spaces-needed (- l (apply + (map count terms-interleaved)))
        f (fn [terms _] (insert terms (inc (rand-int (- (count terms) 1))) " "))]
    (string/join (reduce f terms-interleaved (range spaces-needed)))))
