Published
Edited
Mar 11, 2021
Importers
2 stars
Insert cell
Insert cell
tweet`Hello, world! #twitter`
Insert cell
Insert cell
function tweet() {
const string = String.raw.apply(this, arguments).trim();
const length = twitter.parseTweet(string).weightedLength;
return html`<div style="font-family: var(--sans-serif);">
<p style="white-space: pre-wrap; min-height: 25px;">${twitter.autoLink(string, {usernameIncludeSymbol: true})}</p>
<p style="margin-top: -1em; font-size: 12px; color: ${length <= 280 ? "#999" : "#e7040f"};">${length} of 280 characters</p>
</div>`;
}
Insert cell
twitter = require("twitter-text@3.0/dist/twitter-text.js")
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