How to create colored pills that span multiple lines? (multiline boxes)

Note that highlight.stroke accepts a dictionary which you can use like this

#let pill(a, b, fill: red) = {
  highlight(
    fill: fill, 
    stroke: fill, 
    radius: (left: 100%),
    [~~~~~]
  )
  h(-.7em)
  highlight(
    fill: fill, 
    stroke: fill, 
    text(white, [#a~])
  )
  highlight(
    fill: none, 
    stroke: (y: fill), 
    text(fill, [~#b])
  )
  h(-.7em)
  highlight(
    fill: none, 
    stroke: (y: fill, right: fill), 
    radius: (right: 100%),
    text(fill, [~~~~~])
  )
}

image

Still not perfect maybe but betterer.

5 Likes