ic/tzo: fix chapter anchors

This commit is contained in:
E. S. 2025-05-18 16:36:00 +03:00
parent 4417945078
commit 22dd4a6d9c

View File

@ -106,10 +106,11 @@ class TZOPart
// chapter markers
$html = preg_replace_callback(
'/<center>(?:# )?(\(\d+\)|([\w\s?]+))<\/center>/',
'/<center>(?:# )?(\((\d+)\)|([\w\s?]+))<\/center>/',
function ($matches) {
$number = $matches[1];
return '<p class="tzo-chapter" id="chapter'.$number.'">'.$number.'</p>';
$id = isset($matches[2]) && $matches[2] != '' ? 'chapter'.$matches[2] : '';
return '<p class="tzo-chapter" id="'.$id.'">'.$number.'</p>';
},
$html
);