Linecove
A cove is the inward corner of a text highlight, where a shorter line steps in from a longer one. Customize the color and radius. Try it out below.
without rounding
with rounding
String whereYouBelong(You you)
{
if (you.feelsFree())
{
return "wildflowers";
}
else if (you.sailsAway())
return "out at sea";
else
return "somewhere free";
}
You belong among the wildflowers
You belong in a boat out at sea
Sail away, kill off the hours
You belong somewhere you feel free
Run away, find you a lover
Go away somewhere all bright and new
I have seen no other
Who compares with you
Installation
The package is ESM and includes TypeScript types. It has no runtime dependencies.
npm install linecoveUsage
Attach it to an element. The browser selection stays in place, so copy and paste still work.
Inside that element, the native highlight is hidden and Linecove draws the rounded shape instead.
Call destroy() when the element goes away.
import { attachLiveSelection } from "linecove";
const article = document.querySelector("article");
if (!article) throw new Error("Missing article");
const highlight = attachLiveSelection(article, {
radius: 6,
paddingInline: 1,
});