Platform
Resources
Pricing
Sign in
Get started
Simon Willison
Workspace
Fork
Published
By
Simon Willison
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
,
'>'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/&/g
,
'&'
)
.
replace
(
/"/g
,
'"'
)
.
replace
(
/'/g
,
'''
)
;
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
url
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
results
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
search
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
highlight
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
html_escape
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sql
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML