 
 (defn left-justify-text [s width]
   (let [n-ws (- width (count s))]
+   (apply str (concat s (repeat n-ws " ")))))
+
+(defn center-markup [s width]
+  (let [n-ws-left (int (/ (- width (markup-length s)) 2))
+        n-ws-right (int (+ 0.5 (/ (- width (markup-length s)) 2)))]
+   (apply str (concat (repeat n-ws-left " ") s (repeat n-ws-right " ")))))
+
+(defn left-justify-markup [s width]
+  (let [n-ws (- width (markup-length s))]
    (apply str (concat s (repeat n-ws " ")))))
 
 (defn render-line

                   #{:underline}
                   #{})]
    #_(log/info "put-string" (format "\"%s\"" line) "width" width)
    (put-string screen x y s fg bg style)))


(defn render-rect-border

  ([s]
   (str->chars s :white :black))
  ([s fg bg]
   (str->chars s fg bg #{}))
  ([s fg bg style]
   (map (fn [c] {:c c :fg fg :bg bg :style style})
        s)))

(defn markup->chars
  ([x y s]
   (markup->chars x y s :white :black))
  ([x y s fg bg]
   (markup->chars x y s fg bg #{}))
  ([x y s fg bg style]
   (if (re-find #"^\s*$" s)
     (map (fn [idx] {:c     " "
                     :x     (+ x idx)
                     :y     y
                     :fg    (color->rgb fg)
                     :bg    (color->rgb bg)
                     :style style})
          (range (count s)))
     (let [body    (str "<body>" s "</body>")
           z       (zip-str body)
           content (-> z zip/node :content)
           characters
       (map-indexed (fn [idx c] (assoc c :c     (str (get c :c))
                                         :x     (+ x idx)
                                         :y     y
                                         :fg    (color->rgb (get c :fg))
                                         :bg    (color->rgb (get c :bg))
                                         :style style))
                    (reduce (fn [characters v]
                              (cond
                                (string? v)
                                  (concat characters
                                          (str->chars v fg bg style))
                                (map? v)
                                  (concat characters
                                          (str->chars (-> v :content first)
                                                      (if (= (get v :tag) :color)
                                                        (keyword (get-in v [:attrs :fg] fg))
                                                        fg)
                                                      (if (= (get v :tag) :color)
                                                        (keyword (get-in v [:attrs :bg] bg))
                                                        bg)))))
                            []
                            content))]
      characters))))

(defn put-string
  ([^robinson.aterminal.ATerminal screen x y string]
