Published
Edited
Dec 19, 2018
3 stars
Insert cell
Insert cell
url = (
"https://search-24ways.herokuapp.com/24ways.json?sql=" +
encodeURIComponent(sql) +
`&search=${encodeURIComponent(search)}&_shape=array`
);
Insert cell
Insert cell
Insert cell
html`
<h2>Results</h2>
${results.map(r => `
<h3><a href="${r.url}" target="_blank">${r.title}</a></h3>
<p><small>${r.author} - ${r.year}</small></p>
<p>${highlight(r.snippet)}</p>
`)}

`
Insert cell
function highlight(s) {
s = html_escape(s);
return s.replace(
/b4de2a49c8/g, '<b>'
).replace(
/8c94a2ed4b/g, '</b>'
);
}
Insert cell
html_escape = (s) => s.replace(
/>/g, '&gt;'
).replace(
/</g, '&lt;'
).replace(
/&/g, '&amp;'
).replace(
/"/g, '&quot;'
).replace(
/'/g, '&#039;'
);
Insert cell
Insert cell
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