On 2/8/2026 7:34 AM, Max Chernoff via ntg-context wrote:
Hi all,
I would like to place a coloured background around some text that may
potentially be broken across multiple lines, and I would like for this
background to have rounded corners. I tried using "textbackground"s with
"location=text" and "corner=round", but this doesn't give the results
that I would expect when the highlighted text is shorter than a single
line.
With "backgroundoffset=0pt", the bottom-left corner of the first line
and the top-right corner aren't properly rounded; with
"backgroundoffset!=0pt", the two separate backgrounds are connected
between the lines of the unhighlighted text.
I'm using the latest version (2026.01.08 23:30), and I get the same
results with MkIV and LMTX. Demonstration:
%% Define the text background
\definecolor[transparent][s=1, t=0, a=1]
\definetextbackground[bg][
location=text,
backgroundoffset=0.5ex, %% Optional
corner=round,
radius=1.8ex,
%% "corner=round" doesn't work with "frame=off", so use an
%% invisible frame instead
rulethickness=1sp,
framecolor=transparent,
]
\define[1]\bg{\starttextbackground[bg]#1\stoptextbackground}
%% Demonstration
\define[1]\filler{\dorecurse{#1}{ filler }}
\setuppapersize[A8, landscape]
\setupheadertexts[]
\setupwhitespace[big]
\starttext
\filler{1} \bg{Looks okay} \filler{2}
\filler{2} \bg{Looks \filler{5} okay} \filler{1}
\filler{3} \bg{Looks \filler{2} bad} \filler{3}
\stoptext
Is there a different mechanism that I can use to avoid this?
There always is ... if only to keep Hraban in keeping up and updaing mode,
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------local utilitydata = { }
utilitydata.comment={
["escape"]="[===[ ... ]===]",
["file"]="rules-001",
["format"]="cont-en",
["stamp"]="2026.02.05 16:14",
["version"]=0x1.547ae147ae148p+0,
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.variables then utilitydata.job.variables = { } end
utilitydata.job.variables.checksums={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.variables then utilitydata.job.variables = { } end
utilitydata.job.variables.collected={
["macros"]={},
["randomseed"]=0x1.c470987ff7d8p-7,
["sectionblockorder"]={},
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.structure then utilitydata.job.structure = { } end
utilitydata.job.structure.collected={
["branches"]={},
["name"]="",
["type"]="text",
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.positions then utilitydata.job.positions = { } end
utilitydata.job.positions.collected={
["shared"]={
["x_h_d"]={},
["x_h_d_hs"]={},
["x_y_w_h"]={},
["y_w_h_d"]={},
},
["user"]={},
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.datasets then utilitydata.job.datasets = { } end
utilitydata.job.datasets.collected={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.pagestates then utilitydata.job.pagestates = { } end
utilitydata.job.pagestates.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.specials then utilitydata.structures.specials = {
} end
utilitydata.structures.specials.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.sections then utilitydata.structures.sections = {
} end
utilitydata.structures.sections.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.counters then utilitydata.structures.counters = {
} end
utilitydata.structures.counters.collected={
["chemical"]={
{ 0 },
},
["combination"]={
{ 0 },
},
["endnote"]={
{ 0 },
},
["figure"]={
{ 0 },
},
["float"]={
{ 0 },
},
["footnote"]={
{ 0 },
},
["formula"]={
{ 0 },
},
["graphic"]={
{ 0 },
},
["intermezzo"]={
{ 0 },
},
["itemgroup:itemize"]={
{ 0 },
},
["itemgroup:itemize:note"]={
{ 0 },
},
["linenote"]={
{ 0 },
},
["mathnote"]={
{ 0 },
},
["paragraph"]={
{ 0 },
},
["publicationnote"]={
{ 0 },
},
["realpage"]={
{ 2 },
},
["subpage"]={
{ 2 },
},
["table"]={
{ 0 },
},
["textnote:note"]={
{ 0 },
},
["userpage"]={
{ 2 },
},
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.lists then utilitydata.structures.lists = { } end
utilitydata.structures.lists.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.pages then utilitydata.structures.pages = { } end
utilitydata.structures.pages.collected={
{
["block"]="bodypart",
["number"]=1,
["numberdata"]=1,
["prefixdata"]=2,
["state"]="start",
},
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.references then utilitydata.structures.references
= { } end
utilitydata.structures.references.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.references then utilitydata.structures.references
= { } end
utilitydata.structures.references.referred={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.parwrappers then utilitydata.job.parwrappers = { } end
utilitydata.job.parwrappers.collected={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.objects then utilitydata.job.objects = { } end
utilitydata.job.objects.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.itemgroups then utilitydata.structures.itemgroups
= { } end
utilitydata.structures.itemgroups.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.synonyms then utilitydata.structures.synonyms = {
} end
utilitydata.structures.synonyms.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.registers then utilitydata.structures.registers =
{ } end
utilitydata.structures.registers.collected={
}
if not utilitydata.structures then utilitydata.structures = { } end
if not utilitydata.structures.blocks then utilitydata.structures.blocks = { }
end
utilitydata.structures.blocks.collected={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.linkedlists then utilitydata.job.linkedlists = { } end
utilitydata.job.linkedlists.collected={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.files then utilitydata.job.files = { } end
utilitydata.job.files.collected={
}
if not utilitydata.publications then utilitydata.publications = { } end
utilitydata.publications.collected={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.meshedup then utilitydata.job.meshedup = { } end
utilitydata.job.meshedup.collected={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.fileobjreferences then utilitydata.job.fileobjreferences
= { } end
utilitydata.job.fileobjreferences.collected={
}
if not utilitydata.job then utilitydata.job = { } end
if not utilitydata.job.embedded then utilitydata.job.embedded = { } end
utilitydata.job.embedded.collected={
}
utilitydata.job.packed={
["index"]={
{
["conversionset"]="pagenumber",
},
{
["connector"]="–",
["prefix"]="no",
["set"]="part",
},
},
["keys"]={
["directives"]=true,
["metadata"]=true,
["numberdata"]=true,
["numbers"]=true,
["ownnumbers"]=true,
["pagedata"]=true,
["prefixdata"]=true,
["processors"]=true,
["sectiondata"]=true,
["specification"]=true,
},
["skip"]={
["datasets"]=true,
["positions"]=true,
["userdata"]=true,
},
["version"]=0x1.051eb851eb852p+0,
}
return utilitydata___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________