prettier package descriptions
authorMichael Wallner <mike@php.net>
Thu, 21 Jan 2021 09:03:15 +0000 (10:03 +0100)
committerMichael Wallner <mike@php.net>
Thu, 21 Jan 2021 09:03:20 +0000 (10:03 +0100)
public/html.php

index 659d19a06cd2d9b34aa636b60dc8cf0bf93a9761..dfddc50b75e68a179c18c1a4a18363ed32f1390f 100644 (file)
@@ -92,7 +92,7 @@ $res->addHeader("Link", "<" . dirname((new http\Env\Url)->path) . $css . ">; rel
                        .old-version, #new-toggle {
                                display: none;
                        }
-                       .package-description {
+                       p.package-description, div.package-description p {
                                white-space: pre-line;
                        }
                        form * {
@@ -125,8 +125,22 @@ $res->addHeader("Link", "<" . dirname((new http\Env\Url)->path) . $css . ">; rel
                        <h2><?= htmlspecialchars($package) ?></h2>
                        <?php if ($info) : ?>
                                <h3><?= htmlspecialchars($info["title"]) ?><br>
-                                       <small>License: <?= htmlspecialchars($info["license"]) ?></small></h3>
-                               <p class="package-description"><?= htmlspecialchars($info["description"]) ?></p>
+                                       <small>License: <?= htmlspecialchars($info["license"]) ?><br>
+                                               <a href="//pecl.php.net/package/<?= htmlspecialchars($package) ?>">View at PECL</a></small></h3>
+                               <?php if (extension_loaded("discount")) : ?>
+                               <div class="package-description">
+                                       <?php
+                                       $md = MarkdownDocument::createFromString($info["description"]);
+                                       $md->compile(   MarkdownDocument::AUTOLINK |
+                                                                       MarkdownDocument::ONE_COMPAT);
+                                       echo $md->getHtml();
+                                       ?>
+                               </div>
+                               <?php else : ?>
+                               <p class="package-description">
+                                       <?= htmlspecialchars($info["description"]) ?>
+                               </p>
+                               <?php endif; ?>
                        <?php endif; ?>
                        <table class="table table-full versions">
                                <thead>
@@ -185,7 +199,7 @@ $res->addHeader("Link", "<" . dirname((new http\Env\Url)->path) . $css . ">; rel
                        <form name="search"></form>
                        <ul class="list-inline package-list">
                        <?php foreach (array_map("htmlspecialchars", $packages) as $index => $pkg) : ?>
-                               <?php $next = strtolower($pkg{0}); ?>
+                               <?php $next = strtolower($pkg[0]); ?>
                                <?php if (isset($prev) && $next != $prev) : ?>
 
                        </ul>