Replies: 4 comments 1 reply
-
An interesting idea, and one that came up many years ago. I didn't pursue it because, unlike most programmers these days, I don't spend my days writing code that eventually shows up in a browser -- so I don't know what the correct output would look like. I spent some time looking at some peoples html for code, and it was all over the map, or at least that is my memory. I'm interested in your use case for the hiccup or html output. You have sketched in some ideas on how to pursue this, above, and maybe that is all I would need. But I expect that to make this move forward it would take a good bit of back and forth to it to work. I think there are a few things that are needed before I jump into this:
I'm open to pursuing this (modulo some sense of how useful this might be to people), and I'm willing to try to figure out the code, but I'm not willing to go it alone. It is worth knowing that I'm not positive if this is even possible given the current architecture of zprint, though I expect that it is. There is an intermediate format for the output that is currently post-processed into the ANSI format, and it would probably be possible post-process it into a variety of other output formats pretty easily. Anyway, let me know how your thoughts, and we'll see where we go from there. If you don't hear back from me quickly, it will be because of the holidays. |
Beta Was this translation helpful? Give feedback.
-
My apologies for letting this slide for so long. I'm still getting my head around "discussions", and I lost track of this because it wasn't an "issue". I didn't even see the "Create issue from discussion" button before. Sigh. So, on closer examination, it looks like you have largely (or completely?) implemented the To be painfully clear, the problem I have is that I'm not particularly familiar with either What are you thinking for actual html output? Are you thinking of using hiccup directly to turn the Anyway, let me know how you were thinking to produce html, and I'll see about hacking what you've done into zprint as a feasibility test. |
Beta Was this translation helpful? Give feedback.
-
So, I've been experimenting with what you sketched in. I have something working, but I don't feel confident in the results. Here is what I'm testing with, at the REPL:
If I get it to generate
If I put that in a file and display it with Safari on my Mac, it looks fine. My questions:
Thanks! |
Beta Was this translation helpful? Give feedback.
-
So, I've been moving forward on this, and I've gotten the both |
Beta Was this translation helpful? Give feedback.
-
It would be cool to add hiccup and/or html output in addition to ANSI to czprint. For instance you could add ...
(s/def ::color-output-types #{:ansi :hiccup :html})
(s/def ::color-output ::color-output-types)
where ANSI is the default for backward compatibility with :color? switch, if the new :color-output is not defined.
converting color-str in ansi.cljc to a defmethod trio for ansi, hiccup and html.
(defn color-str
"Wraps a string with hiccup expressions."
[s & ansi]
(let [style-str (apply str (interpose ; (map html-codes ansi)))]
[:span {:style style-str} s]))
html-codes might look something like this
(def html-codes
{:bold "font-weight:bold"
:faint "opacity:50%"
:italic "font-style:italic",
:underline "text-decoration: underline"
:blink ""
:reverse ""
:hidden "display: none"
:strike "text-decoration: line-through"
:normal "text-decoration: none"
:italic-off "font-style:normal"
:underline-off "font-style:normal"
:blink-off ""
:reverse-off ""
:hidden-off "display: unset"
:strike-off "text-decoration: none"
:black "color:black"
; ....
})
Beta Was this translation helpful? Give feedback.
All reactions