To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

This notebook takes about 20 seconds to run.

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
👀 Reading hidden code
Enter cell code...
67.8 μs
Wowie!
👀 Reading hidden code
wowie = html"""
<h5>Wowie!</h5>
"""
29.9 μs
👀 Reading hidden code
"""
h5 {
color: pink;
}
"""
)
13.4 μs
👀 Reading hidden code
scoped_css2(embed_display([1,2]),
"""
h5 {
color: pink;
}
"""
)
17.0 ms
scoped_css2 (generic function with 1 method)
function scoped_css2(x, style)
# html_code = repr(MIME"text/html"(), x)
@htl("""
<pl-css-scoper>
<template shadowroot="open">
<style>
$(style)
</style>
$(x)
</template>
</pl-css-scoper>

""")
end
👀 Reading hidden code
496 ms
Error message

syntax: incomplete: "function" at /home/runner/work/disorganised-mess/disorganised-mess/scoped_css.jl#==#db1220d3-457c-4226-843d-5d1e82e593fd:1 requires end

Computers are hard!
function scoped_css2()
html"""



"""
👀 Reading hidden code
---
#= html"""

<host-element>
<template shadowroot="open">
<style>
::slotted {
background:green !important;
}
</style>
<h2>Shadow Content (visible if in shadow root)</h2>
<slot></slot>
</template>
<style>
h2 {
background: red;
}
</style>
<h2>Light DOM content (green if slotted)</h2>
</host-element>



""" =#
👀 Reading hidden code
9.9 μs

asdf

html"""
<h2>asdf</h2>

"""
👀 Reading hidden code
119 μs
#= html"""

<host-element>
<template shadowroot="open">
<style>
::slotted(h2), h2 {
background:green !important;
}
</style>
<h2>Shadow Content (visible if in shadow root)</h2>
<slot></slot>
</template>
<style>
h2 {
background: red;
}
</style>
<h2>Light DOM content (green if slotted)</h2>
</host-element>



""" =#
👀 Reading hidden code
8.6 μs
using HypertextLiteral
👀 Reading hidden code
26.3 ms
html"""
<html>
<h1>Hello Shadow DOM</h1>
</html>
"""
👀 Reading hidden code
111 μs

Hello Shadow DOM

html"""
<h1>Hello Shadow DOM</h1>
"""
👀 Reading hidden code
110 μs
scoped_css (generic function with 1 method)
isolated_css = scoped_css
👀 Reading hidden code
11.1 μs
isolated_css(@htl("""
<script>alert("123")</script>
<h1>Hello Shadow DOM</h1>
$(embed_display([1,2,3]))
"""),"""

h1 {
color: pink;
}

""")
👀 Reading hidden code
Deprecated, use `AbstractPlutoDingetjes.Display.published_to_js(x)` instead of `PlutoRunner.publish_to_js(x)`.
Deprecated, use `AbstractPlutoDingetjes.Display.published_to_js(x)` instead of `PlutoRunner.publish_to_js(x)`.
1.9 s
scoped_css(html"<h1>Hello Shadow DOM</h1>","""

h1 {
color: pink;
}

""")
👀 Reading hidden code
Deprecated, use `AbstractPlutoDingetjes.Display.published_to_js(x)` instead of `PlutoRunner.publish_to_js(x)`.
Deprecated, use `AbstractPlutoDingetjes.Display.published_to_js(x)` instead of `PlutoRunner.publish_to_js(x)`.
482 μs
scoped_css (generic function with 1 method)
function scoped_css(x, style)
html_code = repr(MIME"text/html"(), x)
@htl("""
<script>
const css_code = $(PlutoRunner.publish_to_js(style))
const html_code = $(PlutoRunner.publish_to_js(html_code))
const host = document.createElement("span")
const shadowRoot = host.attachShadow({mode: 'open'});
shadowRoot.innerHTML = `<style>\${css_code}</style><pluto-output>\${html_code}</pluto-output>`;
return host
</script>
""")
end
👀 Reading hidden code
830 μs

👀 Reading hidden code
66.9 μs