JuliaWeb / Hyperscript.jl

Hyperscript: A lightweight DOM representation for Julia
Other
101 stars 11 forks source link

display to text/plain #28

Closed clarkevans closed 3 years ago

clarkevans commented 3 years ago

"As a rule of thumb, the single-line show method should print a valid Julia expression for creating the shown object." One suggestion is to use PrettyPrinting.jl to replicate the code tree you'd need to re-generate the object. Alternatively, perhaps there is a function that would take the rendered output and re-construct the node? e.g. Node("<span>hello</span>") might be the show for span("hello"), then this Node constructor could return the same object as would be created by @tags; span("hello")? I'm asking this because when I show Hyperscript objects within a larger structure, I get something that isn't a valid constructor, and hence it violates the rule of thumb above.

schneiderfelipe commented 3 years ago

@clarkevans Although I understand what you mean, I think having HTML being rendered directly in the terminal is simply too convenient (I would argue, more so than reproducible Julia code in the case of Hyperscript.jl). Similar things are done in the standard library by, e.g., Markdown.jl,

julia> using Markdown

julia> md"""
       # Hello world

       I'm a **paragraph**.
       """
  Hello world
  ≡≡≡≡≡≡≡≡≡≡≡≡≡

  I'm a paragraph.