From acae3936cf223745f304db5ba5b35f7612bb09f2 Mon Sep 17 00:00:00 2001 From: Alberto Mengali Date: Sun, 8 Oct 2023 12:53:00 +0200 Subject: [PATCH] avoid skipping scripts with a specified id --- src/combine_htl/helpers.jl | 4 ++-- test/combinehtl_module.jl | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/combine_htl/helpers.jl b/src/combine_htl/helpers.jl index ab1881c..00a1080 100644 --- a/src/combine_htl/helpers.jl +++ b/src/combine_htl/helpers.jl @@ -53,8 +53,8 @@ shouldskip(p::ScriptContent, args...) = shouldskip(p.content, args...) shouldskip(::Any, args...) = (@nospecialize; return false) shouldskip(n::AbstractHTML, l::SingleDisplayLocation) = (@nospecialize; shouldskip(displaylocation(n), l)) -shouldskip(x::PlutoScript, ::InsidePluto) = shouldskip(x.body) && shouldskip(x.invalidation) && !hasreturn(x) -shouldskip(x::NormalScript, ::OutsidePluto) = shouldskip(x.body) && !hasreturn(x) +shouldskip(x::PlutoScript, ::InsidePluto) = shouldskip(x.body) && shouldskip(x.invalidation) && shouldskip(x.id) && !hasreturn(x) +shouldskip(x::NormalScript, ::OutsidePluto) = shouldskip(x.body) && shouldskip(x.id) && !hasreturn(x) shouldskip(n::NonScript{L}, ::L) where L <: SingleDisplayLocation = n.empty # Dual Script/Node shouldskip(d::Dual, l::SingleDisplayLocation) = shouldskip(inner_node(d, l), l) diff --git a/test/combinehtl_module.jl b/test/combinehtl_module.jl index 3a9f0a6..1536b63 100644 --- a/test/combinehtl_module.jl +++ b/test/combinehtl_module.jl @@ -226,6 +226,13 @@ end @test shouldskip(T("")) === true end + # We should not skip a script it is empty content but with an id + @test shouldskip(PlutoScript(""), InsidePluto()) == true + @test shouldskip(PlutoScript(""; id = "lol"), InsidePluto()) == false + @test shouldskip(NormalScript(""; id = "lol"), OutsidePluto()) == false + ds = DualScript(""; id = "lol") + @test shouldskip(ds, InsidePluto()) == shouldskip(ds, OutsidePluto()) == false + for l in (InsidePluto(), OutsidePluto()) @test haslisteners(make_script("asd"), l) === false end