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
public void Repeat(int x)
{
if (x < 0)
{
x = x % width;
x = width + x;
}
else
x = x % width;
return x;
}
The river keeps the evening in its pocket.
It spends the light on stones,
then folds the dark along the bank.
Where the grass is still deciding
whether to be water,
a heron stands in the shallows
and does not choose.
By morning the pocket is empty.
The stones remember the light.
Installation
The package is ESM and includes TypeScript types. It has no runtime dependencies.
npm install linecove
Usage
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,
color: "#ADD6FF",
paddingInline: 1,
});