request("$url[path]$url[query]"); $title = ''; if ($response->getStatusCode()->value == 20) { ob_start(); $mime = explode(';', $response->getMeta())[0]; if (strpos($mime, 'text/gemini') === 0) { $parser = new Gemtext($response->getBody()); $lines = $parser->parse(); $wasListItem = false; $currentListItems = []; foreach ($lines as $line) { if ($wasListItem && $line['type'] !== 'listitem') { echo "
"; } else if ($line['type'] === 'preformatted') { echo htmlentities($line['raw']); } else if ($line['type'] === 'preformatted_off') { echo ""; } else if ($line['type'] === 'heading') { if (empty($title)) { $title = $line['text']; } echo "
$line[text]"; } else if ($line['type'] === 'link') { $line['link'] = str_replace(["gemini://$geminiHost", $geminiHost], "https://$geminiHost", $line['link']); $line['text'] = $line['text'] ?: $line['link']; echo "$line[text]"; } else if ($line['type'] === 'text') { if (! empty($line['text'])) { echo "
$line[text]
"; } } } } else if (strpos($mime, 'text') === 0) { echo $response->getBody(); } else if (strpos($mime, 'image') === 0) { $src = "data:{$mime};base64," . base64_encode($response->getBody()); ?> getBody()); ?> getBody()); ?> getHeader(); echo $response->getHeader(); } echo "