JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

Move closing `>`s to previous lines. #172

Closed MichaelHatherly closed 2 years ago

MichaelHatherly commented 2 years ago

Noticed when trying out https://github.com/MichaelHatherly/CommonMark.jl/issues/31.

Some of the formatting of closing >s for the HTML tags put them on their own lines. The commonmark spec doesn't really like this, and instead parses the dangling > as the start of a quote block, which leaves the preceding HTML as raw text. This is pretty reasonable for the spec to do since markdown syntax has precedence over embedded HTML. All this PR does is move those >s to the previous line and things work out nicely.

Another more global change could be to have @htl do some minifying and strip out white space characters from it's output such that the user doesn't have to care about the white space sensitivity of embedded HTML in markdown.

github-actions[bot] commented 2 years ago

Try this Pull Request!

Open Julia and type:

  julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/MichaelHatherly/PlutoUI.jl", rev="mh/md+htl")
julia> using PlutoUI

Or run this code in your browser: Run with binder

MichaelHatherly commented 2 years ago

Here's a link to how the reference implementation handles these kind of inputs: https://spec.commonmark.org/dingus/?text=%3Cinput%0A%3E

fonsp commented 2 years ago

Thanks! Let's make this change, but we also need to get rid of the whitespace, because of a 'bug' in pluto that displays all whitespace inside the data viewer:

[Slider(1:10), TextField()]

A minifying step seems like a bit much right now in Julia, I would be worried that the implementation is not well tested (but perhaps it can be done with HyperScript.jl?), so let's just sacrifice readabilty in our code for now :)

MichaelHatherly commented 2 years ago

A minifying step seems like a bit much right now in Julia, I would be worried that the implementation is not well tested (but perhaps it can be done with HyperScript.jl?), so let's just sacrifice readabilty in our code for now :)

Yeah, sounds like a reasonable route for now. The whitespace issue might not actually be much of a problem in practice hopefully :crossed_fingers:

fonsp commented 2 years ago

I don't think anyone really noticed no