Published
Edited
Feb 9, 2021
3 stars
Insert cell
Insert cell
viewof textInput = textarea({width: "100%", rows: 4})
Insert cell
Insert cell
viewof height = text({placeholder: "Image height", value: 450})
Insert cell
viewof width = text({placeholder: "Image width", value: 253})
Insert cell
md`You can customize the template used here:`
Insert cell
viewof template = textarea({
value: `
<div class="slide">
<img alt="" height="{height}" src="{filename}" width="{width}">
<div>
<p>Words</p>
</div>
</div>
`, width: "100%", rows: 12})
Insert cell
filenames = textInput.split(/\s+/).filter(s => s)
Insert cell
sorted = filenames.sort((a, b) => numericComponent(a) - numericComponent(b));
Insert cell
function numericComponent(a) {
return parseInt(a.split(".")[0], 10);
}
Insert cell
import {textarea, text} from "@jashkenas/inputs"
Insert cell
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more