# ConTeXt: Heading text surrounded by lines

I'd like to replicate this heading style in ConTeXt:

The closest I've come is surrounding a centered text with \thinrules but those are at the baseline of the text instead of horizontally centered around the text:

\centeraligned{\thinrule SKILLS \thinrule}

Does someone have a solution? I'm sure it's possible with MetaFun but I haven't quite understood enough of that yet.

You can create raised rules with the \blackrule command. The correct width for the rules can be calculated when you measure the width of the section text with the \dowithnextbox command.

\define\SectionTextCommand
{\dowithnextbox
{\beginhbox
\blackrule[width=\dimexpr(\hsize-\nextboxwd-2\emwidth)/2\relax,height=0.8ex,depth=-0.6ex,color=middlecyan]%
\copy\nextbox
\blackrule[width=\dimexpr(\hsize-\nextboxwd-2\emwidth)/2\relax,height=0.8ex,depth=-0.6ex,color=middlecyan]%
\endhbox}
\hbox}

[subject]
[textstyle={\setcharactercasing[WORD]\ssa},
textcommand=\SectionTextCommand]

\starttext

\subject{Skills}

\stoptext


Another method is to use the filler mechanism to place rules at the left and right of the text which take the available space without the need to calculate it.

\definefiller
[SectionRule]
[alternative=rule,
color=middlecyan,
height=0.8ex,
depth=-0.6ex]

\definefiller
[SectionLeftRule]
[SectionRule]
[left=\zerowidthnobreakspace,

\definefiller
[SectionRightRule]
[SectionRule]
right=\zerowidthnobreakspace]