Fix guide deep links, code block styling
- Move heading IDs from hidden permalink anchors to parent headings so deep links scroll correctly (admin.php) - Change code block background from dark to light gray (guide.php) - Add pre/code CSS to frontend layout.mustache for visible code blocks
This commit is contained in:
@@ -1417,6 +1417,14 @@ function handleGuide(AdminAuth $auth, array $config): void
|
||||
$environment->addExtension(new \League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension());
|
||||
$converter = new \League\CommonMark\MarkdownConverter($environment);
|
||||
$content = $converter->convert($rawContent)->getContent();
|
||||
|
||||
// Move IDs from heading-permalink anchors to their parent headings
|
||||
// so deep links scroll to the heading element itself (not a hidden anchor)
|
||||
$content = preg_replace(
|
||||
'~<h(\d)>(.*?)<a id="([^"]+)"[^>]*></a></h\1>~s',
|
||||
'<h\1 id="\3">\2</h\1>',
|
||||
$content
|
||||
);
|
||||
} else {
|
||||
$content = '<pre>' . htmlspecialchars($rawContent) . '</pre>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user