If you're talking about automatically adding id
attributes to headers, no it doesn't and I'm not sure it ever will. Some Markdown flavors do, but I see those unprefixed id
s as a liability because they allow naming collisions between user-controlled IDs and the rest of the page.
In the meantime, if your extension requires it you can add support for id
attributes yourself with the following:
function addId($tag, $text)
{
if (!$tag->getEndTag())
{
return true;
}
$startPos = $tag->getPos() + $tag->getLen();
$endPos = $tag->getEndTag()->getPos();
$text = substr($text, $startPos, $endPos - $startPos);
$id = preg_replace('/[^-\\w]+/', '-', strtolower($text));
$id = preg_replace('/^-*(.*?)-*$/', '$1', $id);
$tag->setAttribute('id', $id);
return true;
}
$js = "
function (tag, text)
{
if (!tag.getEndTag())
{
return true;
}
var startPos = tag.getPos() + tag.getLen(),
endPos = tag.getEndTag().getPos(),
id;
text = text.substr(startPos, endPos - startPos);
id = text.replace(/[^-\w]+/g, '-', text.toLowerCase());
id = id.replace(/^-*(.*?)-*$/, '$1');
tag.setAttribute('id', id);
return true;
}";
$i = 0;
while (++$i <= 6)
{
$tag = $configurator->tags['H' . $i];
if (isset($tag->attributes['id']))
{
continue;
}
$tag->attributes->add('id')->required = false;
$tag->filterChain->prepend('addId')
->resetParameters()
->addParameterByName('tag')
->addParameterByName('text')
->setJS($js);
$tag->template = '<h' . $i . '><xsl:copy-of select="@id"/><xsl:apply-templates/></h' . $i . '>';
}