From c780f6dcd95fbf8931c7afc00499a8436075ae6c Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 10 Nov 2020 12:04:14 +0100 Subject: [PATCH 01/12] Update TagBot.yml --- .github/workflows/TagBot.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index d77d3a0..9151731 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -1,9 +1,12 @@ name: TagBot on: - schedule: - - cron: 0 * * * * + issue_comment: # THIS BIT IS NEW + types: + - created + workflow_dispatch: jobs: TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' runs-on: ubuntu-latest steps: - uses: JuliaRegistries/TagBot@v1 From 4a7b1faa6ebbb963428bed245457e2b37e70fdb1 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 22 Feb 2021 15:28:09 +0000 Subject: [PATCH 02/12] Use `show` instead of `repr`. Allows for passing `IOContext` through to underlying `show` methods for arbitary types embedded in the dom. --- src/Hyperscript.jl | 2 +- test/runtests.jl | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Hyperscript.jl b/src/Hyperscript.jl index 7e78464..eb4b195 100644 --- a/src/Hyperscript.jl +++ b/src/Hyperscript.jl @@ -238,7 +238,7 @@ renderdomchild(io, rctx::RenderContext, ctx, x::Nothing) = nothing # Render and escape other HTMLSVG children, including CSS nodes, in the parent context. # If a child is `showable` with text/html, render with that using `repr`. renderdomchild(io, rctx::RenderContext, ctx, x) = - showable(MIME("text/html"), x) ? print(io, repr(MIME("text/html"), x)) : printescaped(io, x, escapechild(ctx)) + showable(MIME("text/html"), x) ? show(io, MIME("text/html"), x) : printescaped(io, x, escapechild(ctx)) # All camelCase attribute names from HTML 4, HTML 5, SVG 1.1, SVG Tiny 1.2, and SVG 2 const HTML_SVG_CAMELS = Dict(lowercase(x) => x for x in [ diff --git a/test/runtests.jl b/test/runtests.jl index 5342fac..33da4f4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -278,3 +278,18 @@ import Hyperscript: px, em @test string(5 * (1px + 2em)) == "calc(5 * (1px + 2em))" @test string(5 * (1px + 3px + 4.3em)) == "calc(5 * (4px + 4.3em))" @test string(3.2 * (4.3em + 1px + 3px)) == "calc(3.2 * ((4.3em + 1px) + 3px))" + +# IOContext passthrough. +struct MyType +end +Base.show(io::IO, ::MIME"text/html", ::MyType) = print(io, get(io, :key, "")) + +let + io = IOBuffer() + show(io, MIME("text/html"), m("div")(MyType())) + @test String(take!(io)) == "
" + + ctx = IOContext(io, :key => "value") + show(ctx, MIME("text/html"), m("div")(MyType())) + @test String(take!(io)) == "
value
" +end From c59f46b799d21d2104ea97c12548c2802e404fc4 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 22 Feb 2021 15:29:46 +0000 Subject: [PATCH 03/12] Add gitignore Running `Pkg.test` was causing the repo to become dirty since it appears to edit the Project.toml when running and change stanza ordering. Manifest wasn't in gitignore so that's added too. --- .gitignore | 1 + Project.toml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1face5b..fae4405 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.jl.*.cov *.jl.mem .DS_Store +/Manifest.toml diff --git a/Project.toml b/Project.toml index 69bc634..3bfda6c 100644 --- a/Project.toml +++ b/Project.toml @@ -3,8 +3,8 @@ uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" author = ["Yuri Vishnevsky "] version = "0.0.4" -[compat] -julia = "1" - [deps] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +julia = "1" From 2988ff6bac2563c40827bc97be511940b57554ba Mon Sep 17 00:00:00 2001 From: "Felipe S. S. Schneider" <37125+schneiderfelipe@users.noreply.github.com> Date: Thu, 6 May 2021 17:55:29 -0300 Subject: [PATCH 04/12] Make flat accept AbstractArray --- src/Hyperscript.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperscript.jl b/src/Hyperscript.jl index eb4b195..b74d1e3 100644 --- a/src/Hyperscript.jl +++ b/src/Hyperscript.jl @@ -130,7 +130,7 @@ function processattrs(ctx, tag, attrs) ) end -function flat(xs::Union{Base.Generator, Tuple, Array}) +function flat(xs::Union{Base.Generator, Tuple, AbstractArray}) out = Any[] # Vector{Any} for node children and attribute values for x in xs append!(out, flat(x)) From 56a134a9b28fc2a9ac10dc096a19c6db0d9e4ff7 Mon Sep 17 00:00:00 2001 From: "Felipe S. S. Schneider" Date: Sat, 8 May 2021 09:46:59 -0300 Subject: [PATCH 05/12] Test flattening of AbstractArrays --- test/runtests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 33da4f4..6dd06f9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -90,6 +90,8 @@ end ## Generators, arrays, and tuples # Arrays are flattened @renders m("p", [1, 2, 3]) s`

123

` +# AbstractArrays are flattened +@renders m("p", BitArray([0, 1, 0])) s`

falsetruefalse

` # Generators are flattened @renders m("p", (x for x in 1:3)) s`

123

