Public
Edited
Apr 21, 2023
Paused
Importers
20 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
markLines(exampleText, [1, 2], 'js')
Insert cell
Insert cell
markLines(exampleText, [1, 2], { language: 'js', span: true})
Insert cell
Insert cell
Insert cell
markRanges(exampleText, [[16, 26], [57, 92]], 'js')
Insert cell
Insert cell
markRanges(exampleText, [[16, 26, '#FDF'], [57, 92, '#CFC']], {
language: 'js',
wrap: (contents, color) => html`<mark style="background:${color}">${contents}`
})
Insert cell
Insert cell
markMatches(exampleText, /\([^()]*\)/g, 'js')
Insert cell
Insert cell
Insert cell
{
const styleInitial = 'box-shadow: none; border-radius: 4px; padding: 2px; background: none; transition: all 500ms';
const styleActive = 'background: #ff0; box-shadow: 0 2px 5px -1px #550a';
const lines = [];
// Data equals the current line number.
const wrap = (contents, data) => {
const node = html`<mark style="${styleInitial}">${contents}`;
node.index = data;
lines.push(node);
return node;
};
const block = markLines(exampleText, true, {wrap, language: 'js'});
lines.sort((a, b) => a.index - b.index);
let n = -1;
while(true) {
if(lines[n]) lines[n].style.cssText += styleInitial;
n = (n + 1) % lines.length;
lines[n].style.cssText += styleActive;
yield block;
await Promises.delay(1000);
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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