@if($document) @php $lines = explode("\n", $document->content); $sections = []; $currentSection = null; $currentContent = []; foreach ($lines as $line) { $trimmed = trim($line); // Detect section headings — lines that look like titles (short, no period, not blank) if (strlen($trimmed) > 3 && strlen($trimmed) < 80 && !str_contains($trimmed, '.') && strtoupper($trimmed) === $trimmed && $trimmed !== '') { if ($currentSection !== null) { $sections[] = ['title' => $currentSection, 'content' => implode("\n", $currentContent)]; } $currentSection = $trimmed; $currentContent = []; } else { $currentContent[] = $line; } } if ($currentSection !== null) { $sections[] = ['title' => $currentSection, 'content' => implode("\n", $currentContent)]; } // If no sections detected, treat entire content as one section if (empty($sections)) { $sections = [['title' => 'Player Handbook', 'content' => $document->content]]; } @endphp
{{-- SIDEBAR TOC --}} {{-- CONTENT --}}

Player Handbook

Version {{ $document->version_label }}

@foreach($sections as $i => $section)

{{ Str::title(strtolower($section['title'])) }}

{{ trim($section['content']) }}
@endforeach
@else

Player Handbook is not currently available.

@endif