` # Tuples are flattened From 7108f4c38d69e2a6362161ac643eb0d61449a0a3 Mon Sep 17 00:00:00 2001 From: "Felipe S. S. Schneider" Date: Sat, 8 May 2021 09:48:54 -0300 Subject: [PATCH 06/12] Ensure AbstractRanges are not flattened --- src/Hyperscript.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Hyperscript.jl b/src/Hyperscript.jl index b74d1e3..598ee9c 100644 --- a/src/Hyperscript.jl +++ b/src/Hyperscript.jl @@ -138,6 +138,7 @@ function flat(xs::Union{Base.Generator, Tuple, AbstractArray}) out end flat(x) = (x,) +flat(x::AbstractRange) = (x,) ## Rendering From 08a39c2d59ac38190cc0943458463f38adabb8ea Mon Sep 17 00:00:00 2001 From: "Thomas A. Poulsen" Date: Tue, 22 Jun 2021 21:40:18 +0200 Subject: [PATCH 07/12] Add example of writing html-file --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index bf6027c..702f44a 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,34 @@ print(Pretty(node)) Note that the extra white space can affect layout, particularly in conjunction with CSS properties like [white-space](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space). +Vectors of nodes can be written as an html-file using the `savehtml` function. Here's an example: + +```julia +@tags head meta body h1 h2 ul li + +doc = [ + head( + meta(charset="UTF-8"), + ), + body( + [ + h1("My title"), + "Some text", + h2("A list"), + ul(li.(["First point", "Second Point"])) + ] ) +] +# 2-element Vector{Hyperscript.Node{Hyperscript.HTMLSVG}}: +# +#

My title

Some text

A list

  • First point
  • Second Point
+ +savehtml("/tmp/hyper.html", doc) ; + +# cat /tmp/hyper.html +# +#

My title

Some text

A list

  • First point
  • Second Point
+``` + ## CSS In addition to HTML and SVG, Hyperscript also supports CSS: From cb5932e360bc39b7a1529d99084eee5828e3bd1f Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 6 Oct 2021 23:42:01 +0200 Subject: [PATCH 08/12] Update cssunits.jl --- src/cssunits.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cssunits.jl b/src/cssunits.jl index b569995..f09add7 100644 --- a/src/cssunits.jl +++ b/src/cssunits.jl @@ -49,4 +49,5 @@ const vh = BareUnit{Unit{:vh}}() const vw = BareUnit{Unit{:vw}}() const vmin = BareUnit{Unit{:vmin}}() const vmax = BareUnit{Unit{:vmax}}() -const pc = BareUnit{Unit{Symbol("%")}}() \ No newline at end of file +const pc = BareUnit{Unit{Symbol("%")}}() +const fr = BareUnit{Unit{:fr}}() From 06fbf64a862931c4d38367b7697ac74e342adab5 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 6 Oct 2021 23:42:40 +0200 Subject: [PATCH 09/12] Update Hyperscript.jl --- src/Hyperscript.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperscript.jl b/src/Hyperscript.jl index 598ee9c..401219d 100644 --- a/src/Hyperscript.jl +++ b/src/Hyperscript.jl @@ -59,7 +59,7 @@ export @tags, @tags_noescape, m, css, Style, styles, render, Pretty, savehtml, s # Units include(joinpath(@__DIR__, "cssunits.jl")) -export px, pt, em, #= (this one conflicts with Base) rem, =# vh, vw, vmin, vmax, pc +export px, pt, em, #= (this one conflicts with Base) rem, =# vh, vw, vmin, vmax, pc, fr ## Basic definitions From dd58c43b3e6e48e5fb7fd4b831c87e50446da675 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Mon, 4 Apr 2022 12:53:56 +0200 Subject: [PATCH 10/12] Use `read` instead of `cat` --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 702f44a..ea29a29 100644 --- a/README.md +++ b/README.md @@ -124,14 +124,11 @@ doc = [ h2("A list"), ul(li.(["First point", "Second Point"])) ] ) -] -# 2-element Vector{Hyperscript.Node{Hyperscript.HTMLSVG}}: -# -#

My title

Some text

A list

  • First point
  • Second Point
+]; -savehtml("/tmp/hyper.html", doc) ; +savehtml("/tmp/hyper.html", doc); -# cat /tmp/hyper.html +read("/tmp/hyper.html", String) # #

My title

Some text

A list

  • First point
  • Second Point
``` From 5a54464d24cf2016caafaa2895228b15a6ac0973 Mon Sep 17 00:00:00 2001 From: Marius Fersigan Date: Wed, 22 Jun 2022 16:42:59 +0300 Subject: [PATCH 11/12] kebab function fix --- src/Hyperscript.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Hyperscript.jl b/src/Hyperscript.jl index 401219d..0ce9d13 100644 --- a/src/Hyperscript.jl +++ b/src/Hyperscript.jl @@ -179,8 +179,8 @@ printescaped(io::IO, x::AbstractChar, escapes) = printescaped(io, string(x), esc # allocation via sprint. future use: sprint(printescaped, x, escapes)) printescaped(io::IO, x, escapes) = printescaped(io, sprint(print, x), escapes) -# pass numbers through untrammelled -kebab(camel::String) = join(islowercase(c) || isnumeric(c) || c == '-' ? c : '-' * lowercase(c) for c in camel) +# pass numbers (and 1-character attributes) through untrammelled +kebab(camel::String) = length(camel) > 1 ? join(islowercase(c) || isnumeric(c) || c == '-' ? c : '-' * lowercase(c) for c in camel) : camel ## HTMLSVG From 21678c30d0f72a0833097488e6e9f98b0e9bd608 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 22 Nov 2023 15:54:33 +0100 Subject: [PATCH 12/12] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3bfda6c..03148ba 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Hyperscript" uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91" author = ["Yuri Vishnevsky "] -version = "0.0.4" +version = "0.0.5" [deps] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"