Skip to content

Commit 29888b7

Browse files
committed
fix: allow code in titles
1 parent 194996c commit 29888b7

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Web/Documentation/ChapterView.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Web\Documentation;
66

77
use Tempest\Support\Arr\ImmutableArray;
8+
use Tempest\Support\Str;
89
use Tempest\View\IsView;
910
use Tempest\View\View;
1011

@@ -35,14 +36,14 @@ public function isCurrent(Chapter $other): bool
3536
public function getSubChapters(): array
3637
{
3738
// TODO(@innocenzi): clean up
38-
preg_match_all('/<h2.*>.*<a.*href="(?<uri>.*?)".*<\/span>(?<title>.*)<\/a><\/h2>/', $this->currentChapter->body, $h2Matches);
39-
preg_match_all('/<h3.*>.*<a.*href="(?<h3uri>.*?)".*<\/span>(?<h3title>.*)<\/a><\/h3>/', $this->currentChapter->body, $h3Matches);
39+
preg_match_all('/<h2.*>.*<a.*href="(?<uri>.*?)".*?<\/span>(?<title>.*)<\/a><\/h2>/', $this->currentChapter->body, $h2Matches);
40+
preg_match_all('/<h3.*>.*<a.*href="(?<h3uri>.*?)".*?<\/span>(?<h3title>.*)<\/a><\/h3>/', $this->currentChapter->body, $h3Matches);
4041

4142
$subChapters = [];
4243

4344
foreach ($h2Matches[0] as $key => $match) {
4445
$h2Uri = $h2Matches['uri'][$key];
45-
$h2Title = $h2Matches['title'][$key];
46+
$h2Title = Str\strip_tags($h2Matches['title'][$key]);
4647
$subChapters[$h2Uri] = [
4748
'title' => $h2Title,
4849
'children' => [],
@@ -51,7 +52,7 @@ public function getSubChapters(): array
5152

5253
foreach ($h3Matches[0] as $key => $match) {
5354
$h3Uri = $h3Matches['h3uri'][$key];
54-
$h3Title = $h3Matches['h3title'][$key];
55+
$h3Title = Str\strip_tags($h3Matches['h3title'][$key]);
5556
$parentH2Uri = null;
5657
$h3Position = strpos($this->currentChapter->body, $match);
5758

src/Web/Documentation/show.view.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ class="
103103
<x-template :foreach="$subChapters as $url => $chapter">
104104
<li>
105105
<a :href="$url" :data-on-this-page="$chapter['title']" class="group relative text-sm flex items-center focus-visible:outline-(--ui-primary) py-1 text-(--ui-text-muted) hover:text-(--ui-text) data-[active]:text-(--ui-primary) transition-colors">
106-
{{ \Tempest\Support\Str\strip_tags($chapter['title']) }}
106+
{{ $chapter['title'] }}
107107
</a>
108108
</li>
109109
<li :foreach="$chapter['children'] as $url => $title">
110110
<a :href="$url" :data-on-this-page="$title" class="pl-4 group relative text-sm flex items-center focus-visible:outline-(--ui-primary) py-1 text-(--ui-text-dimmed) hover:text-(--ui-text) data-[active]:text-(--ui-primary) transition-colors">
111-
<span>{{ \Tempest\Support\Str\strip_tags($title) }}</span>
111+
<span>{{ $title }}</span>
112112
</a>
113113
</li>
114114
</x-template>

0 commit comments

Comments
 (0)