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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more