clojure - 如何在 HTML 中漂亮地打印 Clojure 数据结构?

标签 clojure clojurescript reagent hiccup

如何使以下代码生成与 HTML 中的 pprint 类似的可视化效果?

(let [clj-structure {:ui {:selected #{[:A 3]}}                                                                                       
                           :domain                                                                                                         
                           {:C {0 {:value 12}}                                                                                             
                            :D {0 {:dependants [[:C 0]] :string "3" :value "3"}                                                            
                                1 {:dependants [[:C 0]] :string "4" :value "4"}}                                                           
                            :E {2 {:dependants [] :string "2" :value "2"}                                                                  
                                3 {:dependants [] :string "10" :value "10"}}}}]                                                            
        [:p (str clj-structure)])

最佳答案

(let [clj-structure {:ui {:selected #{[:A 3]}}                                                                                       
                           :domain                                                                                                         
                           {:C {0 {:value 12}}                                                                                             
                            :D {0 {:dependants [[:C 0]] :string "3" :value "3"}                                                            
                                1 {:dependants [[:C 0]] :string "4" :value "4"}}                                                           
                            :E {2 {:dependants [] :string "2" :value "2"}                                                                  
                                3 {:dependants [] :string "10" :value "10"}}}}]                                                            
        [:pre (with-out-str (cljs.pprint/pprint clj-structure))])

enter image description here

关于clojure - 如何在 HTML 中漂亮地打印 Clojure 数据结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65834562/

相关文章:

java - 从 Java 调用 clojure (Clojure Interop)

ruby - 你会如何用 Ruby 和/或 Haskell 编写这个 Clojure 片段?

clojure - 升级 ClojureScript 最简单的方法是什么?

clojure - 使用 lein 从 cljc 文件编译 ClojureScript

electron - Clojurescript:如何使 Web 应用程序版本与桌面 Electron 版本共存

json - 如何解码,然后格式化,标记的 LocalDateTime 值

clojure - clojure 中# 和 % 的名称是什么?

clojure - 使用 core.async 进行测试 - 在测试中刷新 go block ?

clojure - 试剂中的交互式列表

clojure - 为什么Clojure中的 "use"会调用 "in-ns"返回原来的命名空间?